Bugfix _and_ a step towards IU in one patch... mathed's xo_/yo_ and inset's top_x/top_baseline cache have been functionally the same. This uses now xo_/yo_ all over the place and removes mathed's "double caching"
Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
? 1.diff ? 1.diff.gz ? 2.diff ? 3.diff ? ?t ? fullredraw.diff ? par-row.diff ? textcache.diff ? insets/.insetcommand.C.swp ? insets/.insettoc.C.swp ? insets/1.diff ? mathed/cursor.diff ? support/1.diff Index: insets/inset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.C,v retrieving revision 1.116 diff -u -p -r1.116 inset.C --- insets/inset.C 10 Nov 2003 09:06:40 -0000 1.116 +++ insets/inset.C 10 Nov 2003 15:27:52 -0000 @@ -26,14 +26,14 @@ using std::string; InsetOld::InsetOld() : InsetBase(), - top_x(0), top_baseline(0), scx(0), owner_(0), + xo_(0), yo_(0), scx(0), owner_(0), background_color_(LColor::inherit) {} InsetOld::InsetOld(InsetOld const & in) : InsetBase(), - top_x(0), top_baseline(0), scx(0), owner_(0), + xo_(0), yo_(0), scx(0), owner_(0), name_(in.name_), background_color_(in.background_color_) {} Index: insets/inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v retrieving revision 1.139 diff -u -p -r1.139 inset.h --- insets/inset.h 10 Nov 2003 11:26:33 -0000 1.139 +++ insets/inset.h 10 Nov 2003 15:27:52 -0000 @@ -213,9 +213,9 @@ public: /// LColor_color backgroundColor() const; /// - int x() const { return top_x; } + int x() const { return xo_; } /// - int y() const { return top_baseline; } + int y() const { return yo_; } /// virtual void deleteLyXText(BufferView *, bool = true) const {} /// returns the actuall scroll-value @@ -288,9 +288,9 @@ public: virtual void addPreview(lyx::graphics::PreviewLoader &) const {} protected: /// - mutable int top_x; + mutable int xo_; /// - mutable int top_baseline; + mutable int yo_; /// mutable int scx; /// Index: insets/insetcollapsable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.202 diff -u -p -r1.202 insetcollapsable.C --- insets/insetcollapsable.C 10 Nov 2003 14:29:39 -0000 1.202 +++ insets/insetcollapsable.C 10 Nov 2003 15:27:52 -0000 @@ -146,8 +146,8 @@ void InsetCollapsable::draw(PainterInfo button_dim.y1 = -aa; button_dim.y2 = -aa + dim_collapsed.height(); - top_x = x; - top_baseline = y; + xo_ = x; + yo_ = y; if (!isOpen()) { draw_collapsed(pi, x, y); @@ -327,7 +327,7 @@ InsetCollapsable::priv_dispatch(FuncRequ int InsetCollapsable::insetInInsetY() const { - return inset.y() - top_baseline + inset.insetInInsetY(); + return inset.y() - yo_ + inset.insetInInsetY(); } Index: insets/insetcommand.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v retrieving revision 1.102 diff -u -p -r1.102 insetcommand.C --- insets/insetcommand.C 10 Nov 2003 13:23:11 -0000 1.102 +++ insets/insetcommand.C 10 Nov 2003 15:27:52 -0000 @@ -48,6 +48,8 @@ void InsetCommand::metrics(MetricsInfo & void InsetCommand::draw(PainterInfo & pi, int x, int y) const { + xo_ = x; + yo_ = y; button_.draw(pi, x, y); } Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.372 diff -u -p -r1.372 insettabular.C --- insets/insettabular.C 10 Nov 2003 13:23:12 -0000 1.372 +++ insets/insettabular.C 10 Nov 2003 15:27:53 -0000 @@ -255,8 +255,8 @@ void InsetTabular::draw(PainterInfo & pi if (!owner()) x += scroll(); - top_x = x; - top_baseline = y; + xo_ = x; + yo_ = y; x += ADD_TO_TABULAR_WIDTH; int cell = 0; @@ -474,7 +474,7 @@ void InsetTabular::edit(BufferView * bv, setPos(bv, x, y); clearSelection(); finishUndo(); - int xx = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell); + int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell); bv->cursor().push(this); if (x > xx) activateCellInset(bv, x - xx, y - cursory_); @@ -623,7 +623,7 @@ InsetTabular::priv_dispatch(FuncRequest clearSelection(); int column = actcol; if (bv->top_y() + bv->painter().paperHeight() - < top_baseline + tabular.getHeightOfTabular()) + < yo_ + tabular.getHeightOfTabular()) { bv->scrollDocView(bv->top_y() + bv->painter().paperHeight()); actcell = tabular.getCellBelow(first_visible_cell) + column; @@ -638,9 +638,9 @@ InsetTabular::priv_dispatch(FuncRequest if (hs) clearSelection(); int column = actcol; - if (top_baseline < 0) { + if (yo_ < 0) { bv->scrollDocView(bv->top_y() - bv->painter().paperHeight()); - if (top_baseline > 0) + if (yo_ > 0) actcell = column; else actcell = tabular.getCellBelow(first_visible_cell) + column; @@ -968,7 +968,7 @@ void InsetTabular::calculate_dimensions_ void InsetTabular::getCursorPos(BufferView *, int & x, int & y) const { - x = TEXT_TO_INSET_OFFSET + cursorx_ - top_x; + x = TEXT_TO_INSET_OFFSET + cursorx_ - xo_; y = TEXT_TO_INSET_OFFSET + cursory_; } @@ -1015,7 +1015,7 @@ void InsetTabular::setPos(BufferView * b lx += tabular.getWidthOfColumn(actcell + 1) + tabular.getAdditionalWidth(actcell); - cursorx_ = lx - tabular.getWidthOfColumn(actcell) + top_x + 2; + cursorx_ = lx - tabular.getWidthOfColumn(actcell) + xo_ + 2; resetPos(bv); } @@ -1030,7 +1030,7 @@ int InsetTabular::getCellXPos(int cell) for (; c < cell; ++c) lx += tabular.getWidthOfColumn(c); - return lx - tabular.getWidthOfColumn(cell) + top_x; + return lx - tabular.getWidthOfColumn(cell) + xo_; } @@ -1091,8 +1091,8 @@ void InsetTabular::resetPos(BufferView * } else if (cursorx_ - offset < 20) { scroll(bv, 20 - cursorx_ + offset); updateLocal(bv); - } else if (scroll() && top_x > 20 && - top_x + tabular.getWidthOfTabular() > bv->workWidth() - 20) { + } else if (scroll() && xo_ > 20 && + xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) { scroll(bv, old_x - cursorx_); updateLocal(bv); } Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.535 diff -u -p -r1.535 insettext.C --- insets/insettext.C 10 Nov 2003 13:23:13 -0000 1.535 +++ insets/insettext.C 10 Nov 2003 15:27:53 -0000 @@ -241,8 +241,8 @@ void InsetText::draw(PainterInfo & pi, i { // update our idea of where we are. Clearly, we should // not have to know this information. - top_x = x; - top_baseline = y; + xo_ = x; + yo_ = y; int const start_x = x; @@ -271,7 +271,7 @@ void InsetText::drawFrame(Painter & pain { int const ttoD2 = TEXT_TO_INSET_OFFSET / 2; int const frame_x = x + ttoD2; - int const frame_y = top_baseline - dim_.asc + ttoD2; + int const frame_y = yo_ - dim_.asc + ttoD2; int const frame_w = dim_.wid - TEXT_TO_INSET_OFFSET; int const frame_h = dim_.asc + dim_.des - TEXT_TO_INSET_OFFSET; pain.rectangle(frame_x, frame_y, frame_w, frame_h, frameColor()); @@ -689,7 +689,7 @@ void InsetText::validate(LaTeXFeatures & void InsetText::getCursorPos(BufferView *, int & x, int & y) const { - x = cx() - top_x; + x = cx() - xo_; y = cy(); } @@ -918,7 +918,7 @@ void InsetText::setFrameColor(LColor_col int InsetText::cx() const { - return text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET; + return text_.cursor.x() + xo_ + TEXT_TO_INSET_OFFSET; } @@ -1006,7 +1006,7 @@ void InsetText::clearInset(BufferView * } if (ty + h > pain.paperHeight()) h = pain.paperHeight(); - if (top_x + w > pain.paperWidth()) + if (xo_ + w > pain.paperWidth()) w = pain.paperWidth(); pain.fillRectangle(start_x + 1, ty + 1, w - 3, h - 1, backgroundColor()); } Index: insets/insettoc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.C,v retrieving revision 1.64 diff -u -p -r1.64 insettoc.C --- insets/insettoc.C 5 Nov 2003 12:06:18 -0000 1.64 +++ insets/insettoc.C 10 Nov 2003 15:27:53 -0000 @@ -80,10 +80,6 @@ InsetTOC::priv_dispatch(FuncRequest cons { switch (cmd.action) { case LFUN_MOUSE_RELEASE: - if (button().box().contains(cmd.x, cmd.y)) - InsetCommandMailer("toc", *this).showDialog(cmd.view()); - return DispatchResult(true, true); - case LFUN_INSET_DIALOG_SHOW: InsetCommandMailer("toc", *this).showDialog(cmd.view()); return DispatchResult(true, true); Index: insets/updatableinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.C,v retrieving revision 1.36 diff -u -p -r1.36 updatableinset.C --- insets/updatableinset.C 10 Nov 2003 13:23:14 -0000 1.36 +++ insets/updatableinset.C 10 Nov 2003 15:27:53 -0000 @@ -47,37 +47,37 @@ void UpdatableInset::scroll(BufferView * } int const workW = bv->workWidth(); - int const tmp_top_x = top_x - scx; + int const tmp_xo_ = xo_ - scx; - if (tmp_top_x > 0 && tmp_top_x + width() < workW) + if (tmp_xo_ > 0 && tmp_xo_ + width() < workW) return; - if (s > 0 && top_x > 0) + if (s > 0 && xo_ > 0) return; scx = int(s * workW / 2); #warning metrics? - if (tmp_top_x + scx + width() < workW / 2) - scx = workW / 2 - tmp_top_x - width(); + if (tmp_xo_ + scx + width() < workW / 2) + scx = workW / 2 - tmp_xo_ - width(); } void UpdatableInset::scroll(BufferView * bv, int offset) const { if (offset > 0) { - if (!scx && top_x >= 20) + if (!scx && xo_ >= 20) return; - if (top_x + offset > 20) + if (xo_ + offset > 20) scx = 0; - // scx = - top_x; + // scx = - xo_; else scx += offset; } else { #warning metrics? - if (!scx && top_x + width() < bv->workWidth() - 20) + if (!scx && xo_ + width() < bv->workWidth() - 20) return; - if (top_x - scx + offset + width() < bv->workWidth() - 20) { - scx += bv->workWidth() - width() - top_x - 20; + if (xo_ - scx + offset + width() < bv->workWidth() - 20) { + scx += bv->workWidth() - width() - xo_ - 20; } else { scx += offset; } Index: mathed/formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.307 diff -u -p -r1.307 formula.C --- mathed/formula.C 10 Nov 2003 09:06:47 -0000 1.307 +++ mathed/formula.C 10 Nov 2003 15:27:53 -0000 @@ -195,6 +195,9 @@ bool editing_inset(InsetFormula const * void InsetFormula::draw(PainterInfo & pi, int x, int y) const { + xo_ = x; + yo_ = y; + // The previews are drawn only when we're not editing the inset. bool const use_preview = !editing_inset(this) && RenderPreview::activated() @@ -224,13 +227,6 @@ void InsetFormula::draw(PainterInfo & pi par_->draw(p, x, y); } - - xo_ = x; - yo_ = y; - - top_x = x; - top_baseline = y; - } Index: mathed/formulabase.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v retrieving revision 1.309 diff -u -p -r1.309 formulabase.C --- mathed/formulabase.C 10 Nov 2003 13:23:14 -0000 1.309 +++ mathed/formulabase.C 10 Nov 2003 15:27:53 -0000 @@ -78,7 +78,6 @@ bool openNewInset(BufferView * bv, Updat InsetFormulaBase::InsetFormulaBase() - : xo_(0), yo_(0) { // This is needed as long the math parser is not re-entrant initMath(); @@ -173,12 +172,10 @@ void InsetFormulaBase::getCursor(BufferV void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const { - // calling metrics here destroys the cached xo,yo positions e.g. in - // MathParboxinset. And it would be too expensive anyway... - //metrics(bv); if (!mathcursor) { lyxerr << "getCursorPos - should not happen"; - x = y = 0; + x = 0; + y = 0; return; } mathcursor->getPos(x, y); Index: mathed/formulabase.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.h,v retrieving revision 1.84 diff -u -p -r1.84 formulabase.h --- mathed/formulabase.h 4 Nov 2003 12:36:59 -0000 1.84 +++ mathed/formulabase.h 10 Nov 2003 15:27:53 -0000 @@ -116,11 +116,6 @@ protected: void handleFont(BufferView * bv, std::string const & arg, std::string const & font); /// void handleFont2(BufferView * bv, std::string const & arg); - - /// - mutable int xo_; - /// - mutable int yo_; }; // We don't really mess want around with mathed stuff outside mathed.