]> git.lyx.org Git - features.git/commitdiff
Show properly on screen "indented" maths.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 11 Apr 2017 11:03:34 +0000 (13:03 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 3 May 2017 12:46:05 +0000 (14:46 +0200)
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.

src/TextMetrics.cpp
src/insets/Inset.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h

index c577b47c400b50698a163a1a9ef1bec577c720df..52cbcef50c184479b1c6b268d41c4ac77b1d587a 100644 (file)
@@ -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:
index 3d93904fdb3b07ffc9a7f4b28f030f2597f79d0f..9ba894513c8034f31e34c03d34c209bfb4c1af15 100644 (file)
@@ -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?
index 38cdd26427ee63c5b34adcfbb5c7cdbabd7e4088..3e897df0e1724581202f689b91e7af31d6fb9b68 100644 (file)
@@ -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_) {
index bae26530c3c5ac824da884cef448f3fff1aa7042..1b3eef3410676475dd514272231696b1fe20c77a 100644 (file)
@@ -294,6 +294,8 @@ public:
        Inset * editXY(Cursor & cur, int x, int y);
        ///
        DisplayType display() const;
+       ///
+       int indent(BufferView const &) const;
 
 protected:
        ///