]> git.lyx.org Git - lyx.git/commitdiff
Revert "Use new display() values to remove some inset hardcoding."
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 12 Sep 2018 13:26:15 +0000 (15:26 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 12 Sep 2018 13:26:15 +0000 (15:26 +0200)
This is a work in progress that committed by mistake.

This reverts commit b28ec44476d3f2c5858d06596ed5bd975012ec33.

22 files changed:
src/TextMetrics.cpp
src/insets/Inset.h
src/insets/InsetBibtex.h
src/insets/InsetBox.h
src/insets/InsetCaption.h
src/insets/InsetFloatList.h
src/insets/InsetInclude.cpp
src/insets/InsetIndex.h
src/insets/InsetListings.cpp
src/insets/InsetNewline.h
src/insets/InsetNewpage.h
src/insets/InsetNomencl.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetRef.h
src/insets/InsetScript.cpp
src/insets/InsetScript.h
src/insets/InsetSeparator.h
src/insets/InsetTOC.h
src/insets/InsetTabular.cpp
src/insets/InsetVSpace.h
src/mathed/InsetMathHull.cpp

index 4661b76fdbb377c2fa52c5d195f23eab10d02eed..2b0903c750d23f1398d462db0ddb8e8956300eb5 100644 (file)
@@ -557,13 +557,19 @@ LyXAlignment TextMetrics::getAlign(Paragraph const & par, Row const & row) const
 
        // Display-style insets should always be on a centered row
        if (Inset const * inset = par.getInset(row.pos())) {
-               if (inset->display() & Inset::Display) {
-                       if (inset->display() & Inset::AlignLeft)
-                               align = LYX_ALIGN_BLOCK;
-                       else if (inset->display() & Inset::AlignRight)
-                               align = LYX_ALIGN_RIGHT;
-                       else
-                               align = LYX_ALIGN_CENTER;
+               switch (inset->display()) {
+               case Inset::AlignLeft:
+                       align = LYX_ALIGN_BLOCK;
+                       break;
+               case Inset::AlignCenter:
+                       align = LYX_ALIGN_CENTER;
+                       break;
+               case Inset::Inline:
+                       // unchanged (use align)
+                       break;
+               case Inset::AlignRight:
+                       align = LYX_ALIGN_RIGHT;
+                       break;
                }
        }
 
@@ -914,12 +920,15 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
                }
 
                // Handle some situations that abruptly terminate the row
-               // - Before an inset with BreakBefore
-               // - After an inset with BreakAfter
-               Inset const * prevInset = !row.empty() ? row.back().inset : 0;
-               Inset const * nextInset = (i + 1 < end) ? par.getInset(i + 1) : 0;
-               if ((nextInset && nextInset->display() & Inset::BreakBefore)
-                   || (prevInset && prevInset->display() & Inset::BreakAfter)) {
+               // - A newline inset
+               // - Before a display inset
+               // - After a display inset
+               Inset const * inset = 0;
+               if (par.isNewline(i) || par.isEnvSeparator(i)
+                   || (i + 1 < end && (inset = par.getInset(i + 1))
+                       && inset->display())
+                   || (!row.empty() && row.back().inset
+                       && row.back().inset->display())) {
                        row.flushed(true);
                        need_new_row = par.isNewline(i);
                        ++i;
@@ -1744,7 +1753,7 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
            // display style insets are always centered, omit indentation
            && !(!par.empty()
                 && par.isInset(pos)
-                && par.getInset(pos)->display() & Inset::Display)
+                && par.getInset(pos)->display())
            && (!(tclass.isDefaultLayout(par.layout())
                || tclass.isPlainLayout(par.layout()))
                || buffer.params().paragraph_separation
index 302c958a1eb756bec50013a1047e514564904dd2..0f76671ea821a709f684467af6906298351a41fa 100644 (file)
@@ -467,26 +467,14 @@ public:
        /// does this inset try to use all available space (like \\hfill does)?
        virtual bool isHfill() const { return false; }
 
-       // Describe how the inset should be typeset
        enum DisplayType {
                Inline = 0,
-               // break row before this inset
-               BreakBefore = 1,
-               // break row after this inset
-               BreakAfter = 2,
-               // optionally break row after this inset (not used yet)
-               CanBreakAfter = 4,
-               // specify an alignment (left, right) for a display inset (default is center)
-               AlignLeft = 8,
-               AlignRight = 16,
-               // do not allow cursor to go at the end of the row before
-               // a display inset (not used yet)
-               NoBoundary = 32,
-               // A display inset breaks row at both ends
-               Display = BreakBefore | BreakAfter
+               AlignLeft,
+               AlignCenter,
+               AlignRight
        };
 
-       /// How should this inset be typeset?
+       /// 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; }
@@ -646,21 +634,6 @@ protected:
        Buffer * buffer_;
 };
 
-
-inline Inset::DisplayType operator|(Inset::DisplayType const d1,
-                                    Inset::DisplayType const d2)
-{
-       return static_cast<Inset::DisplayType>(int(d1) | int(d2));
-}
-
-
-inline Inset::DisplayType operator&(Inset::DisplayType const d1,
-                                    Inset::DisplayType const d2)
-{
-       return static_cast<Inset::DisplayType>(int(d1) & int(d2));
-}
-
-
 } // namespace lyx
 
 #endif
index c618574a4735ec98380152e435f7f6f0dec3daa0..f2b8dd15763a141ffaebd810b6cf5c00273372aa 100644 (file)
@@ -48,7 +48,7 @@ public:
        ///
        InsetCode lyxCode() const { return BIBTEX_CODE; }
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
index 04c57707af61eb7e9835a254ffaffd1b5f3b18cc..e181bd738a229df472781879f480e84849727c7f 100644 (file)
@@ -111,6 +111,8 @@ public:
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
+       DisplayType display() const { return Inline; }
+       ///
        ColorCode backgroundColor(PainterInfo const &) const;
        ///
        LyXAlignment contentAlignment() const;
index 1d3cac1bb956946a5dad467de74bcc368602e563..92dc9405c28e71691df4328e55c3078b3d226126 100644 (file)
@@ -38,7 +38,7 @@ private:
        ///
        void write(std::ostream & os) const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        bool neverIndent() const { return true; }
        ///
index 8c2a57128f4f2eb2e354ef5898ce34edb9da6398..3d6a7a356905d0f7530fc5bd2c5e60bfae198924 100644 (file)
@@ -32,7 +32,7 @@ public:
        ///
        InsetCode lyxCode() const { return FLOAT_LIST_CODE; }
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void write(std::ostream &) const;
        ///
index d6936c837e6f3668ea279d3c78056aacfde06cd9..2d91f62bd21fed19cf54b8d13600fb9690f3e60c 100644 (file)
@@ -1159,7 +1159,7 @@ string InsetInclude::contextMenuName() const
 
 Inset::DisplayType InsetInclude::display() const
 {
-       return type(params()) == INPUT ? Inline : Display;
+       return type(params()) == INPUT ? Inline : AlignCenter;
 }
 
 
index 8dc14b967cdc670d2ed2c3c0b55d83eab347f412..01bf7096b08b5d0b8f074b92103df8f2d2eb53e2 100644 (file)
@@ -119,7 +119,7 @@ public:
        ///
        bool hasSettings() const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived classes
index 1b1debb18d46bb17f1da4ae5c88d909c4fb48d75..ec9ad7225f37254683f45ba25fcc7fa4851d2c7a 100644 (file)
@@ -68,7 +68,7 @@ InsetListings::~InsetListings()
 
 Inset::DisplayType InsetListings::display() const
 {
-       return params().isInline() || params().isFloat() ? Inline : Display | AlignLeft;
+       return params().isInline() || params().isFloat() ? Inline : AlignLeft;
 }
 
 
index a2848a1e31efdb40b700b300001bf0db322d923f..2dc9c553ed70930e03c8d9fbefb1fc4a267d1446 100644 (file)
@@ -47,8 +47,6 @@ public:
        InsetNewline(InsetNewlineParams par) : Inset(0)
        { params_.kind = par.kind; }
        ///
-       DisplayType display() const { return BreakAfter | NoBoundary; }
-       ///
        static void string2params(std::string const &, InsetNewlineParams &);
        ///
        static std::string params2string(InsetNewlineParams const &);
index 51142d0e2dfffd2f1c94c51fbdcf13b15b998ef5..51f640a09700b1483b1feb8fe2f4fb939bf89e3e 100644 (file)
@@ -76,7 +76,7 @@ private:
        ///
        void write(std::ostream & os) const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        docstring insetLabel() const;
        ///
index b5a4e9315c64f087432b94f66bcb7df7f8d2cd9b..4d11a47d793c0bfd7f99f442558440dc300053d0 100644 (file)
@@ -100,7 +100,7 @@ public:
        ///
        bool hasSettings() const { return true; }
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
index 920ebd82b71a3be389bcc04ba430aa0fddeec4fa..02f47ba30e78075cc6385168b9ea902bdd778d5e 100644 (file)
@@ -116,6 +116,12 @@ docstring InsetNote::layoutName() const
 }
 
 
