From c788ba4d674b6eec0bef725b861e74fe32eaaba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Fri, 14 Jun 2002 12:24:28 +0000 Subject: [PATCH] playing around with visual feedback for the new mathed font insets now a font change gets small (and hopefully not too annoying) markers and no two "logical" positions end up in the same physical position on screen. Comments welcome. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4402 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formulabase.C | 1 + src/mathed/math_fontinset.C | 16 ++++++++++++---- src/mathed/math_nestinset.C | 5 +---- src/mathed/math_support.C | 16 ++++++++-------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 12eaf7b76f..af2a4e33e4 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -730,6 +730,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_INSET_TOGGLE: mathcursor->insetToggle(); + updateLocal(bv, true); break; default: diff --git a/src/mathed/math_fontinset.C b/src/mathed/math_fontinset.C index c07d9e09d3..b1eb6ba1f7 100644 --- a/src/mathed/math_fontinset.C +++ b/src/mathed/math_fontinset.C @@ -11,6 +11,7 @@ #include "math_support.h" #include "LaTeXFeatures.h" #include "textpainter.h" +#include "frontends/Painter.h" @@ -18,7 +19,7 @@ MathFontInset::MathFontInset(string const & name) : MathNestInset(1), name_(name) { - lock(true); + //lock(true); } @@ -32,9 +33,9 @@ void MathFontInset::metrics(MathMetricsInfo & mi) const { MathFontSetChanger dummy(mi.base, name_.c_str()); xcell(0).metrics(mi); - width_ = xcell(0).width(); + width_ = xcell(0).width() + 6; ascent_ = xcell(0).ascent(); - descent_ = xcell(0).descent(); + descent_ = xcell(0).descent() + 3; } @@ -43,7 +44,14 @@ void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const //lyxerr << "MathFontInset::draw\n"; MathNestInset::draw(pi, x, y); MathFontSetChanger dummy(pi.base, name_.c_str()); - xcell(0).draw(pi, x, y); + xcell(0).draw(pi, x + 3, y); + int b = x + 1; + int t = x + width() - 1; + int d = y + descent(); + pi.pain.line(b, d - 3, b, d, LColor::mathframe); + pi.pain.line(t, d - 3, t, d, LColor::mathframe); + pi.pain.line(b, d, b + 3, d, LColor::mathframe); + pi.pain.line(t - 2, d, t, d, LColor::mathframe); } diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 31523e5504..3983db44c7 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -147,12 +147,9 @@ void MathNestInset::dump() const void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const { - lyxerr << "MathNestInset::draw()\n"; - if (lock_) { - lyxerr << "MathNestInset::draw background\n"; + if (lock_) pi.pain.fillRectangle(x, y - ascent(), width(), height(), LColor::mathlockbg); - } } diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index fce3be0cf0..89fd9e2913 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -410,11 +410,11 @@ int mathed_string_descent(LyXFont const & font, string const & s) -void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h, +void mathed_draw_deco(MathPainterInfo & pi, int x, int y, int w, int h, const string & name) { if (name == ".") { - pain.pain.line(x + w/2, y, x + w/2, y + h, + pi.pain.line(x + w/2, y, x + w/2, y + h, LColor::mathcursor, Painter::line_onoffdash); return; } @@ -454,7 +454,7 @@ void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h, else mt.transform(xx, yy); mt.transform(x2, y2); - pain.pain.line( + pi.pain.line( x + int(xx + 0.5), y + int(yy + 0.5), x + int(x2 + 0.5), y + int(y2 + 0.5), LColor::math); @@ -474,25 +474,25 @@ void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h, yp[j] = y + int(yy + 0.5); // lyxerr << "P[" << j " " << xx << " " << yy << " " << x << " " << y << "]"; } - pain.pain.lines(xp, yp, n, LColor::math); + pi.pain.lines(xp, yp, n, LColor::math); } } } -void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const * p) +void mathed_draw_framebox(MathPainterInfo & pi, int x, int y, MathInset const * p) { if (mathcursor && mathcursor->isInside(p)) - pain.pain.rectangle(x, y - p->ascent(), p->width(), p->height(), + pi.pain.rectangle(x, y - p->ascent(), p->width(), p->height(), LColor::mathframe); } // In the future maybe we use a better fonts renderer -void drawStr(MathPainterInfo & pain, LyXFont const & font, +void drawStr(MathPainterInfo & pi, LyXFont const & font, int x, int y, string const & str) { - pain.pain.text(x, y, str, font); + pi.pain.text(x, y, str, font); }