From 8c3c804a4de7d0ceeac2b0b258e2494f5109b471 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 30 Nov 2001 09:16:16 +0000 Subject: [PATCH] fix drawing glitch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3118 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formula.C | 7 ++-- src/mathed/formulabase.C | 3 +- src/mathed/math_deliminset.C | 4 +-- src/mathed/math_gridinset.C | 64 ++++++++++++++++++------------------ 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 83fe96b561..0b14506d4f 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -335,8 +335,7 @@ void InsetFormula::read(Buffer const *, LyXLex & lex) void InsetFormula::draw(BufferView * bv, LyXFont const & font, int y, float & xx, bool) const { - int x = int(xx) - 1; - y -= 2; + int x = int(xx); Painter & pain = bv->painter(); @@ -597,13 +596,13 @@ bool InsetFormula::insetAllowed(Inset::Code code) const int InsetFormula::ascent(BufferView *, LyXFont const &) const { - return par_->ascent() + 2; + return par_->ascent() + 1; } int InsetFormula::descent(BufferView *, LyXFont const &) const { - return par_->descent() - 2; + return par_->descent() + 1; } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 7e9d1b8844..6f796ceea8 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -174,7 +174,7 @@ void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const { mathcursor->getPos(x, y); x += xo_; - y += yo_ - 3; + y += yo_; //lyxerr << "getCursorPos: " << x << " " << y << "\n"; } @@ -191,7 +191,6 @@ void InsetFormulaBase::toggleInsetCursor(BufferView * bv) int x; int y; mathcursor->getPos(x, y); - y -= 3; y -= yo_; int asc = 0; int des = 0; diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index f74f8086a3..57ba6a220f 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -59,8 +59,8 @@ void MathDelimInset::normalize(NormalStream & os) const int MathDelimInset::dw() const { int w = height() / 5; - if (w > 15) - w = 15; + if (w > 12) + w = 12; if (w < 4) w = 4; return w; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index f2d3ba939b..9e5f84dc0c 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -38,7 +38,7 @@ string verboseHLine(int n) MathGridInset::RowInfo::RowInfo() - : skip_(0), lines_(0) + : lines_(0), skip_(0) {} @@ -220,8 +220,7 @@ void MathGridInset::metrics(MathMetricsInfo const & mi) const // let the cells adjust themselves MathNestInset::metrics(mi); - // adjust vertical structure - rowinfo_[0].offset_ = 0; + // compute absolute sizes of vertical structure for (row_type row = 0; row < nrows(); ++row) { int asc = 0; int desc = 0; @@ -232,17 +231,22 @@ void MathGridInset::metrics(MathMetricsInfo const & mi) const } rowinfo_[row].ascent_ = asc; rowinfo_[row].descent_ = desc; - rowinfo_[row].offset_ += asc + HLINESEP * rowinfo_[row].lines_; - - rowinfo_[row + 1].offset_ = - rowinfo_[row].offset_ + - rowinfo_[row].descent_ + - rowinfo_[row].skipPixels() + - ROWSEP; } + rowinfo_[0].ascent_ += HLINESEP * rowinfo_[0].lines_; rowinfo_[nrows()].ascent_ = 0; rowinfo_[nrows()].descent_ = 0; - rowinfo_[nrows()].offset_ += HLINESEP * rowinfo_[nrows()].lines_; + + // compute vertical offsets + rowinfo_[0].offset_ = 0; + for (row_type row = 1; row <= nrows(); ++row) { + rowinfo_[row].offset_ = + rowinfo_[row - 1].offset_ + + rowinfo_[row - 1].descent_ + + rowinfo_[row - 1].skipPixels() + + ROWSEP + + rowinfo_[row].lines_ * HLINESEP + + rowinfo_[row].ascent_; + } // adjust vertical offset int h = 0; @@ -251,35 +255,34 @@ void MathGridInset::metrics(MathMetricsInfo const & mi) const h = 0; break; case 'b': - h = rowinfo_[nrows()].offset_; + h = rowinfo_[nrows() - 1].offset_; break; default: - h = rowinfo_[nrows()].offset_ / 2; + h = rowinfo_[nrows() - 1].offset_ / 2; } - //lyxerr << "\nnrows: " << nrows() << " h: " << h << '\n'; - for (row_type row = 0; row <= nrows(); ++row) { + for (row_type row = 0; row <= nrows(); ++row) rowinfo_[row].offset_ -= h; - //lyxerr << "row: " << row << " off: " << rowinfo_[row].offset_ << '\n'; - } - - // adjust horizontal structure - colinfo_[0].offset_ = BORDER; + + // compute absolute sizes of horizontal structure for (col_type col = 0; col < ncols(); ++col) { int wid = 0; for (row_type row = 0; row < nrows(); ++row) wid = std::max(wid, xcell(index(row, col)).width()); - colinfo_[col].width_ = wid; - colinfo_[col].offset_ += VLINESEP * colinfo_[col].lines_; - - colinfo_[col + 1].offset_ = - colinfo_[col].offset_ + - colinfo_[col].width_ + - colinfo_[col].skip_ + - COLSEP; + colinfo_[col].width_ = wid; } colinfo_[ncols()].width_ = 0; - colinfo_[ncols()].offset_ += VLINESEP * colinfo_[ncols()].lines_; + + // compute horizontal offsets + colinfo_[0].offset_ = BORDER; + for (col_type col = 1; col <= ncols(); ++col) { + colinfo_[col].offset_ = + colinfo_[col - 1].offset_ + + colinfo_[col - 1].width_ + + colinfo_[col - 1].skip_ + + COLSEP + + colinfo_[col].lines_ * VLINESEP; + } width_ = colinfo_[ncols() - 1].offset_ @@ -360,7 +363,6 @@ void MathGridInset::draw(Painter & pain, int x, int y) const for (int i = 0; i < rowinfo_[row].lines_; ++i) { int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_ - i * HLINESEP - HLINESEP/2 - ROWSEP/2; - //lyxerr << "i: " << i << " yy: " << yy << '\n'; pain.line(x + 1, yy, x + width_ - 1, yy); } @@ -368,7 +370,6 @@ void MathGridInset::draw(Painter & pain, int x, int y) const for (int i = 0; i < colinfo_[col].lines_; ++i) { int xx = x + colinfo_[col].offset_ - i * VLINESEP - VLINESEP/2 - COLSEP/2; - //lyxerr << "i: " << i << " xx: " << xx << '\n'; pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1); } } @@ -715,4 +716,3 @@ void MathGridInset::write(WriteStream & os) const os << "\\\\" << s.c_str(); } - -- 2.39.2