+Inset::DisplayType InsetNote::display() const
+{
+       return Inline;
+}
+
+
 void InsetNote::write(ostream & os) const
 {
        params_.write(os);
index 5c99df19092913f5fd499f928245dab99501ad5a..9df1a501a29c75ba12c7ebc3c8f13517f7f4d3c4 100644 (file)
@@ -61,6 +61,8 @@ private:
        InsetCode lyxCode() const { return NOTE_CODE; }
        ///
        docstring layoutName() const;
+       ///
+       DisplayType display() const;
        /** returns false if, when outputing LaTeX, font changes should
            be closed before generating this inset. This is needed for
            insets that may contain several paragraphs */
index c42aa1fa7284f537b22d5737cc03390243705525..0f5a5b201d87983b5cd66d64dd3073240124a965 100644 (file)
@@ -49,12 +49,14 @@ public:
        docstring toolTip(BufferView const &, int, int) const
                { return tooltip_; }
        ///
-       docstring getTOCString() const;
+  docstring getTOCString() const;
        ///
        bool hasSettings() const { return true; }
        ///
        InsetCode lyxCode() const { return REF_CODE; }
        ///
+       DisplayType display() const { return Inline; }
+       ///
        void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstringstream & ods, OutputParams const & op,
index 8057962d9bfee7b5b1167645e843e68010b942f1..918492fb55493041b31edd34a5b00e0f5b092fd4 100644 (file)
@@ -151,6 +151,12 @@ docstring InsetScript::layoutName() const
 }
 
 
