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
This commit is contained in:
José Matox 2002-06-14 12:24:28 +00:00
parent 8dccf74da7
commit c788ba4d67
4 changed files with 22 additions and 16 deletions

View File

@ -730,6 +730,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
case LFUN_INSET_TOGGLE:
mathcursor->insetToggle();
updateLocal(bv, true);
break;
default:

View 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);
}

View 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);
}
}

View 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);
}