mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Show properly on screen "indented" maths.
This is done by two things: 1/ the equation returns LefAlign as display() value 2/ Inset::indent() return a value (in general 0) that should be added on the left (or right in rtl) of the inset when it is flushed. The code that uses these values is in TextMetrics::computeRowMetrics.
This commit is contained in:
parent
5ef057b42e
commit
fa2dcd37a2
@ -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:
|
||||
|
@ -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?
|
||||
|
@ -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_) {
|
||||
|
@ -294,6 +294,8 @@ public:
|
||||
Inset * editXY(Cursor & cur, int x, int y);
|
||||
///
|
||||
DisplayType display() const;
|
||||
///
|
||||
int indent(BufferView const &) const;
|
||||
|
||||
protected:
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user