]> git.lyx.org Git - lyx.git/commitdiff
Enable InsetExternal to be hit by the mouse once again.
authorAngus Leeming <leeming@lyx.org>
Thu, 4 Dec 2003 16:53:53 +0000 (16:53 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 4 Dec 2003 16:53:53 +0000 (16:53 +0000)
Some small additions to the ExternalTransforms stuff.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8193 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/ExternalTransforms.C
src/insets/ExternalTransforms.h
src/insets/insetexternal.C

index b7d20cd6d78955e9565b6fb1616f9ba70651bda4..ca399e2b90b31815a0cf9f5139b0de04c06e31eb 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-04  Angus Leeming  <leeming@lyx.org>
+
+       * insetexternal.C (draw): update the xo_, yo_ cache.
+
+       * ExternalTransforms.[Ch] (ResizeData): add a usingScale member function.
+       (RotationDataType): new helper struct wrapping the
+       RotationData::OriginType enum.
 
 2003-12-03  André Pönitz  <poenitz@gmx.net>
 
index 9d77c37d2ee598dbafa96da9c7fac7220186b3ab..05b66b7b05b5345700171e21df4433f43b7a6bd4 100644 (file)
@@ -45,8 +45,13 @@ void ExtraData::set(string const & id, string const & data)
 
 bool ResizeData::no_resize() const
 {
-       return float_equal(scale, 0.0, 0.05) &&
-               width.zero() && height.zero();
+       return !usingScale() && width.zero() && height.zero();
+}
+
+
+bool ResizeData::usingScale() const
+{
+       return !float_equal(scale, 0.0, 0.05);
 }
 
 
@@ -90,15 +95,27 @@ string const ResizeLatexCommand::front_impl() const
                return string();
 
         std::ostringstream os;
-       if (!float_equal(data.scale, 0.0, 0.05)) {
+       if (data.usingScale()) {
                double const scl = data.scale / 100.0;
                os << "\\scalebox{" << scl << "}{" << scl << "}{";
        } else {
+               string width  = "!";
+               string height = "!";
+               if (data.keepAspectRatio) {
+                       if (data.width.inPixels(10) > data.height.inPixels(10))
+                               width = data.width.asLatexString();
+                       else
+                               height = data.height.asLatexString();
+               } else {
+                       if (!data.width.zero())
+                               width = data.width.asLatexString();
+                       if (!data.height.zero())
+                               height = data.height.asLatexString();
+               }
+               
                os << "\\resizebox{"
-                  << (data.width.zero()  ?
-                      "!" : data.width.asLatexString()) << "}{"
-                  << (data.height.zero() ?
-                      "!" : data.height.asLatexString()) << "}{";
+                  << width << "}{"
+                  << height << "}{";
        }
        return os.str();
 }
@@ -210,7 +227,7 @@ string const ResizeLatexOption::option_impl() const
                return string();
 
         std::ostringstream os;
-       if (!float_equal(data.scale, 0.0, 0.05)) {
+       if (data.usingScale()) {
                if (!float_equal(data.scale, 100.0, 0.05))
                        os << "scale=" << data.scale / 100.0 << ',';
                return os.str();
index 9275759c5820bb3b63a2bb41a76ffe4c0fc9323e..f5ea527a7ca9bc205be7a55492caa49fdb8b32ba 100644 (file)
@@ -59,6 +59,8 @@ public:
        ResizeData() : scale(0), keepAspectRatio(false) {}
        bool no_resize() const;
 
+       bool usingScale() const;
+
        float scale;
        LyXLength width;
        LyXLength height;
@@ -100,6 +102,18 @@ private:
 };
 
 
+/** \c RotationDataType is a wrapper for RotationData::OriginType
+ *  It can be forward-declared and passed as a function argument without
+ *  having to expose this header file.
+ */
+class RotationDataType {
+       RotationData::OriginType val_;
+public:
+       RotationDataType(RotationData::OriginType val) : val_(val) {}
+       operator RotationData::OriginType() const { return val_; }
+};
+
+
 /*
  * Transformers generating commands
  */
index b6239cc34b3fdbe08c175601819349949031036d..7c7d888a2c6cdbe0a2b004163446e90cc54328c9 100644 (file)
@@ -482,6 +482,8 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetExternal::draw(PainterInfo & pi, int x, int y) const
 {
+       xo_ = x;
+       yo_ = y;
        renderer_->draw(pi, x, y);
 }