]> git.lyx.org Git - features.git/commitdiff
Fix the display of column spacing in AMS environments
authorGuillaume Munch <gm@lyx.org>
Sun, 20 Dec 2015 20:56:34 +0000 (20:56 +0000)
committerUwe Stöhr <uwestoehr@lyx.org>
Tue, 19 Jan 2016 21:45:04 +0000 (22:45 +0100)
AMS align environment should have some spacing between odd and even columns.

Add a new virtual method displayColSpace() to InsetMathGrid, InsetMathHull and
InsetMathSplit.

src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathGrid.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h
src/mathed/InsetMathSplit.cpp
src/mathed/InsetMathSplit.h

index 00d9a6f20fbf2b2369a976d01edf49a00ef1b9a6..d8e5925b623cc4266c3a12016bc06384a5f3fee7 100644 (file)
@@ -486,7 +486,7 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
                colinfo_[col].offset_ =
                        colinfo_[col - 1].offset_ +
                        colinfo_[col - 1].width_ +
-                       colinfo_[col - 1].skip_ +
+                       displayColSpace(col - 1) +\r
                        colsep() +
                        colinfo_[col].lines_ * vlinesep();
        }
@@ -508,7 +508,7 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & dim) const
                        int const nextoffset =
                                colinfo_[first].offset_ +
                                wid +
-                               colinfo_[last].skip_ +
+                               displayColSpace(last) +\r
                                colsep() +
                                colinfo_[last+1].lines_ * vlinesep();
                        int const dx = nextoffset - colinfo_[last+1].offset_;
@@ -741,7 +741,7 @@ void InsetMathGrid::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
                colinfo_[col].offset_ =
                        colinfo_[col - 1].offset_ +
                        colinfo_[col - 1].width_ +
-                       colinfo_[col - 1].skip_ +
+                       displayColSpace(col - 1) +\r
                        1 ; //colsep() +
                        //colinfo_[col].lines_ * vlinesep();
        }
@@ -953,7 +953,7 @@ int InsetMathGrid::cellWidth(idx_type idx) const
                col_type c2 = c1 + ncellcols(idx);
                return colinfo_[c2].offset_
                        - colinfo_[c1].offset_
-                       - colinfo_[c2].skip_
+                       - displayColSpace(c2)\r
                        - colsep()
                        - colinfo_[c2].lines_ * vlinesep();
        }
@@ -1378,6 +1378,11 @@ char InsetMathGrid::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathGrid::displayColSpace(col_type col) const\r
+{\r
+       return colinfo_[col].skip_;\r
+}\r
+\r
 void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "*** InsetMathGrid: request: " << cmd << endl;
@@ -1862,5 +1867,32 @@ char InsetMathGrid::colAlign(HullType type, col_type col)
 }\r
 \r
 \r
+//static\r
+int InsetMathGrid::colSpace(HullType type, col_type col)\r
+{\r
+       int alignInterSpace;\r
+       switch (type) {\r
+       case hullEqnArray:\r
+               return 5;\r
+       \r
+       case hullAlign:\r
+               alignInterSpace = 20;\r
+               break;\r
+       case hullAlignAt:\r
+               alignInterSpace = 0;\r
+               break;\r
+       case hullXAlignAt:\r
+               alignInterSpace = 40;\r
+               break;\r
+       case hullXXAlignAt:\r
+       case hullFlAlign:\r
+               alignInterSpace = 60;\r
+               break;\r
+       default:\r
+               return 0;\r
+       }\r
+       return (col % 2) ? alignInterSpace : 0;\r
+}\r
+\r
 \r
 } // namespace lyx
index 6199b7dafc8fef516acaa7934f8e8298dab0ce79..e99431083eaad9703e35c9929831e94e1d1904d6 100644 (file)
@@ -261,8 +261,16 @@ protected:
        /// Column alignment for display of cell \p idx.\r
        /// Must not be written to file!
        virtual char displayColAlign(idx_type idx) const;
+       /// Column spacing for display of column \p col.\r
+       /// Must not be written to file!\r
+       virtual int displayColSpace(col_type col) const;\r
+\r
+       // The following two functions are used in InsetMathHull and\r
+       // InsetMathSplit.\r
        /// The value of a fixed col align for a certain hull type \r
        static char colAlign(HullType type, col_type col);\r
+       /// The value of a fixed col spacing for a certain hull type\r
+       static int colSpace(HullType type, col_type col);\r
 
        /// row info.
        /// rowinfo_[nrows()] is a dummy row used only for hlines.
index cce029f6cedf25f98b3f3293ac45ea8cb8476974..b6cf474d306791e43058187bf9b7bc775acd68a7 100644 (file)
@@ -382,6 +382,13 @@ char InsetMathHull::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathHull::displayColSpace(col_type col) const\r
+{\r
+       return colSpace(type_, col);\r
+}\r
+\r
+\r
+//FIXME: This has probably no effect and can be removed.\r
 int InsetMathHull::defaultColSpace(col_type col)
 {
        if (type_ == hullAlign || type_ == hullAlignAt)
index 9598ad4281d092497f92acbdb7053e8ed72540b5..084fff67c0590c7daf216c0ecf06b92bf45f06d6 100644 (file)
@@ -111,6 +111,8 @@ public:
        ///
        int defaultColSpace(col_type col);
        ///
+       int displayColSpace(col_type col) const;\r
+       ///\r
        char defaultColAlign(col_type col);
        ///
        char displayColAlign(idx_type idx) const;
index f85e664eefee0647053320b9329cb4c7cf387fe9..07e78f41a2472713b92225d576e4b459fc79171f 100644 (file)
@@ -83,6 +83,17 @@ char InsetMathSplit::displayColAlign(idx_type idx) const
 }\r
 \r
 \r
+int InsetMathSplit::displayColSpace(col_type col) const\r
+{\r
+       if (name_ == "split" || name_ == "aligned" || name_ == "align")\r
+               return colSpace(hullAlign, col);\r
+       if (name_ == "alignedat")\r
+               return colSpace(hullAlignAt, col);\r
+       return 0;\r
+}\r
+\r
+\r
+\r
 void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
 {
        InsetMathGrid::draw(pi, x, y);
index 6136b6faf6806aeb62f7020ed3d098d232018afc..0f47e38bf3e41d76b40d13e2c54f53d445f6047c 100644 (file)
@@ -41,6 +41,8 @@ public:
        ///
        int defaultColSpace(col_type) { return 0; }
        ///
+       int displayColSpace(col_type col) const;\r
+       ///\r
        char defaultColAlign(col_type);
        ///
        char displayColAlign(idx_type idx) const;\r