diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index c577b47c40..52cbcef50c 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -627,15 +627,25 @@ void TextMetrics::computeRowMetrics(Row & row, int width) const row.dimension().wid += w; } break; + case LYX_ALIGN_LEFT: + // a displayed inset that is flushed + if (Inset const * inset = par.getInset(row.pos())) + row.left_margin += inset->indent(*bv_); + break; case LYX_ALIGN_RIGHT: - row.left_margin += w; - row.dimension().wid += w; + if (Inset const * inset = par.getInset(row.pos())) { + int const new_w = max(w - inset->indent(*bv_), 0); + row.left_margin += new_w; + row.dimension().wid += new_w; + } else { + row.left_margin += w; + row.dimension().wid += w; + } break; case LYX_ALIGN_CENTER: row.dimension().wid += w / 2; row.left_margin += w / 2; break; - case LYX_ALIGN_LEFT: case LYX_ALIGN_NONE: case LYX_ALIGN_LAYOUT: case LYX_ALIGN_SPECIAL: diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 3d93904fdb..9ba894513c 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -460,6 +460,8 @@ public: /// should we have a non-filled line before this inset? virtual DisplayType display() const { return Inline; } + /// indentation before this inset (only needed for displayed hull insets with fleqn option) + virtual int indent(BufferView const &) const { return 0; } /// virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; } /// should we break lines after this inset? diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 38cdd26427..3e897df0e1 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -993,12 +993,31 @@ Inset::DisplayType InsetMathHull::display() const case hullEquation: case hullMultline: case hullGather: - return AlignCenter; + if (buffer().params().is_math_indent) + return AlignLeft; + else + return AlignCenter; } // avoid warning return AlignCenter; } + +int InsetMathHull::indent(BufferView const & bv) const +{ + // FIXME: set this in the textclass. This value is what the article class uses. + static Length default_indent(2.5, Length::EM); + if (buffer().params().is_math_indent) { + Length const & len = buffer().params().getMathIndent(); + if (len.empty()) + return bv.inPixels(default_indent); + else + return bv.inPixels(len); + } else + return Inset::indent(bv); +} + + bool InsetMathHull::numberedType() const { switch (type_) { diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index bae26530c3..1b3eef3410 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -294,6 +294,8 @@ public: Inset * editXY(Cursor & cur, int x, int y); /// DisplayType display() const; + /// + int indent(BufferView const &) const; protected: ///