The branch, str-metrics, has been updated. - Log -----------------------------------------------------------------
commit bee6d39d945053f20e72fb572a60269f4bad9f24 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Thu Jul 18 10:55:52 2013 +0200 Small Inset isXXX methods cleanup * rename isStretchableSpace to isHfill * inline a trivial method * remove InsetIPAMacro::isLineSeparator, which has the same value as default. diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 7fd271c..60bee4e 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3192,8 +3192,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, bool Paragraph::isHfill(pos_type pos) const { Inset const * inset = getInset(pos); - return inset && (inset->lyxCode() == SPACE_CODE && - inset->isStretchableSpace()); + return inset && inset->isHfill(); } diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 742060d..b89044f 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -672,8 +672,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit, InsetList::const_iterator iend = par.insetList().end(); for ( ; ii != iend; ++ii) { if (ii->pos >= endpos || ii->pos < row.pos() - || (ii->inset->lyxCode() != SPACE_CODE || - !ii->inset->isStretchableSpace())) + || !ii->inset->isHfill()) continue; Dimension dim = row.dimension(); if (pm.hfillExpansion(row, ii->pos)) diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 8165b4c..6c02875 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -437,8 +437,8 @@ public: /// is this equivalent to a space (which is BTW different from /// a line separator)? virtual bool isSpace() const { return false; } - /// is this an expandible space (rubber length)? - virtual bool isStretchableSpace() const { return false; } + /// does this inset try to use all available space (like \\hfill does)? + virtual bool isHfill() const { return false; } enum DisplayType { Inline = 0, diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index f8888ce..be924f3 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -619,16 +619,4 @@ void InsetIPAChar::validate(LaTeXFeatures & features) const } -bool InsetIPAChar::isLetter() const -{ - return true; -} - - -bool InsetIPAChar::isLineSeparator() const -{ - return false; -} - - } // namespace lyx diff --git a/src/insets/InsetIPAMacro.h b/src/insets/InsetIPAMacro.h index 077889c..b40b237 100644 --- a/src/insets/InsetIPAMacro.h +++ b/src/insets/InsetIPAMacro.h @@ -167,9 +167,7 @@ public: /// should this inset be handled like a normal character? bool isChar() const { return true; } /// is this equivalent to a letter? - bool isLetter() const; - /// should we break lines after this inset? - bool isLineSeparator() const; + bool isLetter() const { return true; } private: Inset * clone() const { return new InsetIPAChar(*this); } diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 03c9367..74e24ba 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -172,7 +172,7 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd, InsetSpaceParams params; string2params(to_utf8(cmd.argument()), params); status.setOnOff(params_.kind == params.kind); - status.setEnabled(true); + status.setEnabled(true); } else status.setEnabled(false); return true; @@ -193,7 +193,7 @@ int const arrow_size = 8; void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const { - if (isStretchableSpace()) { + if (isHfill()) { // The metrics for this kinds are calculated externally in // \c TextMetrics::computeRowMetrics. Those are dummy value: dim = Dimension(10, 10, 10); @@ -234,7 +234,7 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const break; case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM_PROTECTED: { - int const w = + int const w = params_.length.len().inPixels(mi.base.textwidth, fm.width(char_type('M'))); int const minw = (w < 0) ? 3 * arrow_size : 4; @@ -261,7 +261,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const { Dimension const dim = dimension(*pi.base.bv); - if (isStretchableSpace() || params_.length.len().value() < 0) { + if (isHfill() || params_.length.len().value() < 0) { int const asc = theFontMetrics(pi.base.font).ascent('M'); int const desc = theFontMetrics(pi.base.font).descent('M'); // Pixel height divisible by 2 for prettier fill graphics: @@ -453,7 +453,7 @@ void InsetSpaceParams::write(ostream & os) const os << "\\hspace*{}"; break; } - + if (!length.len().empty()) os << "\n\\length " << length.asString(); } @@ -827,7 +827,7 @@ void InsetSpace::forToc(docstring & os, size_t) const } -bool InsetSpace::isStretchableSpace() const +bool InsetSpace::isHfill() const { return params_.kind == InsetSpaceParams::HFILL || params_.kind == InsetSpaceParams::HFILL_PROTECTED diff --git a/src/insets/InsetSpace.h b/src/insets/InsetSpace.h index 7e32dc7..9f6fc68 100644 --- a/src/insets/InsetSpace.h +++ b/src/insets/InsetSpace.h @@ -140,9 +140,8 @@ public: bool hasSettings() const { return true; } /// InsetCode lyxCode() const { return SPACE_CODE; } - /// is this an expandible space (rubber length)? - bool isStretchableSpace() const; - + /// does this inset try to use all available space (like \\hfill does)? + bool isHfill() const; /// should this inset be handled like a normal character? bool isChar() const { return true; } /// is this equivalent to a letter? ----------------------------------------------------------------------- Summary of changes: src/Paragraph.cpp | 3 +-- src/TextMetrics.cpp | 3 +-- src/insets/Inset.h | 4 ++-- src/insets/InsetIPAMacro.cpp | 12 ------------ src/insets/InsetIPAMacro.h | 4 +--- src/insets/InsetSpace.cpp | 12 ++++++------ src/insets/InsetSpace.h | 5 ++--- 7 files changed, 13 insertions(+), 30 deletions(-) hooks/post-receive -- Repository for new features