From 9ac321f28f4c2ea805d8f5db2555e406f144399c Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sat, 22 Dec 2007 14:39:22 +0000 Subject: [PATCH] * kerning may depend on the BufferView because the metrics of some insets (e.g. math macros) depend on the cursor position in the view git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22259 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMath.h | 2 +- src/mathed/InsetMathChar.h | 2 +- src/mathed/InsetMathFont.h | 2 +- src/mathed/InsetMathFontOld.h | 2 +- src/mathed/InsetMathScript.cpp | 8 ++++---- src/mathed/InsetMathScript.h | 2 +- src/mathed/InsetMathSymbol.h | 2 +- src/mathed/InsetMathUnknown.h | 2 +- src/mathed/MathData.cpp | 2 +- src/mathed/MathData.h | 2 +- src/mathed/MathMacro.cpp | 8 ++++---- src/mathed/MathMacro.h | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index af6f35a629..d805fd36e3 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -199,7 +199,7 @@ public: virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; } /// superscript kerning - virtual int kerning() const { return 0; } + virtual int kerning(BufferView const * bv) const { return 0; } }; /// diff --git a/src/mathed/InsetMathChar.h b/src/mathed/InsetMathChar.h index dc0bc379b1..1ff946bfd6 100644 --- a/src/mathed/InsetMathChar.h +++ b/src/mathed/InsetMathChar.h @@ -30,7 +30,7 @@ public: /// void drawT(TextPainter &, int x, int y) const; /// - int kerning() const { return kerning_; } + int kerning(BufferView const * bv) const { return kerning_; } /// void write(WriteStream & os) const; diff --git a/src/mathed/InsetMathFont.h b/src/mathed/InsetMathFont.h index 98b36e6bd9..a55c1f77b1 100644 --- a/src/mathed/InsetMathFont.h +++ b/src/mathed/InsetMathFont.h @@ -46,7 +46,7 @@ public: /// void infoize(odocstream & os) const; /// - int kerning() const { return cell(0).kerning(); } + int kerning(BufferView const * bv) const { return cell(0).kerning(bv); } private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathFontOld.h b/src/mathed/InsetMathFontOld.h index 22da1ea208..10ef8305e0 100644 --- a/src/mathed/InsetMathFontOld.h +++ b/src/mathed/InsetMathFontOld.h @@ -44,7 +44,7 @@ public: /// void infoize(odocstream & os) const; /// - int kerning() const { return cell(0).kerning(); } + int kerning(BufferView const * bv) const { return cell(0).kerning(bv); } private: virtual Inset * clone() const; diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index a6d81617d7..a8142612cd 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -253,7 +253,7 @@ int InsetMathScript::dx1(BufferView const & bv) const { BOOST_ASSERT(hasUp()); Dimension const dim = dimension(bv); - return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(); + return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(&bv); } @@ -282,10 +282,10 @@ int InsetMathScript::ndes(BufferView const & bv) const } -int InsetMathScript::nker() const +int InsetMathScript::nker(BufferView const * bv) const { if (nuc().size()) { - int kerning = nuc().kerning(); + int kerning = nuc().kerning(bv); return kerning > 0 ? kerning : 0; } return 0; @@ -322,7 +322,7 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = max(dim.wid, dimdown.width()); } else { if (hasUp()) - dim.wid = max(dim.wid, nker() + dimup.width()); + dim.wid = max(dim.wid, nker(mi.base.bv) + dimup.width()); if (hasDown()) dim.wid = max(dim.wid, dimdown.width()); dim.wid += nwid(bv); diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index e26e73824a..e851e2b371 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -125,7 +125,7 @@ private: /// returns descent of nucleus if any int ndes(BufferView const &) const; /// returns superscript kerning of nucleus if any - int nker() const; + int nker(BufferView const * bv) const; /// where do we have to draw the scripts? bool hasLimits() const; /// clean up empty cells and return true if a cell has been deleted. diff --git a/src/mathed/InsetMathSymbol.h b/src/mathed/InsetMathSymbol.h index 5d5d7f3c37..d9b26edcfe 100644 --- a/src/mathed/InsetMathSymbol.h +++ b/src/mathed/InsetMathSymbol.h @@ -35,7 +35,7 @@ public: /// void draw(PainterInfo &, int x, int y) const; /// - int kerning() const { return kerning_; } + int kerning(BufferView const * bv) const { return kerning_; } /// bool isRelOp() const; diff --git a/src/mathed/InsetMathUnknown.h b/src/mathed/InsetMathUnknown.h index eddc808c63..00eb81f0e6 100644 --- a/src/mathed/InsetMathUnknown.h +++ b/src/mathed/InsetMathUnknown.h @@ -52,7 +52,7 @@ public: /// bool final() const; /// - int kerning() const { return kerning_; } + int kerning(BufferView const * bv) const { return kerning_; } private: virtual Inset * clone() const; /// diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index 1d40598dff..e579ece41e 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -260,7 +260,7 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const atom_dims_.push_back(d); dim += d; if (i == n - 1) - kerning_ = at->kerning(); + kerning_ = at->kerning(mi.base.bv); } // Cache the dimension. mi.base.bv->coordCache().arrays().add(this, dim); diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h index 1ddf623685..c0388aa671 100644 --- a/src/mathed/MathData.h +++ b/src/mathed/MathData.h @@ -152,7 +152,7 @@ public: /// additional super/subscript shift int sshift() const { return sshift_; } /// superscript kerning - int kerning() const { return kerning_; } + int kerning(BufferView const * bv) const { return kerning_; } /// void swap(MathData & ar) { base_type::swap(ar); } diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 5ad9366aed..9468bc10a9 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -82,7 +82,7 @@ public: /// size_t idx() const { return idx_; } /// - int kerning() const { return mathMacro_.cell(idx_).kerning(); } + int kerning(BufferView const * bv) const { return mathMacro_.cell(idx_).kerning(bv); } private: /// @@ -204,9 +204,9 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const } -int MathMacro::kerning() const { - if (displayMode_ == DISPLAY_NORMAL) - return expanded_.kerning(); +int MathMacro::kerning(BufferView const * bv) const { + if (displayMode_ == DISPLAY_NORMAL && !editing(bv)) + return expanded_.kerning(bv); else return 0; } diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h index b8c91f4d0a..54ca2de8c6 100644 --- a/src/mathed/MathMacro.h +++ b/src/mathed/MathMacro.h @@ -41,7 +41,7 @@ public: /// void metrics(MetricsInfo & mi, Dimension & dim) const; /// - int kerning() const; + int kerning(BufferView const * bv) const; /// get cursor position void cursorPos(BufferView const & bv, CursorSlice const & sl, bool boundary, int & x, int & y) const; -- 2.39.2