On Sat, Apr 02, 2005 at 01:11:29PM +0000, Angus Leeming wrote: > On Saturday 02 April 2005 09:53, Martin Vermeer wrote: > > In the math insets AMSArray and Cases, there is a UI bug that the > > small corner markers are displaced to the right. The reason for > > this is the way they call MathGridInset::draw. They do so: > > > > MathGridInset::draw(pi, x + 6, y) > > > > and > > > > MathGridInset::draw(pi, x + 8, y) > > > > This does the correct thing of shifting the grid with content > > ("blue stuff") to inside the braces/brackets of these structures, > > but unfortunately it also shifts the corner markers to the right by > > 6...8 pixels, as seen in the MathGridInset::draw code, as the > > drawMarkers2 method is called from within draw. > > > > The clean solution would be to separate out draw and drawMarkers, > > requiring two method calls everywhere where there is now only a > > call to MathGridInset::draw. That is in Array, AmsArray, Cases, > > Hull, Par, SubStack and Tabular. This could be streamlined a bit by > > adding a public method drawWithoutMarkers to GridInset, to be used > > only from Cases and AmsArray. > > > > Of course there exist fudges too for the problem not requiring this > > reworking, but I don't like fudges. They tend to come back and > > bite. > > > > What say you? > > Sounds like a plan. Go for it. > Angus
I implemented this, tested and it works precisely as planned. Attached. Georg, would you please put your existing patch in soon? This one clashes with it (or my local version of part of it) in math_amsarray.C, as you can see in the attached. I'll resolve the conflict then. - Martin
Index: math_amsarrayinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_amsarrayinset.C,v retrieving revision 1.26 diff -u -r1.26 math_amsarrayinset.C --- math_amsarrayinset.C 30 Mar 2005 09:05:30 -0000 1.26 +++ math_amsarrayinset.C 2 Apr 2005 16:35:39 -0000 @@ -82,11 +92,36 @@ void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const { - MathGridInset::draw(pi, x + 6, y); + MathGridInset::drawWithoutMarkers(pi, x + 6, y); + drawMarkers2(pi, x, y); int const yy = y - dim_.ascent(); mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), name_left()); mathed_draw_deco(pi, x + dim_.width() - 6, yy, 5, dim_.height(), name_right()); setPosCache(pi, x, y); +} + + +bool MathAMSArrayInset::getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + switch (cmd.action) { + case LFUN_TABULAR_FEATURE: { + //istringstream is(cmd.argument); + //string s; + //is >> s; + string const s = cmd.argument; + if (s == "add-vline-left" || s == "add-vline-right") { + flag.message(bformat( + N_("Can't add vertical grid lines in '%1$s'"), + name_)); + flag.enabled(false); + return true; + } + return MathGridInset::getStatus(cur, cmd, flag); + } + default: + return MathGridInset::getStatus(cur, cmd, flag); + } } Index: math_gridinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.C,v retrieving revision 1.156 diff -u -r1.156 math_gridinset.C --- math_gridinset.C 14 Feb 2005 14:25:17 -0000 1.156 +++ math_gridinset.C 2 Apr 2005 16:35:39 -0000 @@ -479,6 +479,13 @@ void MathGridInset::draw(PainterInfo & pi, int x, int y) const { + drawWithoutMarkers(pi, x, y); + drawMarkers2(pi, x, y); +} + + +void MathGridInset::drawWithoutMarkers(PainterInfo & pi, int x, int y) const +{ for (idx_type idx = 0; idx < nargs(); ++idx) cell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx)); @@ -499,7 +506,6 @@ xx, y + dim_.descent() - 1, LColor::foreground); } - drawMarkers2(pi, x, y); } @@ -1016,7 +1022,7 @@ void MathGridInset::doDispatch(LCursor & cur, FuncRequest & cmd) { - //lyxerr << "*** MathGridInset: request: " << cmd << endl; + lyxerr << "*** MathGridInset: request: " << cmd << endl; switch (cmd.action) { case LFUN_MOUSE_RELEASE: Index: math_gridinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.h,v retrieving revision 1.86 diff -u -r1.86 math_gridinset.h --- math_gridinset.h 14 Feb 2005 14:25:17 -0000 1.86 +++ math_gridinset.h 2 Apr 2005 16:35:39 -0000 @@ -98,6 +98,8 @@ /// void draw(PainterInfo & pi, int x, int y) const; /// + void drawWithoutMarkers(PainterInfo & pi, int x, int y) const; + /// void metricsT(TextMetricsInfo const & mi, Dimension & dim) const; /// void drawT(TextPainter & pi, int x, int y) const; Index: math_casesinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_casesinset.C,v retrieving revision 1.28 diff -u -r1.28 math_casesinset.C --- math_casesinset.C 24 Mar 2005 16:26:15 -0000 1.28 +++ math_casesinset.C 2 Apr 2005 16:35:39 -0000 @@ -60,7 +60,8 @@ void MathCasesInset::draw(PainterInfo & pi, int x, int y) const { mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 6, dim_.height(), "{"); - MathGridInset::draw(pi, x + 8, y); + MathGridInset::drawWithoutMarkers(pi, x + 8, y); + drawMarkers2(pi, x, y); setPosCache(pi, x, y); }
pgp6pTbFpTMZD.pgp
Description: PGP signature