From 7150b0caa381ed6872d0b6090a1057861cacfa50 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Mon, 24 Dec 2007 10:52:58 +0000 Subject: [PATCH] * moved atom_dim_ to coord cache in the buffer view to make it dependent on the buffer view git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22290 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathBig.cpp | 2 -- src/mathed/InsetMathBoldSymbol.cpp | 2 -- src/mathed/InsetMathBox.cpp | 10 ---------- src/mathed/InsetMathBrace.cpp | 2 -- src/mathed/InsetMathChar.cpp | 2 -- src/mathed/InsetMathColor.cpp | 2 -- src/mathed/InsetMathComment.cpp | 2 -- src/mathed/InsetMathDecoration.cpp | 2 -- src/mathed/InsetMathDelim.cpp | 2 -- src/mathed/InsetMathDots.cpp | 2 -- src/mathed/InsetMathEnv.cpp | 2 -- src/mathed/InsetMathExFunc.cpp | 2 -- src/mathed/InsetMathFont.cpp | 2 -- src/mathed/InsetMathFontOld.cpp | 2 -- src/mathed/InsetMathFrac.cpp | 18 +++--------------- src/mathed/InsetMathGrid.cpp | 2 +- src/mathed/InsetMathLefteqn.cpp | 2 -- src/mathed/InsetMathNest.cpp | 8 ++++---- src/mathed/InsetMathOverset.cpp | 2 -- src/mathed/InsetMathPhantom.cpp | 2 -- src/mathed/InsetMathRoot.cpp | 2 -- src/mathed/InsetMathScript.cpp | 2 -- src/mathed/InsetMathSize.cpp | 2 -- src/mathed/InsetMathSqrt.cpp | 2 -- src/mathed/InsetMathStackrel.cpp | 2 -- src/mathed/InsetMathSymbol.cpp | 3 --- src/mathed/InsetMathUnderset.cpp | 4 +--- src/mathed/InsetMathXArrow.cpp | 2 -- src/mathed/MathData.cpp | 27 +++++++++++++++------------ src/mathed/MathData.h | 10 ++++------ src/mathed/MathMacroTemplate.cpp | 3 --- 31 files changed, 28 insertions(+), 101 deletions(-) diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp index 692d35d262..c547a7bb97 100644 --- a/src/mathed/InsetMathBig.cpp +++ b/src/mathed/InsetMathBig.cpp @@ -69,8 +69,6 @@ void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = 6; dim.asc = int(h + f * h); dim.des = int(f * h); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathBoldSymbol.cpp b/src/mathed/InsetMathBoldSymbol.cpp index 6ef4de7099..45ed5355ef 100644 --- a/src/mathed/InsetMathBoldSymbol.cpp +++ b/src/mathed/InsetMathBoldSymbol.cpp @@ -38,8 +38,6 @@ void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const cell(0).metrics(mi, dim); metricsMarkers(dim); ++dim.wid; // for 'double stroke' - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index 013e35bd93..641f50e370 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -56,8 +56,6 @@ void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const FontSetChanger dummy(mi.base, "textnormal"); cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -93,8 +91,6 @@ void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const FontSetChanger dummy(mi.base, "textnormal"); cell(0).metrics(mi, dim); metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -148,8 +144,6 @@ void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const dim += cell(1).dimension(*mi.base.bv); dim += cell(2).dimension(*mi.base.bv); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -213,8 +207,6 @@ void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -274,8 +266,6 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const dim += cell(2).dimension(*mi.base.bv); dim.wid += 4 * w_ + 4; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp index fa50c461e2..d5b6da44dc 100644 --- a/src/mathed/InsetMathBrace.cpp +++ b/src/mathed/InsetMathBrace.cpp @@ -53,8 +53,6 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = max(dim0.des, t.des); dim.wid = dim0.width() + 2 * t.wid; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 02013d9013..8c8f1ef141 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -84,8 +84,6 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid += 2 * theFontMetrics(font_).width(' '); lyxerr << "InsetMathChar::metrics: " << dim << endl; #endif - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathColor.cpp b/src/mathed/InsetMathColor.cpp index 9246f3d459..f5854f3712 100644 --- a/src/mathed/InsetMathColor.cpp +++ b/src/mathed/InsetMathColor.cpp @@ -45,8 +45,6 @@ void InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathComment.cpp b/src/mathed/InsetMathComment.cpp index b856ffc240..5bf046d08e 100644 --- a/src/mathed/InsetMathComment.cpp +++ b/src/mathed/InsetMathComment.cpp @@ -44,8 +44,6 @@ void InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index ecf5f58c2b..3878da7f8c 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -119,8 +119,6 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const } metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp index 5c732751a6..403c1cf65d 100644 --- a/src/mathed/InsetMathDelim.cpp +++ b/src/mathed/InsetMathDelim.cpp @@ -87,8 +87,6 @@ void InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = dim0.width() + 2 * dw_ + 8; dim.asc = max(a0, d0) + h0; dim.des = max(a0, d0) - h0; - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp index 7bbfa0b3e0..6e54907653 100644 --- a/src/mathed/InsetMathDots.cpp +++ b/src/mathed/InsetMathDots.cpp @@ -49,8 +49,6 @@ void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const } else if (key_->name == "ddots") dh_ = dim.asc; - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathEnv.cpp b/src/mathed/InsetMathEnv.cpp index adbca074e8..82460b986c 100644 --- a/src/mathed/InsetMathEnv.cpp +++ b/src/mathed/InsetMathEnv.cpp @@ -36,8 +36,6 @@ void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathExFunc.cpp b/src/mathed/InsetMathExFunc.cpp index 7b03387ba3..9a871f49d4 100644 --- a/src/mathed/InsetMathExFunc.cpp +++ b/src/mathed/InsetMathExFunc.cpp @@ -45,8 +45,6 @@ Inset * InsetMathExFunc::clone() const void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const { mathed_string_dim(mi.base.font, name_, dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp index 33f65751ad..2d73d64710 100644 --- a/src/mathed/InsetMathFont.cpp +++ b/src/mathed/InsetMathFont.cpp @@ -49,8 +49,6 @@ void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const FontSetChanger dummy(mi.base, key_->name); cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathFontOld.cpp b/src/mathed/InsetMathFontOld.cpp index c46defe897..fda63bdba4 100644 --- a/src/mathed/InsetMathFontOld.cpp +++ b/src/mathed/InsetMathFontOld.cpp @@ -40,8 +40,6 @@ void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const FontSetChanger dummy(mi.base, key_->name.c_str()); cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index ff0596250a..915169becc 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -45,7 +45,7 @@ bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const if (cur.idx() == target) return false; cur.idx() = target; - cur.pos() = cell(target).x2pos(cur.x_target()); + cur.pos() = cell(target).x2pos(&cur.bv(), cur.x_target()); return true; } @@ -94,7 +94,7 @@ bool InsetMathFrac::idxForward(Cursor & cur) const if (cur.idx() == target) return false; cur.idx() = target; - cur.pos() = cell(target).x2pos(cur.x_target()); + cur.pos() = cell(target).x2pos(&cur.bv(), cur.x_target()); return true; } @@ -112,7 +112,7 @@ bool InsetMathFrac::idxBackward(Cursor & cur) const if (cur.idx() == target) return false; cur.idx() = target; - cur.pos() = cell(target).x2pos(cur.x_target()); + cur.pos() = cell(target).x2pos(&cur.bv(), cur.x_target()); return true; } @@ -168,8 +168,6 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const } } metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -373,8 +371,6 @@ void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = max(dim0.wid, dim1.wid) + 2; dim.asc = dim0.height() + 2 + 5; dim.des = dim1.height() + 2 - 5; - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -433,8 +429,6 @@ void InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = max(dim0.width(), dim1.width()) + 2; dim.asc = dim0.height() + 2 + 5; dim.des = dim1.height() + 2 - 5; - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -510,8 +504,6 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = dim1.height() + 4 - 5; dim.wid = max(dim0.width(), dim1.wid) + 2 * dw(dim.height()) + 4; metricsMarkers2(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -584,8 +576,6 @@ void InsetMathDBinom::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = dim1.height() + 4 - 5; dim.wid = max(dim0.width(), dim1.wid) + 2 * dw(dim.height()) + 4; metricsMarkers2(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -654,8 +644,6 @@ void InsetMathTBinom::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = dim1.height() + 4 - 5; dim.wid = max(dim0.width(), dim1.wid) + 2 * dw(dim.height()) + 4; metricsMarkers2(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index cc542399c2..214ca7e9fa 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -813,7 +813,7 @@ bool InsetMathGrid::idxUpDown(Cursor & cur, bool up) const return false; cur.idx() += ncols(); } - cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo(cur.bv())); + cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target() - cur.cell().xo(cur.bv())); return true; } diff --git a/src/mathed/InsetMathLefteqn.cpp b/src/mathed/InsetMathLefteqn.cpp index dffa982b9a..f66c815179 100644 --- a/src/mathed/InsetMathLefteqn.cpp +++ b/src/mathed/InsetMathLefteqn.cpp @@ -35,8 +35,6 @@ void InsetMathLefteqn::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += 2; dim.wid = 4; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 00d4e2ac6e..77c3c8215d 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -131,7 +131,7 @@ void InsetMathNest::cursorPos(BufferView const & bv, Point const pt2 = coord_cache.getInsets().xy(this); //lyxerr << "retrieving position cache for MathData " // << pt.x_ << ' ' << pt.y_ << endl; - x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos()); + x = pt.x_ - pt2.x_ + ar.pos2x(&bv, sl.pos()); y = pt.y_ - pt2.y_; // lyxerr << "pt.y_ : " << pt.y_ << " pt2_.y_ : " << pt2.y_ // << " asc: " << ascent() << " des: " << descent() @@ -257,9 +257,9 @@ void InsetMathNest::drawSelection(PainterInfo & pi, int x, int y) const if (s1.idx() == s2.idx()) { MathData const & c = cell(s1.idx()); Geometry const & g = bv.coordCache().getArrays().geometry(&c); - int x1 = g.pos.x_ + c.pos2x(s1.pos()); + int x1 = g.pos.x_ + c.pos2x(pi.base.bv, s1.pos()); int y1 = g.pos.y_ - g.dim.ascent(); - int x2 = g.pos.x_ + c.pos2x(s2.pos()); + int x2 = g.pos.x_ + c.pos2x(pi.base.bv, s2.pos()); int y2 = g.pos.y_ + g.dim.descent(); pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, Color_selection); //lyxerr << "InsetMathNest::drawing selection 3: " @@ -1231,7 +1231,7 @@ Inset * InsetMathNest::editXY(Cursor & cur, int x, int y) MathData & ar = cell(idx_min); cur.push(*this); cur.idx() = idx_min; - cur.pos() = ar.x2pos(x - ar.xo(cur.bv())); + cur.pos() = ar.x2pos(&cur.bv(), x - ar.xo(cur.bv())); //lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl; if (dist_min == 0) { diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp index bd56bff79f..62a82427cd 100644 --- a/src/mathed/InsetMathOverset.cpp +++ b/src/mathed/InsetMathOverset.cpp @@ -38,8 +38,6 @@ void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = dim1.asc + dim0.height() + 4; dim.des = dim1.des; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathPhantom.cpp b/src/mathed/InsetMathPhantom.cpp index 0000175ad0..079098094a 100644 --- a/src/mathed/InsetMathPhantom.cpp +++ b/src/mathed/InsetMathPhantom.cpp @@ -36,8 +36,6 @@ void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp index 0017e1c954..f9424ed4ed 100644 --- a/src/mathed/InsetMathRoot.cpp +++ b/src/mathed/InsetMathRoot.cpp @@ -43,8 +43,6 @@ void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = max(dim0.descent() - 5, dim1.descent()) + 2; dim.wid = dim0.width() + dim1.width() + 10; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index a8142612cd..3fd94d11d8 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -340,8 +340,6 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const } else dim.des = nd; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathSize.cpp b/src/mathed/InsetMathSize.cpp index 42f13d858d..c014d90adf 100644 --- a/src/mathed/InsetMathSize.cpp +++ b/src/mathed/InsetMathSize.cpp @@ -39,8 +39,6 @@ void InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const StyleChanger dummy(mi.base, style_); cell(0).metrics(mi, dim); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathSqrt.cpp b/src/mathed/InsetMathSqrt.cpp index 23ded20156..941ad92b92 100644 --- a/src/mathed/InsetMathSqrt.cpp +++ b/src/mathed/InsetMathSqrt.cpp @@ -37,8 +37,6 @@ void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += 2; dim.wid += 12; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp index 1618de2cc1..2879659e1e 100644 --- a/src/mathed/InsetMathStackrel.cpp +++ b/src/mathed/InsetMathStackrel.cpp @@ -39,8 +39,6 @@ void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = dim1.ascent() + dim0.height() + 4; dim.des = dim1.descent(); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index 33a22f9b28..52d6eee858 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -82,9 +82,6 @@ void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const if (sym_->inset == "cmex" || sym_->inset == "esint" || sym_->extra == "funclim") scriptable_ = true; - - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp index d34260451e..a66a225af2 100644 --- a/src/mathed/InsetMathUnderset.cpp +++ b/src/mathed/InsetMathUnderset.cpp @@ -38,8 +38,6 @@ void InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = dim1.ascent(); dim.des = dim1.descent() + dim0.height() + 4; metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -79,7 +77,7 @@ bool InsetMathUnderset::idxUpDown(Cursor & cur, bool up) const if (cur.idx() == target) return false; cur.idx() = target; - cur.pos() = cur.cell().x2pos(cur.x_target()); + cur.pos() = cur.cell().x2pos(&cur.bv(), cur.x_target()); return true; } diff --git a/src/mathed/InsetMathXArrow.cpp b/src/mathed/InsetMathXArrow.cpp index 407b5f5d56..3faee295f3 100644 --- a/src/mathed/InsetMathXArrow.cpp +++ b/src/mathed/InsetMathXArrow.cpp @@ -45,8 +45,6 @@ void InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = dim0.height() + 10; dim.des = dim1.height(); metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); } diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index e579ece41e..114f5b7622 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -253,11 +253,11 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = 0; dim.wid = 0; Dimension d; - atom_dims_.clear(); + CoordCacheBase & coords = mi.base.bv->coordCache().insets(); for (size_t i = 0, n = size(); i != n; ++i) { MathAtom const & at = operator[](i); at->metrics(mi, d); - atom_dims_.push_back(d); + coords.add(at.nucleus(), d); dim += d; if (i == n - 1) kerning_ = at->kerning(mi.base.bv); @@ -287,12 +287,13 @@ void MathData::draw(PainterInfo & pi, int x, int y) const || x >= bv. workWidth()) return; + CoordCacheBase & coords = pi.base.bv->coordCache().insets(); for (size_t i = 0, n = size(); i != n; ++i) { MathAtom const & at = operator[](i); - bv.coordCache().insets().add(at.nucleus(), x, y); + coords.add(at.nucleus(), x, y); at->drawSelection(pi, x, y); at->draw(pi, x, y); - x += atom_dims_[i].wid; + x += coords.dim(at.nucleus()).wid; } } @@ -733,45 +734,47 @@ void MathData::collectParameters(Cursor * cur, } -int MathData::pos2x(size_type pos) const +int MathData::pos2x(BufferView const * bv, size_type pos) const { - return pos2x(pos, 0); + return pos2x(bv, pos, 0); } -int MathData::pos2x(size_type pos, int glue) const +int MathData::pos2x(BufferView const * bv, size_type pos, int glue) const { int x = 0; size_type target = min(pos, size()); + CoordCacheBase const & coords = bv->coordCache().getInsets(); for (size_type i = 0; i < target; ++i) { const_iterator it = begin() + i; if ((*it)->getChar() == ' ') x += glue; //lyxerr << "char: " << (*it)->getChar() // << "width: " << (*it)->width() << endl; - x += atom_dims_[i].wid; + x += coords.dim((*it).nucleus()).wid; } return x; } -MathData::size_type MathData::x2pos(int targetx) const +MathData::size_type MathData::x2pos(BufferView const * bv, int targetx) const { - return x2pos(targetx, 0); + return x2pos(bv, targetx, 0); } -MathData::size_type MathData::x2pos(int targetx, int glue) const +MathData::size_type MathData::x2pos(BufferView const * bv, int targetx, int glue) const { const_iterator it = begin(); int lastx = 0; int currx = 0; + CoordCacheBase const & coords = bv->coordCache().getInsets(); // find first position after targetx for (; currx < targetx && it < end(); ++it) { lastx = currx; if ((*it)->getChar() == ' ') currx += glue; - currx += atom_dims_[it - begin()].wid; + currx += coords.dim((*it).nucleus()).wid; } /** diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h index c0388aa671..2e1b12cfcc 100644 --- a/src/mathed/MathData.h +++ b/src/mathed/MathData.h @@ -132,13 +132,13 @@ public: /// write access to coordinate; void setXY(BufferView & bv, int x, int y) const; /// returns x coordinate of given position in the array - int pos2x(size_type pos) const; + int pos2x(BufferView const * bv, size_type pos) const; /// returns position of given x coordinate - int pos2x(size_type pos, int glue) const; + int pos2x(BufferView const * bv, size_type pos, int glue) const; /// returns position of given x coordinate - size_type x2pos(int pos) const; + size_type x2pos(BufferView const * bv, int pos) const; /// returns position of given x coordinate fstarting from a certain pos - size_type x2pos(int targetx, int glue) const; + size_type x2pos(BufferView const * bv, int targetx, int glue) const; /// returns distance of this cell to the point given by x and y // assumes valid position and size cache int dist(BufferView const & bv, int x, int y) const; @@ -187,8 +187,6 @@ private: const size_type numParams, std::vector & params, size_t & pos, MathAtom & scriptToPutAround, const pos_type macroPos, const int thisPos, const int thisSlice); - /// - mutable std::vector atom_dims_; }; /// diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index 68926d47ae..f1d8e439e5 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -137,8 +137,6 @@ void InsetLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const if (!parent_.premetrics()) dim.des += maxasc + maxdes + 1; } - - setDimCache(mi, dim); } @@ -221,7 +219,6 @@ void DisplayLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = 0; dim.asc = 0; dim.des = 0; - setDimCache(mi, dim); } } -- 2.39.2