]> git.lyx.org Git - features.git/commitdiff
Fix bug 2251 (from G Baum)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 8 Sep 2006 13:52:41 +0000 (13:52 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 8 Sep 2006 13:52:41 +0000 (13:52 +0000)
* src/mathed/math_hullinset.h (displayMargin): new static method.
* src/mathed/math_hullinset.C (metrics): use displayMargin().

* src/text2.C (cursorUp, cursorDown): use MathHullInset::displayMargin.

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

src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/text2.C

index cf78ef34c5b12bda1f15ab7ba639c0528dcb6876..14ea3a08107fe09de8f7c1630900034abbc628e3 100644 (file)
@@ -284,7 +284,7 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
                // insert a one pixel gap in front of the formula
                dim.wid += 1;
                if (display())
-                       dim.des += 12;
+                       dim.des += displayMargin();
                dim_ = dim;
                return;
        }
@@ -296,8 +296,8 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
        MathGridInset::metrics(mi, dim);
 
        if (display()) {
-               dim.asc += 12;
-               dim.des += 12;
+               dim.asc += displayMargin();
+               dim.des += displayMargin();
        }
 
        if (numberedType()) {
index b93c55c96784c0771f6a668e8bf537a63a3cd1c8..a7a220252f8cad16c4e27c90be1cd57cc913285a 100644 (file)
@@ -116,6 +116,8 @@ public:
        ///
        void addPreview(lyx::graphics::PreviewLoader &) const;
 
+       ///
+       static int displayMargin() { return 12; }
 
 protected:
        MathHullInset(MathHullInset const &);
index 37d1a3056642828a072d2f1498a4ef4f7adf159a..0824e42d184c2d87300d029d62460b69c47468b6 100644 (file)
@@ -51,6 +51,8 @@
 
 #include "insets/insetenv.h"
 
+#include "mathed/math_hullinset.h"
+
 #include "support/textutils.h"
 
 #include <boost/current_function.hpp>
@@ -1078,7 +1080,10 @@ bool LyXText::cursorUp(LCursor & cur)
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
                LCursor old = cur;
-               editXY(cur, x, y - par.rows()[row].ascent() - 1);
+               // Go to middle of previous row. 16 found to work OK;
+               // 12 = top/bottom margin of display math
+               int const margin = 3 * MathHullInset::displayMargin() / 2;
+               editXY(cur, x, y - par.rows()[row].ascent() - margin);
                cur.clearSelection();
 
                // This happens when you move out of an inset.
@@ -1124,7 +1129,9 @@ bool LyXText::cursorDown(LCursor & cur)
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
                LCursor old = cur;
-               editXY(cur, x, y + par.rows()[row].descent() + 1);
+               // To middle of next row
+               int const margin = 3 * MathHullInset::displayMargin() / 2;
+               editXY(cur, x, y + par.rows()[row].descent() + margin);
                cur.clearSelection();
 
                // This happens when you move out of an inset.