+Inset::DisplayType InsetScript::display() const
+{
+       return Inline;
+}
+
+
 void InsetScript::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        int const shift = params_.shift(mi.base.font);
index 0b755aa118e83031a63898ec80ca47afaaffea6b..3107b6255dd24c28a837bd42dc5f7d463f875204 100644 (file)
@@ -67,6 +67,8 @@ public:
        ///
        docstring layoutName() const;
        ///
+       DisplayType display() const;
+       ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
index 4d53b956c2b75561da47b0d42860c3e812501e52..5d080ccae6c32d5c3576186a1cc221e357f9d119 100644 (file)
@@ -64,8 +64,6 @@ public:
                // remove warning
                return docstring();
        }
-       ///
-       DisplayType display() const { return BreakAfter | NoBoundary; }
 private:
        ///
        InsetSeparatorParams params() const { return params_; }
index 29d5e91e76d4c2fc76ccbb748fd6218c523d8c8c..4d48c3220f5ce40acf031689966539ca7290e3c0 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        docstring layoutName() const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        virtual void validate(LaTeXFeatures &) const;
        ///
index 0680d93be8a7e60702400c2ee8030d602b82a926..324987c8a445e6474f0b61d8a370b5e59e3c4e15 100644 (file)
@@ -5396,13 +5396,13 @@ Inset::DisplayType InsetTabular::display() const
                if (tabular.is_long_tabular) {
                        switch (tabular.longtabular_alignment) {
                        case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
-                               return Display | AlignLeft;
+                               return AlignLeft;
                        case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
-                               return Display;
+                               return AlignCenter;
                        case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
-                               return Display | AlignRight;
+                               return AlignRight;
                        default:
-                               return Display;
+                               return AlignCenter;
                        }
                } else
                        return Inline;
index 42d76bc9971a73df6f47c6a2018d4bbfd0923955..21afbcd03605392a1f999bf0e46fc4a9c656d570 100644 (file)
@@ -62,7 +62,7 @@ private:
        ///
        void write(std::ostream & os) const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
index 1c40a72e0f6542044db00e69435f80fb489d1d73..dffef8473132b179c5c369f246800d78a1a6ea6b 100644 (file)
@@ -540,7 +540,7 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
                        // insert a gap in front of the formula
                        // value was hardcoded to 1 pixel
                        dim.wid += mi.base.bv->zoomedPixels(1) ;
-                       if (display() != Inline) {
+                       if (display()) {
                                dim.asc += display_margin;
                                dim.des += display_margin;
                        }
@@ -549,13 +549,13 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
        }
 
        Changer dummy1 = mi.base.changeFontSet(standardFont());
-       Changer dummy2 = mi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
+       Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY
                                                            : LM_ST_TEXT);
 
        // let the cells adjust themselves
        InsetMathGrid::metrics(mi, dim);
 
-       if (display() != Inline) {
+       if (display()) {
                dim.asc += display_margin;
                dim.des += display_margin;
        }
@@ -653,7 +653,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
        Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
                : Changer();
        Changer dummy1 = pi.base.changeFontSet(standardFont());
-       Changer dummy2 = pi.base.font.changeStyle(display() != Inline ? LM_ST_DISPLAY
+       Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY
                                                            : LM_ST_TEXT);
 
        int xmath = x;
@@ -695,7 +695,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
 {
-       if (display() != Inline) {
+       if (display()) {
                InsetMathGrid::metricsT(mi, dim);
        } else {
                odocstringstream os;
@@ -711,7 +711,7 @@ void InsetMathHull::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
 
 void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
 {
-       if (display() != Inline) {
+       if (display()) {
                InsetMathGrid::drawT(pain, x, y);
        } else {
                odocstringstream os;
@@ -1022,12 +1022,12 @@ Inset::DisplayType InsetMathHull::display() const
        case hullMultline:
        case hullGather:
                if (buffer().params().is_math_indent)
-                       return Display | AlignLeft;
+                       return AlignLeft;
                else
-                       return Display;
+                       return AlignCenter;
        }
        // avoid warning
-       return Display;
+       return AlignCenter;
 }
 
 
@@ -2324,7 +2324,7 @@ int InsetMathHull::plaintext(odocstringstream & os,
         OutputParams const & op, size_t max_length) const
 {
        // Try enabling this now that there is a flag as requested at #2275.
-       if (buffer().isExporting() && display() != Inline) {
+       if (buffer().isExporting() && display()) {
                Dimension dim;
                TextMetricsInfo mi;
                metricsT(mi, dim);