From: Jean-Marc Lasgouttes Date: Fri, 8 Sep 2006 13:52:41 +0000 (+0000) Subject: Fix bug 2251 (from G Baum) X-Git-Tag: 1.6.10~12627 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=45808381d014ac106d235f8fa7a642d598dfba39;p=features.git Fix bug 2251 (from G Baum) * 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 --- diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index cf78ef34c5..14ea3a0810 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -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()) { diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index b93c55c967..a7a220252f 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -116,6 +116,8 @@ public: /// void addPreview(lyx::graphics::PreviewLoader &) const; + /// + static int displayMargin() { return 12; } protected: MathHullInset(MathHullInset const &); diff --git a/src/text2.C b/src/text2.C index 37d1a30566..0824e42d18 100644 --- a/src/text2.C +++ b/src/text2.C @@ -51,6 +51,8 @@ #include "insets/insetenv.h" +#include "mathed/math_hullinset.h" + #include "support/textutils.h" #include @@ -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.