]> git.lyx.org Git - features.git/commitdiff
playing around with visual feedback for the new mathed font insets
authorJosé Matox <jamatos@lyx.org>
Fri, 14 Jun 2002 12:24:28 +0000 (12:24 +0000)
committerJosé Matox <jamatos@lyx.org>
Fri, 14 Jun 2002 12:24:28 +0000 (12:24 +0000)
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
src/mathed/math_fontinset.C
src/mathed/math_nestinset.C
src/mathed/math_support.C

index 12eaf7b76f890dc00ba056d66bd83c7454ee0a5c..af2a4e33e4cd66e5e1489f8bce0a811cac0616d2 100644 (file)
@@ -730,6 +730,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
 
        case LFUN_INSET_TOGGLE:
                mathcursor->insetToggle();
+               updateLocal(bv, true);
                break;
 
        default:
index c07d9e09d3c1319f3b67e500193cdcbe1fafe84a..b1eb6ba1f7043e23cb6a64375273922c82276194 100644 (file)
@@ -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); 
 }
 
 
index 31523e5504dc096b61e07f3da320f379e96f4f18..3983db44c710f11ae1cf94f0447a279cb8a7102e 100644 (file)
@@ -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);
-       }
 }
 
 
index fce3be0cf0df6fca6a54ce036e56a46e4eee4450..89fd9e2913edeb4a530949167360f815e8c3981c 100644 (file)
@@ -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);
 }