diff --git a/src/dimension.h b/src/dimension.h index 4e803682d3..bf42106de0 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -25,6 +25,12 @@ public: /// initialize data Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {} + Dimension & operator=(Dimension const & dim) { + wid = dim.wid; + asc = dim.asc; + des = dim.des; + return *this; + } /// glue horizontally void operator+=(Dimension const & dim); /// set to empty box @@ -66,7 +72,14 @@ public: inline bool operator==(Dimension const & a, Dimension const & b) { - return a.wid == b.wid && a.asc == b.asc && a.des ==b.des ; + return a.wid == b.wid && a.asc == b.asc && a.des == b.des ; +} + + +inline +bool operator!=(Dimension const & a, Dimension const & b) +{ + return a.wid != b.wid || a.asc != b.asc || a.des != b.des ; } diff --git a/src/insets/inset.h b/src/insets/inset.h index 7832a32017..a6f6a05a1b 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -56,8 +56,6 @@ public: protected: /// InsetOld(InsetOld const & in); - /// - mutable Dimension dim_; private: InsetOld & operator=(InsetOld const &) const; diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index b69bbbde01..f0aa1d4903 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -12,9 +12,10 @@ #ifndef INSETBASE_H #define INSETBASE_H -#include "support/docstream.h" - #include "changes.h" +#include "dimension.h" + +#include "support/docstream.h" #include #include @@ -103,7 +104,8 @@ public: virtual InsetBase * editXY(LCursor & cur, int x, int y); /// compute the size of the object returned in dim - virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; + /// \retval true if metrics changed. + virtual bool metrics(MetricsInfo & mi, Dimension & dim) const = 0; /// draw inset and update (xo, yo)-cache virtual void draw(PainterInfo & pi, int x, int y) const = 0; /// draw inset selection if necessary @@ -443,6 +445,9 @@ protected: * \sa getStatus */ virtual void doDispatch(LCursor & cur, FuncRequest & cmd); + + /// Cached dimensions of the inset. + mutable Dimension dim_; private: virtual std::auto_ptr doClone() const = 0; }; diff --git a/src/insets/insetbox.C b/src/insets/insetbox.C index c26131e21e..e5be700ae4 100644 --- a/src/insets/insetbox.C +++ b/src/insets/insetbox.C @@ -169,13 +169,15 @@ void InsetBox::setButtonLabel() } -void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const +bool InsetBox::metrics(MetricsInfo & m, Dimension & dim) const { MetricsInfo mi = m; if (params_.inner_box || params_.special != "width") mi.base.textwidth = params_.width.inPixels(m.base.textwidth); InsetCollapsable::metrics(mi, dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetbox.h b/src/insets/insetbox.h index 00a69ca455..55ad9237dc 100644 --- a/src/insets/insetbox.h +++ b/src/insets/insetbox.h @@ -72,7 +72,7 @@ public: /// void setButtonLabel(); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// show the Box dialog bool showInsetDialog(BufferView * bv) const; /// diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 482642f94a..ff747d6954 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -119,7 +119,7 @@ void InsetCaption::setLabel(LCursor & cur) const } -void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const { mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET; LCursor cur = mi.base.bv->cursor(); @@ -135,7 +135,9 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += TEXT_TO_INSET_OFFSET; dim.wid += 2 * TEXT_TO_INSET_OFFSET; mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetcaption.h b/src/insets/insetcaption.h index d60718c128..310b0e0fd1 100644 --- a/src/insets/insetcaption.h +++ b/src/insets/insetcaption.h @@ -43,7 +43,7 @@ public: /// bool descendable() const { return true; } /// - virtual void metrics(MetricsInfo & mi, Dimension & dim) const; + virtual bool metrics(MetricsInfo & mi, Dimension & dim) const; /// virtual void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 6d953726c8..3778ffda97 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -139,7 +139,7 @@ void InsetCharStyle::read(Buffer const & buf, LyXLex & lex) } -void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; getDrawFont(mi.base.font); @@ -168,9 +168,11 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += TEXT_TO_INSET_OFFSET; dim.wid += 2 * TEXT_TO_INSET_OFFSET; mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET; - dim_ = dim; if (params_.show_label) - dim_.des += ascent(); + dim.des += ascent(); + bool const changed = dim_ != dim; + dim_ = dim; + return changed; } diff --git a/src/insets/insetcharstyle.h b/src/insets/insetcharstyle.h index 404e44ad40..34b910472f 100644 --- a/src/insets/insetcharstyle.h +++ b/src/insets/insetcharstyle.h @@ -68,7 +68,7 @@ public: /// void read(Buffer const & buf, LyXLex & lex); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo &, int, int) const; /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 3d4434aa79..a2502a0dae 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -132,7 +132,7 @@ Dimension InsetCollapsable::dimensionCollapsed() const } -void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const { autoOpen_ = mi.base.bv->cursor().isInside(this); mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET; @@ -162,7 +162,9 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += TEXT_TO_INSET_OFFSET; dim.wid += 2 * TEXT_TO_INSET_OFFSET; mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 539d1c78c9..82bae54483 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -46,7 +46,7 @@ public: /// void write(Buffer const &, std::ostream &) const; /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 7fdedd2c80..3a7d50aa02 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -46,7 +46,7 @@ InsetCommand::~InsetCommand() } -void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const { if (updateButtonLabel_) { updateButtonLabel_ = false; @@ -54,7 +54,9 @@ void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const editable() != NOT_EDITABLE); } button_.metrics(mi, dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 2b558aaeb4..c268f07e55 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -38,7 +38,7 @@ public: /// ~InsetCommand(); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index b1698f5fb5..15e936c5d2 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -397,14 +397,16 @@ bool InsetERT::insetAllowed(InsetBase::Code /* code */) const } -void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; getDrawFont(mi.base.font); mi.base.font.realize(tmpfont); InsetCollapsable::metrics(mi, dim); mi.base.font = tmpfont; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index cf573a1195..77f81aef22 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -63,7 +63,7 @@ public: /// void validate(LaTeXFeatures &) const {} /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 6726d9859e..d0b0f86fe2 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -482,10 +482,12 @@ void InsetExternal::edit(LCursor & cur, bool) } -void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const { renderer_->metrics(mi, dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 6f175d787c..2e33880a20 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -116,7 +116,7 @@ public: virtual EDITABLE editable() const { return IS_EDITABLE; } /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetfootlike.C b/src/insets/insetfootlike.C index c071c3cfbc..8aef1d25bd 100644 --- a/src/insets/insetfootlike.C +++ b/src/insets/insetfootlike.C @@ -44,13 +44,15 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in) } -void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; mi.base.font = mi.base.bv->buffer()->params().getFont(); InsetCollapsable::metrics(mi, dim); mi.base.font = tmpfont; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetfootlike.h b/src/insets/insetfootlike.h index 6615a4655f..09e24ba420 100644 --- a/src/insets/insetfootlike.h +++ b/src/insets/insetfootlike.h @@ -27,7 +27,7 @@ public: /// InsetFootlike(InsetFootlike const &); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index f5067fc64f..aaeb54e766 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -234,10 +234,12 @@ void InsetGraphics::edit(LCursor & cur, bool) } -void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const { graphic_->metrics(mi, dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 0d52776d8d..51ffe31ca2 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -35,7 +35,7 @@ public: /// ~InsetGraphics(); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// EDITABLE editable() const; /// diff --git a/src/insets/insethfill.C b/src/insets/insethfill.C index 25146edb54..1f20b3deab 100644 --- a/src/insets/insethfill.C +++ b/src/insets/insethfill.C @@ -32,12 +32,14 @@ std::auto_ptr InsetHFill::doClone() const } -void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const +bool InsetHFill::metrics(MetricsInfo &, Dimension & dim) const { dim.wid = 3; dim.asc = 3; dim.des = 3; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insethfill.h b/src/insets/insethfill.h index 3bfa98ffc3..51f5b59fa1 100644 --- a/src/insets/insethfill.h +++ b/src/insets/insethfill.h @@ -23,7 +23,7 @@ public: /// InsetHFill(); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// docstring const getScreenLabel(Buffer const &) const; /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index f395ec700a..f374afcba3 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -648,7 +648,7 @@ InsetInclude::getBibfilesCache(Buffer const & buffer) const } -void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const { BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer()); @@ -673,7 +673,9 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const Box b(0, dim.wid, -dim.asc, dim.des); button_.setBox(b); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 65eee42452..4610e0ea10 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -35,7 +35,7 @@ public: ~InsetInclude(); /// Override these InsetButton methods if Previewing - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 3634bff900..e566acda70 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -242,7 +242,7 @@ void InsetLatexAccent::checkContents() } -void InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont & font = mi.base.font; frontend::FontMetrics const & fm = theFontMetrics(font); @@ -273,7 +273,9 @@ void InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const docstring dcon(contents.begin(), contents.end()); dim.wid = fm.width(dcon) + 4; } + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index d09e221669..33446bd11a 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -36,7 +36,7 @@ public: /// explicit InsetLatexAccent(std::string const & str); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetline.C b/src/insets/insetline.C index 87f0de3d20..9aa4d63e31 100644 --- a/src/insets/insetline.C +++ b/src/insets/insetline.C @@ -42,12 +42,14 @@ void InsetLine::write(Buffer const &, ostream & os) const } -void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const { dim.asc = 3; dim.des = 3; dim.wid = mi.base.textwidth; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetline.h b/src/insets/insetline.h index 67df1d33fd..8e5f6a7d10 100644 --- a/src/insets/insetline.h +++ b/src/insets/insetline.h @@ -25,7 +25,7 @@ public: InsetBase::Code lyxCode() const { return InsetBase::LINE_CODE; } - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/insetnewline.C b/src/insets/insetnewline.C index c71d84eb28..302dda7769 100644 --- a/src/insets/insetnewline.C +++ b/src/insets/insetnewline.C @@ -41,13 +41,15 @@ void InsetNewline::write(Buffer const &, ostream & os) const } -void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const { frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); dim.asc = fm.maxAscent(); dim.des = fm.maxDescent(); dim.wid = fm.width('n'); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetnewline.h b/src/insets/insetnewline.h index 0a8353126d..aa6d2066dd 100644 --- a/src/insets/insetnewline.h +++ b/src/insets/insetnewline.h @@ -25,7 +25,7 @@ public: InsetBase::Code lyxCode() const { return InsetBase::NEWLINE_CODE; } - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; virtual void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/insetpagebreak.C b/src/insets/insetpagebreak.C index b82799d875..817c64d877 100644 --- a/src/insets/insetpagebreak.C +++ b/src/insets/insetpagebreak.C @@ -42,12 +42,14 @@ void InsetPagebreak::write(Buffer const &, ostream & os) const } -void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const { dim.asc = defaultRowHeight(); dim.des = defaultRowHeight(); dim.wid = mi.base.textwidth; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetpagebreak.h b/src/insets/insetpagebreak.h index b1def5c91a..57bb3b35f2 100644 --- a/src/insets/insetpagebreak.h +++ b/src/insets/insetpagebreak.h @@ -25,7 +25,7 @@ public: InsetBase::Code lyxCode() const { return InsetBase::LINE_CODE; } - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 46b9a99e05..ffbf0c4381 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -221,7 +221,7 @@ docstring const InsetQuotes::dispString(Language const * loclang) const } -void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont & font = mi.base.font; frontend::FontMetrics const & fm = @@ -239,7 +239,9 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const else dim.wid += fm.width(','); } + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 87e6a7b6b2..33a62e2f5c 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -74,7 +74,7 @@ public: /// Direct access to inner/outer quotation marks InsetQuotes(char_type c, quote_language l, quote_times t); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; #if 0 diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C index 72dcca13b2..e7fc211fe5 100644 --- a/src/insets/insetspace.C +++ b/src/insets/insetspace.C @@ -48,7 +48,7 @@ InsetSpace::Kind InsetSpace::kind() const } -void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); @@ -75,7 +75,9 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = 10; break; } + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetspace.h b/src/insets/insetspace.h index 02c88477e2..414e6e4171 100644 --- a/src/insets/insetspace.h +++ b/src/insets/insetspace.h @@ -56,7 +56,7 @@ public: /// Kind kind() const; /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index d22a51f90b..7ed1ea8489 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -42,7 +42,7 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const } -void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const { frontend::FontMetrics const & fm = theFontMetrics(mi.base.font); @@ -61,7 +61,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = fm.width(ds); if (kind_ == HYPHENATION && dim.wid > 5) dim.wid -= 2; // to make it look shorter + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index 9a31348d67..26ee9612bd 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -48,7 +48,7 @@ public: /// Kind kind() const; /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 4990ce2936..979706645a 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -246,7 +246,7 @@ void InsetTabular::read(Buffer const & buf, LyXLex & lex) } -void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const { //lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " << // mi.base.textwidth << "\n"; @@ -300,7 +300,9 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = tabular.getAscentOfRow(0); dim.des = tabular.getHeightOfTabular() - dim.asc; dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index a43e22e0bd..cb785f4b5e 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -60,7 +60,7 @@ public: /// void write(Buffer const &, std::ostream &) const; /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 0b843353a0..68067e44be 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -164,7 +164,7 @@ void InsetText::read(Buffer const & buf, LyXLex & lex) } -void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetText::metrics(MetricsInfo & mi, Dimension & dim) const { //lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl; mi.base.textwidth -= 2 * border_; @@ -176,7 +176,9 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const dim.des += border_; dim.wid += 2 * border_; mi.base.textwidth += 2 * border_; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 67128697d7..a2dd9f98a9 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -50,7 +50,7 @@ public: /// void write(Buffer const & buf, std::ostream & os) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// draw inset selection diff --git a/src/insets/insettheorem.C b/src/insets/insettheorem.C index a7b9e2018e..4273ffecf6 100644 --- a/src/insets/insettheorem.C +++ b/src/insets/insettheorem.C @@ -69,12 +69,14 @@ auto_ptr InsetTheorem::doClone() const return result; } -void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const { InsetCollapsable::metrics(mi, dim); center_indent_ = (mi.base.textwidth - dim.wid) / 2; dim.wid = mi.base.textwidth; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insettheorem.h b/src/insets/insettheorem.h index 9a217d527f..2e1d8d59b1 100644 --- a/src/insets/insettheorem.h +++ b/src/insets/insettheorem.h @@ -30,7 +30,7 @@ public: /// Inset::Code lyxCode() const { return Inset::THEOREM_CODE; } /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 64b9441d32..afb221aff2 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -116,7 +116,7 @@ int const arrow_size = 4; } -void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const { int height = 3 * arrow_size; if (space_.length().len().value() >= 0.0) @@ -136,7 +136,9 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = height / 2 + (a - d) / 2; // align cursor with the dim.des = height - dim.asc; // label text dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/insetvspace.h b/src/insets/insetvspace.h index 350748b3f0..eb3a409c55 100644 --- a/src/insets/insetvspace.h +++ b/src/insets/insetvspace.h @@ -29,7 +29,7 @@ public: /// ~InsetVSpace(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/insets/render_base.h b/src/insets/render_base.h index dbd7cec7f2..6a5dc57d3e 100644 --- a/src/insets/render_base.h +++ b/src/insets/render_base.h @@ -34,8 +34,9 @@ public: virtual std::auto_ptr clone(InsetBase const *) const = 0; - /// compute the size of the object returned in dim - virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; + /// compute the size of the object returned in dim. + /// \retval true if the metrics has changed. + virtual bool metrics(MetricsInfo & mi, Dimension & dim) const = 0; /// draw inset and update (xo, yo)-cache virtual void draw(PainterInfo & pi, int x, int y) const = 0; diff --git a/src/insets/render_button.C b/src/insets/render_button.C index 6a833c744b..87172ddbc6 100644 --- a/src/insets/render_button.C +++ b/src/insets/render_button.C @@ -43,7 +43,7 @@ void RenderButton::update(docstring const & text, bool editable) } -void RenderButton::metrics(MetricsInfo &, Dimension & dim) const +bool RenderButton::metrics(MetricsInfo &, Dimension & dim) const { LyXFont font(LyXFont::ALL_SANE); font.decSize(); @@ -56,6 +56,10 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const fm.rectText(text_, dim.wid, dim.asc, dim.des); dim.wid += 4; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/insets/render_button.h b/src/insets/render_button.h index fb4cfbf72f..244180431b 100644 --- a/src/insets/render_button.h +++ b/src/insets/render_button.h @@ -28,7 +28,7 @@ public: std::auto_ptr clone(InsetBase const *) const; /// compute the size of the object returned in dim - virtual void metrics(MetricsInfo & mi, Dimension & dim) const; + virtual bool metrics(MetricsInfo & mi, Dimension & dim) const; /// draw inset and update (xo, yo)-cache virtual void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/render_graphic.C b/src/insets/render_graphic.C index 9ab5697328..513b602d18 100644 --- a/src/insets/render_graphic.C +++ b/src/insets/render_graphic.C @@ -140,7 +140,7 @@ bool readyToDisplay(graphics::Loader const & loader) } // namespace anon -void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const +bool RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const { bool image_ready = displayGraphic(params_) && readyToDisplay(loader_); @@ -175,7 +175,9 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = std::max(50, font_width + 15); } + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/render_graphic.h b/src/insets/render_graphic.h index 498223521f..182e02f2d3 100644 --- a/src/insets/render_graphic.h +++ b/src/insets/render_graphic.h @@ -29,7 +29,7 @@ public: std::auto_ptr clone(InsetBase const *) const; /// compute the size of the object returned in dim - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// draw inset void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/render_preview.C b/src/insets/render_preview.C index f46110f138..5badea260d 100644 --- a/src/insets/render_preview.C +++ b/src/insets/render_preview.C @@ -113,7 +113,7 @@ RenderPreview::getPreviewImage(Buffer const & buffer) const } -void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const +bool RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const { BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer()); @@ -135,7 +135,9 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid = 15 + theFontMetrics(font).width(stat); } + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/insets/render_preview.h b/src/insets/render_preview.h index bc9942132b..52bb7ffe04 100644 --- a/src/insets/render_preview.h +++ b/src/insets/render_preview.h @@ -52,7 +52,7 @@ public: std::auto_ptr clone(InsetBase const *) const; /// Compute the size of the object, returned in dim - void metrics(MetricsInfo &, Dimension & dim) const; + bool metrics(MetricsInfo &, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/lyxtext.h b/src/lyxtext.h index db04130328..f88de27317 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -116,8 +116,8 @@ public: /// insert an inset at cursor position void insertInset(LCursor & cur, InsetBase * inset); - /// compute text metrics - void metrics(MetricsInfo & mi, Dimension & dim); + /// compute text metrics. + bool metrics(MetricsInfo & mi, Dimension & dim); /// draw text (only used for insets) void draw(PainterInfo & pi, int x, int y) const; /// draw textselection diff --git a/src/mathed/InsetFormulaMacro.C b/src/mathed/InsetFormulaMacro.C index 26cefd2f0e..fed292047b 100644 --- a/src/mathed/InsetFormulaMacro.C +++ b/src/mathed/InsetFormulaMacro.C @@ -124,14 +124,16 @@ string InsetFormulaMacro::prefix() const } -void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const { //lyxerr << "InsetFormulaMacro: " << this << " -- " << &tmpl() << endl; tmpl()->metrics(mi, dim); dim.asc += 5; dim.des += 5; dim.wid += 10 + theFontMetrics(mi.base.font).width(prefix()); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/mathed/InsetFormulaMacro.h b/src/mathed/InsetFormulaMacro.h index ad27ec2101..b32bd033c6 100644 --- a/src/mathed/InsetFormulaMacro.h +++ b/src/mathed/InsetFormulaMacro.h @@ -35,7 +35,7 @@ public: /// constructs a mocro from its LaTeX definition explicit InsetFormulaMacro(docstring const & s); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index 3cfc107e58..5aa419a098 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -84,7 +84,6 @@ class InfoStream; class MathMacroTemplate; class MathMacro; class MathPosFinder; -class Dimension; class LCursor; class TextPainter; class TextMetricsInfo; diff --git a/src/mathed/InsetMathAMSArray.C b/src/mathed/InsetMathAMSArray.C index 18b3502ed8..55eeb7f159 100644 --- a/src/mathed/InsetMathAMSArray.C +++ b/src/mathed/InsetMathAMSArray.C @@ -79,12 +79,14 @@ char const * InsetMathAMSArray::name_right() const } -void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const { ArrayChanger dummy(mi.base); InsetMathGrid::metrics(mi, dim); dim.wid += 14; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/mathed/InsetMathAMSArray.h b/src/mathed/InsetMathAMSArray.h index b5f7255b37..64bf75c5bd 100644 --- a/src/mathed/InsetMathAMSArray.h +++ b/src/mathed/InsetMathAMSArray.h @@ -25,7 +25,7 @@ public: /// InsetMathAMSArray(docstring const & name); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pain, int x, int y) const; /// diff --git a/src/mathed/InsetMathArray.C b/src/mathed/InsetMathArray.C index 83b94dcea6..54b1deaff6 100644 --- a/src/mathed/InsetMathArray.C +++ b/src/mathed/InsetMathArray.C @@ -80,12 +80,14 @@ auto_ptr InsetMathArray::doClone() const } -void InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const { ArrayChanger dummy(mi.base); InsetMathGrid::metrics(mi, dim); dim.wid += 6; + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/mathed/InsetMathArray.h b/src/mathed/InsetMathArray.h index b14f9b2e4e..0dd387dada 100644 --- a/src/mathed/InsetMathArray.h +++ b/src/mathed/InsetMathArray.h @@ -31,7 +31,7 @@ public: /// convenience constructor from whitespace/newline separated data InsetMathArray(docstring const &, docstring const & str); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathBig.C b/src/mathed/InsetMathBig.C index 49dbcd73c0..b0bcb7ebe6 100644 --- a/src/mathed/InsetMathBig.C +++ b/src/mathed/InsetMathBig.C @@ -62,14 +62,17 @@ double InsetMathBig::increase() const } -void InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBig::metrics(MetricsInfo & mi, Dimension & dim) const { double const h = theFontMetrics(mi.base.font).ascent('I'); double const f = increase(); - dim_.wid = 6; - dim_.asc = int(h + f * h); - dim_.des = int(f * h); - dim = dim_; + dim.wid = 6; + dim.asc = int(h + f * h); + dim.des = int(f * h); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathBig.h b/src/mathed/InsetMathBig.h index 336c376067..5a983d19e7 100644 --- a/src/mathed/InsetMathBig.h +++ b/src/mathed/InsetMathBig.h @@ -27,7 +27,7 @@ public: /// docstring name() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathBinom.C b/src/mathed/InsetMathBinom.C index 8597514000..564c21979d 100644 --- a/src/mathed/InsetMathBinom.C +++ b/src/mathed/InsetMathBinom.C @@ -45,7 +45,7 @@ int InsetMathBinom::dw() const } -void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const { ScriptChanger dummy(mi.base); cell(0).metrics(mi); @@ -54,7 +54,9 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = cell(1).height() + 4 - 5; dim.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4; metricsMarkers2(dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; } diff --git a/src/mathed/InsetMathBinom.h b/src/mathed/InsetMathBinom.h index aba5364a7f..80ed9473f6 100644 --- a/src/mathed/InsetMathBinom.h +++ b/src/mathed/InsetMathBinom.h @@ -28,7 +28,7 @@ public: /// void normalize(NormalStream &) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathBoldSymbol.C b/src/mathed/InsetMathBoldSymbol.C index 402648983d..989fac4d1a 100644 --- a/src/mathed/InsetMathBoldSymbol.C +++ b/src/mathed/InsetMathBoldSymbol.C @@ -33,13 +33,16 @@ auto_ptr InsetMathBoldSymbol::doClone() const } -void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const { //FontSetChanger dummy(mi.base, "mathbf"); cell(0).metrics(mi, dim); metricsMarkers(dim); ++dim.wid; // for 'double stroke' + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathBoldSymbol.h b/src/mathed/InsetMathBoldSymbol.h index cc50dae5e6..b9f7e78e5f 100644 --- a/src/mathed/InsetMathBoldSymbol.h +++ b/src/mathed/InsetMathBoldSymbol.h @@ -24,7 +24,7 @@ public: /// InsetMathBoldSymbol(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathBox.C b/src/mathed/InsetMathBox.C index cdae7fdd89..4e1bce9dc5 100644 --- a/src/mathed/InsetMathBox.C +++ b/src/mathed/InsetMathBox.C @@ -48,12 +48,15 @@ void InsetMathBox::normalize(NormalStream & os) const } -void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, "textnormal"); cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathBox.h b/src/mathed/InsetMathBox.h index 0591d29e0a..0bb2744d0a 100644 --- a/src/mathed/InsetMathBox.h +++ b/src/mathed/InsetMathBox.h @@ -31,7 +31,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathBoxed.C b/src/mathed/InsetMathBoxed.C index 0f8d830284..4e15ce4ffe 100644 --- a/src/mathed/InsetMathBoxed.C +++ b/src/mathed/InsetMathBoxed.C @@ -38,11 +38,14 @@ auto_ptr InsetMathBoxed::doClone() const } -void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathBoxed.h b/src/mathed/InsetMathBoxed.h index 2764b8aa6c..930c7b3aa0 100644 --- a/src/mathed/InsetMathBoxed.h +++ b/src/mathed/InsetMathBoxed.h @@ -26,7 +26,7 @@ public: /// void validate(LaTeXFeatures & features) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathBrace.C b/src/mathed/InsetMathBrace.C index 03c7c567db..736a47250a 100644 --- a/src/mathed/InsetMathBrace.C +++ b/src/mathed/InsetMathBrace.C @@ -43,7 +43,7 @@ auto_ptr InsetMathBrace::doClone() const } -void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi); Dimension t; @@ -52,7 +52,10 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = max(cell(0).descent(), t.des); dim.wid = cell(0).width() + 2 * t.wid; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathBrace.h b/src/mathed/InsetMathBrace.h index fd673f36fe..3d581dc023 100644 --- a/src/mathed/InsetMathBrace.h +++ b/src/mathed/InsetMathBrace.h @@ -30,7 +30,7 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathCases.C b/src/mathed/InsetMathCases.C index 46c09caa2c..d998c0e4e4 100644 --- a/src/mathed/InsetMathCases.C +++ b/src/mathed/InsetMathCases.C @@ -47,11 +47,16 @@ auto_ptr InsetMathCases::doClone() const } -void InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathCases::metrics(MetricsInfo & mi, Dimension & dim) const { + dim = dim_; InsetMathGrid::metrics(mi); dim_.wid += 8; + + if (dim_ == dim) + return false; dim = dim_; + return true; } diff --git a/src/mathed/InsetMathCases.h b/src/mathed/InsetMathCases.h index bae0cd7619..9f06cbdde8 100644 --- a/src/mathed/InsetMathCases.h +++ b/src/mathed/InsetMathCases.h @@ -25,7 +25,7 @@ public: /// explicit InsetMathCases(row_type rows = 1u); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathChar.C b/src/mathed/InsetMathChar.C index 18437ff6cf..aadcbc06cc 100644 --- a/src/mathed/InsetMathChar.C +++ b/src/mathed/InsetMathChar.C @@ -57,7 +57,7 @@ auto_ptr InsetMathChar::doClone() const } -void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const { #if 1 if (char_ == '=' && has_math_fonts) { @@ -79,12 +79,16 @@ void InsetMathChar::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid += static_cast(0.1667*em+0.5); #else whichFont(font_, code_, mi); - mathed_char_dim(font_, char_, dim_); + mathed_char_dim(font_, char_, dim); if (isBinaryOp(char_, code_)) width_ += 2 * theFontMetrics(font_).width(' '); lyxerr << "InsetMathChar::metrics: " << dim << endl; #endif width_ = dim.wid; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathChar.h b/src/mathed/InsetMathChar.h index 140c16829b..8ee4e9c5cc 100644 --- a/src/mathed/InsetMathChar.h +++ b/src/mathed/InsetMathChar.h @@ -23,7 +23,7 @@ public: /// explicit InsetMathChar(char_type c); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathColor.C b/src/mathed/InsetMathColor.C index 55d9c656cb..32d7c29881 100644 --- a/src/mathed/InsetMathColor.C +++ b/src/mathed/InsetMathColor.C @@ -41,11 +41,14 @@ auto_ptr InsetMathColor::doClone() const } -void InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathColor.h b/src/mathed/InsetMathColor.h index 71fada0473..5d23261a07 100644 --- a/src/mathed/InsetMathColor.h +++ b/src/mathed/InsetMathColor.h @@ -29,7 +29,7 @@ public: /// Create a color inset from LaTeX color name explicit InsetMathColor(bool oldstyle, docstring const & color); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// we write extra braces in any case... /// FIXME Why? Are they necessary if oldstyle_ == false? bool extraBraces() const { return true; } diff --git a/src/mathed/InsetMathCommand.C b/src/mathed/InsetMathCommand.C index 415c72b355..785017cc39 100644 --- a/src/mathed/InsetMathCommand.C +++ b/src/mathed/InsetMathCommand.C @@ -37,14 +37,17 @@ auto_ptr CommandInset::doClone() const } -void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const +bool CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const { if (!set_label_) { set_label_ = true; button_.update(screenLabel(), true); } button_.metrics(mi, dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathCommand.h b/src/mathed/InsetMathCommand.h index a95ec06c68..93c280aa38 100644 --- a/src/mathed/InsetMathCommand.h +++ b/src/mathed/InsetMathCommand.h @@ -27,7 +27,7 @@ public: /// explicit CommandInset(docstring const & name); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathComment.C b/src/mathed/InsetMathComment.C index 650c27f25d..857d721693 100644 --- a/src/mathed/InsetMathComment.C +++ b/src/mathed/InsetMathComment.C @@ -42,11 +42,14 @@ auto_ptr InsetMathComment::doClone() const } -void InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathComment.h b/src/mathed/InsetMathComment.h index 184c7bd142..02986ed1f6 100644 --- a/src/mathed/InsetMathComment.h +++ b/src/mathed/InsetMathComment.h @@ -27,7 +27,7 @@ public: /// explicit InsetMathComment(docstring const &); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathDFrac.C b/src/mathed/InsetMathDFrac.C index e2c771e091..6a0a60f7a8 100644 --- a/src/mathed/InsetMathDFrac.C +++ b/src/mathed/InsetMathDFrac.C @@ -37,14 +37,17 @@ auto_ptr InsetMathDFrac::doClone() const } -void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi); cell(1).metrics(mi); - dim_.wid = max(cell(0).width(), cell(1).width()) + 2; - dim_.asc = cell(0).height() + 2 + 5; - dim_.des = cell(1).height() + 2 - 5; - dim = dim_; + dim.wid = max(cell(0).width(), cell(1).width()) + 2; + dim.asc = cell(0).height() + 2 + 5; + dim.des = cell(1).height() + 2 - 5; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathDFrac.h b/src/mathed/InsetMathDFrac.h index 596f3f5522..3c62c8a664 100644 --- a/src/mathed/InsetMathDFrac.h +++ b/src/mathed/InsetMathDFrac.h @@ -24,7 +24,7 @@ public: /// InsetMathDFrac(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathDecoration.C b/src/mathed/InsetMathDecoration.C index 0d67122d85..846bac8faf 100644 --- a/src/mathed/InsetMathDecoration.C +++ b/src/mathed/InsetMathDecoration.C @@ -102,7 +102,7 @@ bool InsetMathDecoration::ams() const } -void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); @@ -118,7 +118,10 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const } metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathDecoration.h b/src/mathed/InsetMathDecoration.h index 030836617f..d7019ae1e8 100644 --- a/src/mathed/InsetMathDecoration.h +++ b/src/mathed/InsetMathDecoration.h @@ -30,7 +30,7 @@ public: /// void write(WriteStream & os) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void normalize(NormalStream & os) const; /// diff --git a/src/mathed/InsetMathDelim.C b/src/mathed/InsetMathDelim.C index b59ca12fea..f74b81e3bb 100644 --- a/src/mathed/InsetMathDelim.C +++ b/src/mathed/InsetMathDelim.C @@ -71,7 +71,7 @@ void InsetMathDelim::normalize(NormalStream & os) const } -void InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi); Dimension t; @@ -84,10 +84,13 @@ void InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const dw_ = 8; if (dw_ < 4) dw_ = 4; - dim_.wid = cell(0).width() + 2 * dw_ + 8; - dim_.asc = max(a0, d0) + h0; - dim_.des = max(a0, d0) - h0; - dim = dim_; + dim.wid = cell(0).width() + 2 * dw_ + 8; + dim.asc = max(a0, d0) + h0; + dim.des = max(a0, d0) - h0; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h index cc34e54980..ab94d85808 100644 --- a/src/mathed/InsetMathDelim.h +++ b/src/mathed/InsetMathDelim.h @@ -40,7 +40,7 @@ public: /// mode_type currentMode() const { return MATH_MODE; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; diff --git a/src/mathed/InsetMathDiff.C b/src/mathed/InsetMathDiff.C index 8b74d26b26..47ee175654 100644 --- a/src/mathed/InsetMathDiff.C +++ b/src/mathed/InsetMathDiff.C @@ -48,9 +48,10 @@ void InsetMathDiff::normalize(NormalStream & os) const } -void InsetMathDiff::metrics(MetricsInfo &, Dimension &) const +bool InsetMathDiff::metrics(MetricsInfo &, Dimension &) const { lyxerr << "should not happen" << endl; + return true; } diff --git a/src/mathed/InsetMathDiff.h b/src/mathed/InsetMathDiff.h index 3dfc0b1864..02658add64 100644 --- a/src/mathed/InsetMathDiff.h +++ b/src/mathed/InsetMathDiff.h @@ -28,7 +28,7 @@ public: /// void addDer(MathArray const & der); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMathDim.h b/src/mathed/InsetMathDim.h index a88d2f545d..30f13eb20f 100644 --- a/src/mathed/InsetMathDim.h +++ b/src/mathed/InsetMathDim.h @@ -13,8 +13,6 @@ #define MATH_DIMINSET_H #include "InsetMath.h" -#include "dimension.h" - namespace lyx { @@ -38,10 +36,6 @@ public: /// void setPosCache(PainterInfo const & pi, int x, int y) const; - -protected: - /// - mutable Dimension dim_; }; diff --git a/src/mathed/InsetMathDots.C b/src/mathed/InsetMathDots.C index 0d6c954b0f..5178aa6432 100644 --- a/src/mathed/InsetMathDots.C +++ b/src/mathed/InsetMathDots.C @@ -35,7 +35,7 @@ auto_ptr InsetMathDots::doClone() const } -void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const { mathed_char_dim(mi.base.font, 'M', dim); dh_ = 0; @@ -50,7 +50,10 @@ void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const } else if (key_->name == "ddots") dh_ = dim.asc; + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathDots.h b/src/mathed/InsetMathDots.h index 424a0f738a..86173a0b37 100644 --- a/src/mathed/InsetMathDots.h +++ b/src/mathed/InsetMathDots.h @@ -25,7 +25,7 @@ public: /// explicit InsetMathDots(latexkeys const * l); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathEnv.C b/src/mathed/InsetMathEnv.C index e86ec67b40..3a13320fcb 100644 --- a/src/mathed/InsetMathEnv.C +++ b/src/mathed/InsetMathEnv.C @@ -35,11 +35,14 @@ auto_ptr InsetMathEnv::doClone() const } -void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathEnv.h b/src/mathed/InsetMathEnv.h index 75252bb18a..49922d4cc9 100644 --- a/src/mathed/InsetMathEnv.h +++ b/src/mathed/InsetMathEnv.h @@ -32,7 +32,7 @@ public: /// write normalized content void normalize(NormalStream & ns) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void infoize(odocstream & os) const; diff --git a/src/mathed/InsetMathExFunc.C b/src/mathed/InsetMathExFunc.C index 4b9ba777cb..f74af99e0c 100644 --- a/src/mathed/InsetMathExFunc.C +++ b/src/mathed/InsetMathExFunc.C @@ -42,9 +42,13 @@ auto_ptr InsetMathExFunc::doClone() const } -void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & /*dim*/) const +bool InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const { - mathed_string_dim(mi.base.font, name_, dim_); + mathed_string_dim(mi.base.font, name_, dim); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathExFunc.h b/src/mathed/InsetMathExFunc.h index 1dc39f6b8f..5f150eeab9 100644 --- a/src/mathed/InsetMathExFunc.h +++ b/src/mathed/InsetMathExFunc.h @@ -30,7 +30,7 @@ public: /// InsetMathExFunc(docstring const & name, MathArray const & ar); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathExInt.C b/src/mathed/InsetMathExInt.C index a349946a7e..8427723418 100644 --- a/src/mathed/InsetMathExInt.C +++ b/src/mathed/InsetMathExInt.C @@ -65,9 +65,10 @@ void InsetMathExInt::normalize(NormalStream & os) const } -void InsetMathExInt::metrics(MetricsInfo &, Dimension &) const +bool InsetMathExInt::metrics(MetricsInfo &, Dimension &) const { lyxerr << "should not happen" << endl; + return true; } diff --git a/src/mathed/InsetMathExInt.h b/src/mathed/InsetMathExInt.h index 50ea077f37..f1f51d45f4 100644 --- a/src/mathed/InsetMathExInt.h +++ b/src/mathed/InsetMathExInt.h @@ -29,7 +29,7 @@ public: /// void symbol(docstring const &); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; diff --git a/src/mathed/InsetMathFBox.C b/src/mathed/InsetMathFBox.C index 7306c6ed61..71a9ec192d 100644 --- a/src/mathed/InsetMathFBox.C +++ b/src/mathed/InsetMathFBox.C @@ -43,12 +43,15 @@ InsetMath::mode_type InsetMathFBox::currentMode() const } -void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const +bool 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 + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathFBox.h b/src/mathed/InsetMathFBox.h index 1cd2b9d17c..9e8e1a4575 100644 --- a/src/mathed/InsetMathFBox.h +++ b/src/mathed/InsetMathFBox.h @@ -26,7 +26,7 @@ public: /// mode_type currentMode() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathFont.C b/src/mathed/InsetMathFont.C index 7326b69817..dd66629c33 100644 --- a/src/mathed/InsetMathFont.C +++ b/src/mathed/InsetMathFont.C @@ -44,12 +44,15 @@ InsetMath::mode_type InsetMathFont::currentMode() const } -void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, key_->name); cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathFont.h b/src/mathed/InsetMathFont.h index b83910523f..085ca65b56 100644 --- a/src/mathed/InsetMathFont.h +++ b/src/mathed/InsetMathFont.h @@ -34,7 +34,7 @@ public: /// docstring name() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathFontOld.C b/src/mathed/InsetMathFontOld.C index a78e4e77d2..21c8e17bd0 100644 --- a/src/mathed/InsetMathFontOld.C +++ b/src/mathed/InsetMathFontOld.C @@ -36,12 +36,15 @@ auto_ptr InsetMathFontOld::doClone() const } -void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, key_->name.c_str()); cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathFontOld.h b/src/mathed/InsetMathFontOld.h index 7e44e08c9f..734fabc3e7 100644 --- a/src/mathed/InsetMathFontOld.h +++ b/src/mathed/InsetMathFontOld.h @@ -30,7 +30,7 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathFrac.C b/src/mathed/InsetMathFrac.C index 714043d573..8d9fa33bc6 100644 --- a/src/mathed/InsetMathFrac.C +++ b/src/mathed/InsetMathFrac.C @@ -51,7 +51,7 @@ InsetMathFrac const * InsetMathFrac::asFracInset() const } -void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const { FracChanger dummy(mi.base); cell(0).metrics(mi); @@ -66,7 +66,10 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const dim.des = cell(1).height() + 2 - 5; } metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h index dc4ed0bf52..ae361f0b99 100644 --- a/src/mathed/InsetMathFrac.h +++ b/src/mathed/InsetMathFrac.h @@ -33,7 +33,7 @@ public: /// explicit InsetMathFrac(Kind kind = FRAC); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathFrameBox.C b/src/mathed/InsetMathFrameBox.C index 6636442967..a6c270b34e 100644 --- a/src/mathed/InsetMathFrameBox.C +++ b/src/mathed/InsetMathFrameBox.C @@ -34,7 +34,7 @@ auto_ptr InsetMathFrameBox::doClone() const } -void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, "textnormal"); w_ = mathed_char_width(mi.base.font, '['); @@ -43,7 +43,10 @@ void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const dim += cell(1).dim(); dim += cell(2).dim(); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathFrameBox.h b/src/mathed/InsetMathFrameBox.h index 2034e5b375..445bc1468e 100644 --- a/src/mathed/InsetMathFrameBox.h +++ b/src/mathed/InsetMathFrameBox.h @@ -24,7 +24,7 @@ public: /// InsetMathFrameBox(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathGrid.C b/src/mathed/InsetMathGrid.C index 7d52295604..46eed9db8e 100644 --- a/src/mathed/InsetMathGrid.C +++ b/src/mathed/InsetMathGrid.C @@ -471,10 +471,14 @@ void InsetMathGrid::metrics(MetricsInfo & mi) const } -void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const { - metrics(mi); dim = dim_; + metrics(mi); + if (dim_ == dim) + return false; + dim = dim_; + return true; } diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h index f2fbcceb2e..b08ad54be5 100644 --- a/src/mathed/InsetMathGrid.h +++ b/src/mathed/InsetMathGrid.h @@ -97,7 +97,7 @@ public: /// void metrics(MetricsInfo & mi) const; /// - void metrics(MetricsInfo & mi, Dimension &) const; + bool metrics(MetricsInfo & mi, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathHull.C b/src/mathed/InsetMathHull.C index 8ee9abe9ae..4f2f7c4366 100644 --- a/src/mathed/InsetMathHull.C +++ b/src/mathed/InsetMathHull.C @@ -283,7 +283,7 @@ bool InsetMathHull::previewState(BufferView * bv) const } -void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const { if (previewState(mi.base.bv)) { preview_->metrics(mi, dim); @@ -291,8 +291,10 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const dim.wid += 1; if (display()) dim.des += displayMargin(); + if (dim_ == dim) + return false; dim_ = dim; - return; + return true; } FontSetChanger dummy1(mi.base, standardFont()); @@ -323,7 +325,10 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = max(dim.asc, asc); dim.des = max(dim.des, des); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index 41123a4cc8..1df5ce128b 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -35,7 +35,7 @@ public: /// mode_type currentMode() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathKern.C b/src/mathed/InsetMathKern.C index b4ad79d2cc..b696a96b1d 100644 --- a/src/mathed/InsetMathKern.C +++ b/src/mathed/InsetMathKern.C @@ -43,12 +43,16 @@ auto_ptr InsetMathKern::doClone() const } -void InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const { wid_pix_ = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M')); dim.wid = wid_pix_; dim.asc = 0; dim.des = 0; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathKern.h b/src/mathed/InsetMathKern.h index 63c20d0008..218278de92 100644 --- a/src/mathed/InsetMathKern.h +++ b/src/mathed/InsetMathKern.h @@ -31,7 +31,7 @@ public: /// explicit InsetMathKern(docstring const & wid); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathLefteqn.C b/src/mathed/InsetMathLefteqn.C index b75c0da0a9..749bce7068 100644 --- a/src/mathed/InsetMathLefteqn.C +++ b/src/mathed/InsetMathLefteqn.C @@ -33,14 +33,17 @@ auto_ptr InsetMathLefteqn::doClone() const } -void InsetMathLefteqn::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathLefteqn::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); dim.asc += 2; dim.des += 2; dim.wid = 4; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathLefteqn.h b/src/mathed/InsetMathLefteqn.h index cf0d41495d..aecffbfe6c 100644 --- a/src/mathed/InsetMathLefteqn.h +++ b/src/mathed/InsetMathLefteqn.h @@ -27,7 +27,7 @@ public: /// docstring name() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathLim.C b/src/mathed/InsetMathLim.C index 6e30133962..59c6aa3dcc 100644 --- a/src/mathed/InsetMathLim.C +++ b/src/mathed/InsetMathLim.C @@ -44,9 +44,10 @@ void InsetMathLim::normalize(NormalStream & os) const } -void InsetMathLim::metrics(MetricsInfo &, Dimension &) const +bool InsetMathLim::metrics(MetricsInfo &, Dimension &) const { lyxerr << "should not happen" << endl; + return true; } diff --git a/src/mathed/InsetMathLim.h b/src/mathed/InsetMathLim.h index bb6edd2ebb..af1480dd0c 100644 --- a/src/mathed/InsetMathLim.h +++ b/src/mathed/InsetMathLim.h @@ -26,7 +26,7 @@ public: /// InsetMathLim(MathArray const & f, MathArray const & x, MathArray const & x0); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMathMBox.C b/src/mathed/InsetMathMBox.C index 962ece1de0..9f70529010 100644 --- a/src/mathed/InsetMathMBox.C +++ b/src/mathed/InsetMathMBox.C @@ -50,11 +50,14 @@ auto_ptr InsetMathMBox::doClone() const } -void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const { text_.metrics(mi, dim); metricsMarkers2(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathMBox.h b/src/mathed/InsetMathMBox.h index cc621b71c7..e1c34e8acf 100644 --- a/src/mathed/InsetMathMBox.h +++ b/src/mathed/InsetMathMBox.h @@ -26,7 +26,7 @@ public: /// explicit InsetMathMBox(BufferView & bv); /// this stores metrics information in cache_ - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// draw according to cached metrics void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathMacro.C b/src/mathed/InsetMathMacro.C index bb0966d8b6..5126e19ccc 100644 --- a/src/mathed/InsetMathMacro.C +++ b/src/mathed/InsetMathMacro.C @@ -59,7 +59,7 @@ void MathMacro::cursorPos(BufferView const & bv, } -void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const +bool MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const { if (!MacroTable::globalMacros().has(name())) { mathed_string_dim(mi.base.font, "Unknown: " + name(), dim); @@ -84,7 +84,10 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const expanded_.metrics(mi, dim); } metricsMarkers2(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathMacro.h b/src/mathed/InsetMathMacro.h index 24cd74586c..8a6a6997c7 100644 --- a/src/mathed/InsetMathMacro.h +++ b/src/mathed/InsetMathMacro.h @@ -34,7 +34,7 @@ public: /// draw selection background void drawSelection(PainterInfo & pi, int x, int y) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// get cursor position void cursorPos(BufferView const & bv, CursorSlice const & sl, bool boundary, int & x, int & y) const; diff --git a/src/mathed/InsetMathMakebox.C b/src/mathed/InsetMathMakebox.C index 068d42327a..2ef56d955a 100644 --- a/src/mathed/InsetMathMakebox.C +++ b/src/mathed/InsetMathMakebox.C @@ -34,7 +34,7 @@ auto_ptr InsetMathMakebox::doClone() const } -void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, from_ascii("textnormal")); w_ = mathed_char_width(mi.base.font, '['); @@ -44,7 +44,10 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const dim += cell(2).dim(); dim.wid += 4 * w_ + 4; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathMakebox.h b/src/mathed/InsetMathMakebox.h index 859701154f..1c459f2ea1 100644 --- a/src/mathed/InsetMathMakebox.h +++ b/src/mathed/InsetMathMakebox.h @@ -25,7 +25,7 @@ public: /// InsetMathMakebox(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathNumber.C b/src/mathed/InsetMathNumber.C index 9ab909cf08..41e7c60a7c 100644 --- a/src/mathed/InsetMathNumber.C +++ b/src/mathed/InsetMathNumber.C @@ -33,9 +33,13 @@ auto_ptr InsetMathNumber::doClone() const } -void InsetMathNumber::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathNumber::metrics(MetricsInfo & mi, Dimension & dim) const { mathed_string_dim(mi.base.font, str_, dim); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathNumber.h b/src/mathed/InsetMathNumber.h index d6ccbb0d20..606603e6df 100644 --- a/src/mathed/InsetMathNumber.h +++ b/src/mathed/InsetMathNumber.h @@ -26,7 +26,7 @@ public: /// explicit InsetMathNumber(docstring const & s); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathOverset.C b/src/mathed/InsetMathOverset.C index dfca03bd5e..0ecc01577f 100644 --- a/src/mathed/InsetMathOverset.C +++ b/src/mathed/InsetMathOverset.C @@ -30,7 +30,7 @@ auto_ptr InsetMathOverset::doClone() const } -void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const { cell(1).metrics(mi); FracChanger dummy(mi.base); @@ -39,7 +39,10 @@ void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = cell(1).ascent() + cell(0).height() + 4; dim.des = cell(1).descent(); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathOverset.h b/src/mathed/InsetMathOverset.h index cff7e7a229..c74557c04c 100644 --- a/src/mathed/InsetMathOverset.h +++ b/src/mathed/InsetMathOverset.h @@ -22,7 +22,7 @@ namespace lyx { class InsetMathOverset : public InsetMathFracBase { public: /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathPar.C b/src/mathed/InsetMathPar.C index 3f8be93d00..6ebe584c92 100644 --- a/src/mathed/InsetMathPar.C +++ b/src/mathed/InsetMathPar.C @@ -28,11 +28,15 @@ InsetMathPar::InsetMathPar(MathArray const & ar) } -void InsetMathPar::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathPar::metrics(MetricsInfo & mi, Dimension & dim) const { + dim = dim_; FontSetChanger dummy1(mi.base, "textnormal"); InsetMathGrid::metrics(mi); + if (dim_ == dim) + return false; dim = dim_; + return true; } diff --git a/src/mathed/InsetMathPar.h b/src/mathed/InsetMathPar.h index 6fd28850fd..3f980e2fec 100644 --- a/src/mathed/InsetMathPar.h +++ b/src/mathed/InsetMathPar.h @@ -27,7 +27,7 @@ public: /// mode_type currentMode() const { return TEXT_MODE; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathPhantom.C b/src/mathed/InsetMathPhantom.C index 75fd7774cd..97f0bf2fd8 100644 --- a/src/mathed/InsetMathPhantom.C +++ b/src/mathed/InsetMathPhantom.C @@ -35,11 +35,14 @@ std::auto_ptr InsetMathPhantom::doClone() const } -void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathPhantom.h b/src/mathed/InsetMathPhantom.h index dfb7b60f7c..edefb74dff 100644 --- a/src/mathed/InsetMathPhantom.h +++ b/src/mathed/InsetMathPhantom.h @@ -28,7 +28,7 @@ public: /// explicit InsetMathPhantom(Kind); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathRoot.C b/src/mathed/InsetMathRoot.C index 11a9221505..bf0112a2da 100644 --- a/src/mathed/InsetMathRoot.C +++ b/src/mathed/InsetMathRoot.C @@ -38,14 +38,17 @@ auto_ptr InsetMathRoot::doClone() const } -void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const { InsetMathNest::metrics(mi); dim.asc = max(cell(0).ascent() + 5, cell(1).ascent()) + 2; dim.des = max(cell(1).descent() + 5, cell(0).descent()) + 2; dim.wid = cell(0).width() + cell(1).width() + 10; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathRoot.h b/src/mathed/InsetMathRoot.h index ac69d1d933..57af6ae83a 100644 --- a/src/mathed/InsetMathRoot.h +++ b/src/mathed/InsetMathRoot.h @@ -27,7 +27,7 @@ public: /// bool idxUpDown(LCursor & cur, bool up) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMathScript.C b/src/mathed/InsetMathScript.C index c47e239892..b6b3d87e4a 100644 --- a/src/mathed/InsetMathScript.C +++ b/src/mathed/InsetMathScript.C @@ -213,7 +213,7 @@ int InsetMathScript::ndes() const } -void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi); ScriptChanger dummy(mi.base); @@ -238,7 +238,10 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = dy1() + (hasUp() ? up().ascent() : 0); dim.des = dy0() + (hasDown() ? down().descent() : 0); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index adffa97ff7..2c00668384 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -33,7 +33,7 @@ public: /// mode_type currentMode() const { return MATH_MODE; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathSize.C b/src/mathed/InsetMathSize.C index 562aa0cd65..86ec8d8a25 100644 --- a/src/mathed/InsetMathSize.C +++ b/src/mathed/InsetMathSize.C @@ -36,12 +36,15 @@ auto_ptr InsetMathSize::doClone() const } -void InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const { StyleChanger dummy(mi.base, style_); cell(0).metrics(mi, dim); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathSize.h b/src/mathed/InsetMathSize.h index 5a9767af03..f749e3ef5c 100644 --- a/src/mathed/InsetMathSize.h +++ b/src/mathed/InsetMathSize.h @@ -29,7 +29,7 @@ public: /// we write extra braces in any case... bool extraBraces() const { return true; } /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; diff --git a/src/mathed/InsetMathSpace.C b/src/mathed/InsetMathSpace.C index fd0f56997f..0c44fabf5b 100644 --- a/src/mathed/InsetMathSpace.C +++ b/src/mathed/InsetMathSpace.C @@ -85,11 +85,15 @@ int InsetMathSpace::descent() const } -void InsetMathSpace::metrics(MetricsInfo &, Dimension & dim) const +bool InsetMathSpace::metrics(MetricsInfo &, Dimension & dim) const { dim.wid = width(); dim.asc = ascent(); dim.des = descent(); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathSpace.h b/src/mathed/InsetMathSpace.h index a3e06d634e..1a41373436 100644 --- a/src/mathed/InsetMathSpace.h +++ b/src/mathed/InsetMathSpace.h @@ -38,7 +38,7 @@ public: /// int width() const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMathSqrt.C b/src/mathed/InsetMathSqrt.C index 82edc46126..33b5e77514 100644 --- a/src/mathed/InsetMathSqrt.C +++ b/src/mathed/InsetMathSqrt.C @@ -34,14 +34,17 @@ auto_ptr InsetMathSqrt::doClone() const } -void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); dim.asc += 4; dim.des += 2; dim.wid += 12; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathSqrt.h b/src/mathed/InsetMathSqrt.h index 8e19b367d8..a4407d4a28 100644 --- a/src/mathed/InsetMathSqrt.h +++ b/src/mathed/InsetMathSqrt.h @@ -27,7 +27,7 @@ public: /// void draw(PainterInfo &, int x, int y) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void drawT(TextPainter &, int x, int y) const; /// diff --git a/src/mathed/InsetMathStackrel.C b/src/mathed/InsetMathStackrel.C index 197d78df60..b4e245faa3 100644 --- a/src/mathed/InsetMathStackrel.C +++ b/src/mathed/InsetMathStackrel.C @@ -32,7 +32,7 @@ auto_ptr InsetMathStackrel::doClone() const } -void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const { cell(1).metrics(mi); FracChanger dummy(mi.base); @@ -41,7 +41,10 @@ void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = cell(1).ascent() + cell(0).height() + 4; dim.des = cell(1).descent(); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathStackrel.h b/src/mathed/InsetMathStackrel.h index 5799df2749..75c07f7f62 100644 --- a/src/mathed/InsetMathStackrel.h +++ b/src/mathed/InsetMathStackrel.h @@ -28,7 +28,7 @@ public: /// InsetMathStackrel(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/InsetMathString.C b/src/mathed/InsetMathString.C index 78637265d7..dc9e5b8858 100644 --- a/src/mathed/InsetMathString.C +++ b/src/mathed/InsetMathString.C @@ -33,9 +33,13 @@ auto_ptr InsetMathString::doClone() const } -void InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const { mathed_string_dim(mi.base.font, str_, dim); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathString.h b/src/mathed/InsetMathString.h index f0803a8e2b..495de2f005 100644 --- a/src/mathed/InsetMathString.h +++ b/src/mathed/InsetMathString.h @@ -26,7 +26,7 @@ public: /// explicit InsetMathString(docstring const & s); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathSubstack.C b/src/mathed/InsetMathSubstack.C index c89bbc143d..8b7fd3d571 100644 --- a/src/mathed/InsetMathSubstack.C +++ b/src/mathed/InsetMathSubstack.C @@ -42,7 +42,7 @@ auto_ptr InsetMathSubstack::doClone() const } -void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const { if (mi.base.style == LM_ST_DISPLAY) { StyleChanger dummy(mi.base, LM_ST_TEXT); @@ -50,7 +50,10 @@ void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const } else { InsetMathGrid::metrics(mi, dim); } + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathSubstack.h b/src/mathed/InsetMathSubstack.h index c184dc4a97..417adc1d9f 100644 --- a/src/mathed/InsetMathSubstack.h +++ b/src/mathed/InsetMathSubstack.h @@ -25,7 +25,7 @@ public: /// InsetMathSubstack(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathSymbol.C b/src/mathed/InsetMathSymbol.C index 206b6304db..1a5176b666 100644 --- a/src/mathed/InsetMathSymbol.C +++ b/src/mathed/InsetMathSymbol.C @@ -54,7 +54,7 @@ docstring InsetMathSymbol::name() const } -void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const { //lyxerr << "metrics: symbol: '" << sym_->name // << "' in font: '" << sym_->inset @@ -84,6 +84,10 @@ void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const scriptable_ = true; width_ = dim.wid; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathSymbol.h b/src/mathed/InsetMathSymbol.h index 1231983ae7..c34d30c696 100644 --- a/src/mathed/InsetMathSymbol.h +++ b/src/mathed/InsetMathSymbol.h @@ -32,7 +32,7 @@ public: /// explicit InsetMathSymbol(docstring const & name); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathTFrac.C b/src/mathed/InsetMathTFrac.C index 102c061e2c..f361dc7872 100644 --- a/src/mathed/InsetMathTFrac.C +++ b/src/mathed/InsetMathTFrac.C @@ -40,15 +40,18 @@ auto_ptr InsetMathTFrac::doClone() const } -void InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const { StyleChanger dummy(mi.base, LM_ST_SCRIPT); cell(0).metrics(mi); cell(1).metrics(mi); - dim_.wid = max(cell(0).width(), cell(1).width()) + 2; - dim_.asc = cell(0).height() + 2 + 5; - dim_.des = cell(1).height() + 2 - 5; - dim = dim_; + dim.wid = max(cell(0).width(), cell(1).width()) + 2; + dim.asc = cell(0).height() + 2 + 5; + dim.des = cell(1).height() + 2 - 5; + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathTFrac.h b/src/mathed/InsetMathTFrac.h index 045a3e35fb..ee8f4c9524 100644 --- a/src/mathed/InsetMathTFrac.h +++ b/src/mathed/InsetMathTFrac.h @@ -24,7 +24,7 @@ public: /// InsetMathTFrac(); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/InsetMathTabular.C b/src/mathed/InsetMathTabular.C index 663559d79b..54ef64cbbe 100644 --- a/src/mathed/InsetMathTabular.C +++ b/src/mathed/InsetMathTabular.C @@ -51,12 +51,15 @@ auto_ptr InsetMathTabular::doClone() const } -void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const { FontSetChanger dummy(mi.base, "textnormal"); InsetMathGrid::metrics(mi, dim); dim.wid += 6; + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathTabular.h b/src/mathed/InsetMathTabular.h index 13b4960e50..4e86b44ab9 100644 --- a/src/mathed/InsetMathTabular.h +++ b/src/mathed/InsetMathTabular.h @@ -29,7 +29,7 @@ public: /// InsetMathTabular(docstring const &, char valign, docstring const & halign); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathUnderset.C b/src/mathed/InsetMathUnderset.C index 6218b6e72c..f756a49f13 100644 --- a/src/mathed/InsetMathUnderset.C +++ b/src/mathed/InsetMathUnderset.C @@ -31,7 +31,7 @@ auto_ptr InsetMathUnderset::doClone() const } -void InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & dim) const { cell(1).metrics(mi); FracChanger dummy(mi.base); @@ -40,7 +40,10 @@ void InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = cell(1).ascent(); dim.des = cell(1).descent() + cell(0).height() + 4; metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathUnderset.h b/src/mathed/InsetMathUnderset.h index a53e74266a..4eb2fce517 100644 --- a/src/mathed/InsetMathUnderset.h +++ b/src/mathed/InsetMathUnderset.h @@ -22,7 +22,7 @@ namespace lyx { class InsetMathUnderset : public InsetMathFracBase { public: /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathUnknown.C b/src/mathed/InsetMathUnknown.C index 007989b2bc..302c913829 100644 --- a/src/mathed/InsetMathUnknown.C +++ b/src/mathed/InsetMathUnknown.C @@ -53,10 +53,13 @@ void InsetMathUnknown::normalize(NormalStream & os) const } -void InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const { mathed_string_dim(mi.base.font, name_, dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathUnknown.h b/src/mathed/InsetMathUnknown.h index 7872e73b36..d1ab2bc50a 100644 --- a/src/mathed/InsetMathUnknown.h +++ b/src/mathed/InsetMathUnknown.h @@ -25,7 +25,7 @@ public: explicit InsetMathUnknown(docstring const & name, bool final = true, bool black = false); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathXArrow.C b/src/mathed/InsetMathXArrow.C index a6ff4e626a..b8f1f3af98 100644 --- a/src/mathed/InsetMathXArrow.C +++ b/src/mathed/InsetMathXArrow.C @@ -36,7 +36,7 @@ auto_ptr InsetMathXArrow::doClone() const } -void InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const { ScriptChanger dummy(mi.base); cell(0).metrics(mi); @@ -45,7 +45,10 @@ void InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = cell(0).height() + 10; dim.des = cell(1).height(); metricsMarkers(dim); + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathXArrow.h b/src/mathed/InsetMathXArrow.h index 05bc2740bb..0355b15fd0 100644 --- a/src/mathed/InsetMathXArrow.h +++ b/src/mathed/InsetMathXArrow.h @@ -28,7 +28,7 @@ public: /// void write(WriteStream & os) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void normalize(NormalStream & os) const; /// diff --git a/src/mathed/InsetMathXYArrow.C b/src/mathed/InsetMathXYArrow.C index 890d7cc792..1b97ff5407 100644 --- a/src/mathed/InsetMathXYArrow.C +++ b/src/mathed/InsetMathXYArrow.C @@ -81,7 +81,7 @@ MathArray const & InsetMathXYArrow::sourceCell() const } -void InsetMathXYArrow::metrics(MetricsInfo & mi) const +bool InsetMathXYArrow::metrics(MetricsInfo & mi) const { InsetMathNest::metrics(mi); mi_ = mi; diff --git a/src/mathed/InsetMathXYArrow.h b/src/mathed/InsetMathXYArrow.h index 42552c48eb..334b8f58cb 100644 --- a/src/mathed/InsetMathXYArrow.h +++ b/src/mathed/InsetMathXYArrow.h @@ -30,7 +30,7 @@ public: /// virtual std::auto_ptr clone() const; /// - void metrics(MetricsInfo & mi) const; + bool metrics(MetricsInfo & mi) const; /// void draw(PainterInfo & pi, int x, int y) const; /// diff --git a/src/mathed/InsetMathXYMatrix.C b/src/mathed/InsetMathXYMatrix.C index 679f271289..cbeba96583 100644 --- a/src/mathed/InsetMathXYMatrix.C +++ b/src/mathed/InsetMathXYMatrix.C @@ -43,11 +43,15 @@ int InsetMathXYMatrix::rowsep() const } -void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const { if (mi.base.style == LM_ST_DISPLAY) mi.base.style = LM_ST_TEXT; InsetMathGrid::metrics(mi, dim); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/InsetMathXYMatrix.h b/src/mathed/InsetMathXYMatrix.h index 8cef0b8656..949f488f94 100644 --- a/src/mathed/InsetMathXYMatrix.h +++ b/src/mathed/InsetMathXYMatrix.h @@ -24,7 +24,7 @@ public: /// InsetMathXYMatrix(LyXLength const & = LyXLength(), char c = '\0'); /// - void metrics(MetricsInfo &, Dimension &) const; + bool metrics(MetricsInfo &, Dimension &) const; /// InsetMathXYMatrix const * asXYMatrixInset() const { return this; } /// diff --git a/src/mathed/MathData.C b/src/mathed/MathData.C index 731a7753d2..f36bf570ba 100644 --- a/src/mathed/MathData.C +++ b/src/mathed/MathData.C @@ -211,10 +211,14 @@ void MathArray::touch() const } -void MathArray::metrics(MetricsInfo & mi, Dimension & dim) const +bool MathArray::metrics(MetricsInfo & mi, Dimension & dim) const { - metrics(mi); dim = dim_; + metrics(mi); + if (dim_ == dim) + return false; + dim = dim_; + return true; } diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h index 678e9976d5..bf4d5909c0 100644 --- a/src/mathed/MathData.h +++ b/src/mathed/MathData.h @@ -106,7 +106,7 @@ public: /// rebuild cached metrics information void metrics(MetricsInfo & mi) const; /// rebuild cached metrics information - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// redraw cell using cache metrics information void draw(PainterInfo & pi, int x, int y) const; /// rebuild cached metrics information @@ -151,12 +151,13 @@ public: /// dimensions of cell void setDim(Dimension const & d) const { dim_ = d; } +protected: + /// cached dimensions of cell + mutable Dimension dim_; + private: /// is this an exact match at this position? bool find1(MathArray const & ar, size_type pos) const; - - /// cached dimensions of cell - mutable Dimension dim_; }; /// diff --git a/src/mathed/MathMacroArgument.C b/src/mathed/MathMacroArgument.C index 999079b640..14468dd56b 100644 --- a/src/mathed/MathMacroArgument.C +++ b/src/mathed/MathMacroArgument.C @@ -55,10 +55,13 @@ void MathMacroArgument::write(WriteStream & os) const } -void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const +bool MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const { - mathed_string_dim(mi.base.font, str_, dim_); - dim = dim_; + mathed_string_dim(mi.base.font, str_, dim); + if (dim_ == dim) + return false; + dim_ = dim; + return true; } diff --git a/src/mathed/MathMacroArgument.h b/src/mathed/MathMacroArgument.h index 32729a6df7..1fe0f2ea9f 100644 --- a/src/mathed/MathMacroArgument.h +++ b/src/mathed/MathMacroArgument.h @@ -25,7 +25,7 @@ public: /// explicit MathMacroArgument(std::size_t); /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; /// diff --git a/src/mathed/MathMacroTemplate.C b/src/mathed/MathMacroTemplate.C index 1cf6c25e11..aedca14612 100644 --- a/src/mathed/MathMacroTemplate.C +++ b/src/mathed/MathMacroTemplate.C @@ -112,7 +112,7 @@ docstring MathMacroTemplate::prefix() const } -void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const +bool MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi); cell(1).metrics(mi); @@ -121,7 +121,10 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const + theFontMetrics(mi.base.font).width(dp); dim.asc = std::max(cell(0).ascent(), cell(1).ascent()) + 7; dim.des = std::max(cell(0).descent(), cell(1).descent()) + 7; + if (dim_ == dim) + return false; dim_ = dim; + return true; } diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h index c319ae5a8e..4682df22e8 100644 --- a/src/mathed/MathMacroTemplate.h +++ b/src/mathed/MathMacroTemplate.h @@ -55,7 +55,7 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - void metrics(MetricsInfo & mi, Dimension & dim) const; + bool metrics(MetricsInfo & mi, Dimension & dim) const; /// identifies macro templates MathMacroTemplate * asMacroTemplate() { return this; } /// identifies macro templates diff --git a/src/text.C b/src/text.C index e23eba2e88..a0a3c05f83 100644 --- a/src/text.C +++ b/src/text.C @@ -1833,6 +1833,8 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit) Paragraph & par = pars_[pit]; Buffer const & buffer = *bv.buffer(); + bool changed = false; + // Add bibitem insets if necessary if (par.layout()->labeltype == LABEL_BIBLIO) { bool hasbibitem(false); @@ -1871,7 +1873,7 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit) bufferfont : getFont(buffer, par, ii->pos); MetricsInfo mi(&bv, font, w); - ii->inset->metrics(mi, dim); + changed |= ii->inset->metrics(mi, dim); } // rebreak the paragraph @@ -1908,16 +1910,16 @@ bool LyXText::redoParagraph(BufferView & bv, pit_type const pit) dim.asc += par.rows()[0].ascent(); dim.des -= par.rows()[0].ascent(); - bool const same = dim.height() == par.dim().height(); + changed |= dim.height() != par.dim().height(); par.dim() = dim; //lyxerr << "redoParagraph: " << par.rows().size() << " rows\n"; - return !same; + return changed; } -void LyXText::metrics(MetricsInfo & mi, Dimension & dim) +bool LyXText::metrics(MetricsInfo & mi, Dimension & dim) { //BOOST_ASSERT(mi.base.textwidth); if (mi.base.textwidth) @@ -1927,10 +1929,12 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim) // save the caller's font locally: font_ = mi.base.font; + bool changed = false; + unsigned int h = 0; unsigned int w = 0; for (pit_type pit = 0, n = paragraphs().size(); pit != n; ++pit) { - redoParagraph(*mi.base.bv, pit); + changed |= redoParagraph(*mi.base.bv, pit); Paragraph & par = paragraphs()[pit]; h += par.height(); if (w < par.width()) @@ -1941,7 +1945,9 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim) dim.asc = pars_[0].ascent(); dim.des = h - dim.asc; + changed |= dim_ != dim; dim_ = dim; + return changed; }