The branch, betterpaint, has been updated.

- Log -----------------------------------------------------------------

commit 5c78d680835a6f331c2e1ca954d451aee61f4a29
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Fri Apr 8 16:25:34 2016 +0200

    Revert "Use new display() values to remove some inset hardcoding."
    
    This reverts commit 9b9b4c6c86bd0c7a49299f9b667cf8069f37b08d.
    
    This code does not really belong in this branch, it is better to give it 
its own branch.

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 0541f48..3d7251c 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -514,13 +514,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;
                }
        }
 
@@ -856,12 +862,15 @@ bool TextMetrics::breakRow(Row & row, int const 
right_margin, pit_type const pit
                }
 
                // 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.right_boundary(true);
                        need_new_row = par.isNewline(i);
                        ++i;
@@ -1742,23 +1751,23 @@ int TextMetrics::leftMargin(int max_width,
        // set the correct parindent
        if (pos == 0
            && (layout.labeltype == LABEL_NO_LABEL
-               || layout.labeltype == LABEL_ABOVE
-               || layout.labeltype == LABEL_CENTERED
-               || (layout.labeltype == LABEL_STATIC
-                   && layout.latextype == LATEX_ENVIRONMENT
-                   && !text_->isFirstInSequence(pit)))
+               || layout.labeltype == LABEL_ABOVE
+               || layout.labeltype == LABEL_CENTERED
+               || (layout.labeltype == LABEL_STATIC
+                   && layout.latextype == LATEX_ENVIRONMENT
+                   && !text_->isFirstInSequence(pit)))
            && (align == LYX_ALIGN_BLOCK || align == LYX_ALIGN_LEFT)
            && !par.params().noindent()
            // in some insets, paragraphs are never indented
            && !text_->inset().neverIndent()
            // display style insets are always centered, omit indentation
            && !(!par.empty()
-                && par.isInset(pos)
-                && par.getInset(pos)->display() & Inset::Display)
+                && par.isInset(pos)
+                && par.getInset(pos)->display())
            && (!(tclass.isDefaultLayout(par.layout())
-                 || tclass.isPlainLayout(par.layout()))
+                 || tclass.isPlainLayout(par.layout()))
                || buffer.params().paragraph_separation
-                   == BufferParams::ParagraphIndentSeparation)) {
+                               == BufferParams::ParagraphIndentSeparation)) {
                        // use the parindent of the layout when the
                        // default indentation is used otherwise use
                        // the indentation set in the document
diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 4221b1c..96071fa 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -438,26 +438,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; }
        ///
        virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; }
@@ -607,21 +595,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
diff --git a/src/insets/InsetBibtex.h b/src/insets/InsetBibtex.h
index 21d744a..a4310ad 100644
--- a/src/insets/InsetBibtex.h
+++ b/src/insets/InsetBibtex.h
@@ -50,7 +50,7 @@ public:
        ///
        InsetCode lyxCode() const { return BIBTEX_CODE; }
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h
index fe964c9..151d622 100644
--- a/src/insets/InsetBox.h
+++ b/src/insets/InsetBox.h
@@ -111,6 +111,8 @@ public:
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
+       DisplayType display() const { return Inline; }
+       ///
        ColorCode backgroundColor(PainterInfo const &) const;
        ///
        LyXAlignment contentAlignment() const;
diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h
index a1d6004..1d8775e 100644
--- a/src/insets/InsetCaption.h
+++ b/src/insets/InsetCaption.h
@@ -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; }
        ///
diff --git a/src/insets/InsetFloatList.h b/src/insets/InsetFloatList.h
index 55153a8..58a7e23 100644
--- a/src/insets/InsetFloatList.h
+++ b/src/insets/InsetFloatList.h
@@ -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;
        ///
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 52fc338..e9b9600 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1044,7 +1044,7 @@ string InsetInclude::contextMenuName() const
 
 Inset::DisplayType InsetInclude::display() const
 {
-       return type(params()) == INPUT ? Inline : Display;
+       return type(params()) == INPUT ? Inline : AlignCenter;
 }
 
 
diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h
index 3ee741e..b1aa9b4 100644
--- a/src/insets/InsetIndex.h
+++ b/src/insets/InsetIndex.h
@@ -115,7 +115,7 @@ public:
        ///
        bool hasSettings() const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived 
classes
diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp
index 55f4b66..91125d8 100644
--- a/src/insets/InsetListings.cpp
+++ b/src/insets/InsetListings.cpp
@@ -65,7 +65,7 @@ InsetListings::~InsetListings()
 
 Inset::DisplayType InsetListings::display() const
 {
-       return params().isInline() || params().isFloat() ? Inline : Display | 
AlignLeft;
+       return params().isInline() || params().isFloat() ? Inline : AlignLeft;
 }
 
 
diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h
index a2848a1..2dc9c55 100644
--- a/src/insets/InsetNewline.h
+++ b/src/insets/InsetNewline.h
@@ -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 &);
diff --git a/src/insets/InsetNewpage.h b/src/insets/InsetNewpage.h
index 51142d0..51f640a 100644
--- a/src/insets/InsetNewpage.h
+++ b/src/insets/InsetNewpage.h
@@ -76,7 +76,7 @@ private:
        ///
        void write(std::ostream & os) const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        docstring insetLabel() const;
        ///
diff --git a/src/insets/InsetNomencl.h b/src/insets/InsetNomencl.h
index 65c6da6..14507b6 100644
--- a/src/insets/InsetNomencl.h
+++ b/src/insets/InsetNomencl.h
@@ -97,7 +97,7 @@ public:
        ///
        bool hasSettings() const { return true; }
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp
index d189bca..e483cf2 100644
--- a/src/insets/InsetNote.cpp
+++ b/src/insets/InsetNote.cpp
@@ -118,6 +118,12 @@ docstring InsetNote::layoutName() const
 }
 
 
+Inset::DisplayType InsetNote::display() const
+{
+       return Inline;
+}
+
+
 void InsetNote::write(ostream & os) const
 {
        params_.write(os);
diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h
index d0dd4b7..c80d61b 100644
--- a/src/insets/InsetNote.h
+++ b/src/insets/InsetNote.h
@@ -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 */
diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h
index 6f09dfd..f885423 100644
--- a/src/insets/InsetRef.h
+++ b/src/insets/InsetRef.h
@@ -45,12 +45,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,
diff --git a/src/insets/InsetScript.cpp b/src/insets/InsetScript.cpp
index e1eb5fc..f8aae1e 100644
--- a/src/insets/InsetScript.cpp
+++ b/src/insets/InsetScript.cpp
@@ -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);
diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h
index 421b593..decfee3 100644
--- a/src/insets/InsetScript.h
+++ b/src/insets/InsetScript.h
@@ -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;
diff --git a/src/insets/InsetSeparator.h b/src/insets/InsetSeparator.h
index e57bd91..2049c22 100644
--- a/src/insets/InsetSeparator.h
+++ b/src/insets/InsetSeparator.h
@@ -49,8 +49,6 @@ public:
        static void string2params(std::string const &, InsetSeparatorParams &);
        ///
        static std::string params2string(InsetSeparatorParams const &);
-       ///
-       DisplayType display() const { return BreakAfter | NoBoundary; }
 private:
        ///
        InsetSeparatorParams params() const { return params_; }
diff --git a/src/insets/InsetTOC.h b/src/insets/InsetTOC.h
index 458c3ce..074ad53 100644
--- a/src/insets/InsetTOC.h
+++ b/src/insets/InsetTOC.h
@@ -36,7 +36,7 @@ public:
        ///
        docstring layoutName() const;
        ///
-       DisplayType display() const { return Display; }
+       DisplayType display() const { return AlignCenter; }
        ///
        virtual void validate(LaTeXFeatures &) const;
        ///
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 48bccb5..fd35c11 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -5028,13 +5028,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;
diff --git a/src/insets/InsetVSpace.h b/src/insets/InsetVSpace.h
index 4a2bb9c..e94ebcd 100644
--- a/src/insets/InsetVSpace.h
+++ b/src/insets/InsetVSpace.h
@@ -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);
        ///
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index ef94ecf..a782751 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -448,7 +448,7 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & 
dim) const
                } else {
                        // insert a one pixel gap in front of the formula
                        dim.wid += 1;
-                       if (display() != Inline)
+                       if (display())
                                dim.des += displayMargin();
                }
                // Cache the inset dimension.
@@ -457,12 +457,12 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & 
dim) const
        }
 
        FontSetChanger dummy1(mi.base, standardFont());
-       StyleChanger dummy2(mi.base, display() != Inline ? LM_ST_DISPLAY : 
LM_ST_TEXT);
+       StyleChanger dummy2(mi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
 
        // let the cells adjust themselves
        InsetMathGrid::metrics(mi, dim);
 
-       if (display() != Inline) {
+       if (display()) {
                dim.asc += displayMargin();
                dim.des += displayMargin();
        }
@@ -551,7 +551,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
        bool const really_change_color = pi.base.font.color() == Color_none;
        ColorChanger dummy0(pi.base.font, color, really_change_color);
        FontSetChanger dummy1(pi.base, standardFont());
-       StyleChanger dummy2(pi.base, display() != Inline ? LM_ST_DISPLAY : 
LM_ST_TEXT);
+       StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
 
        InsetMathGrid::draw(pi, x + 1, y);
 
@@ -570,7 +570,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;
@@ -587,7 +587,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;
@@ -865,7 +865,7 @@ Inset::DisplayType InsetMathHull::display() const
 {
        if (type_ == hullSimple || type_ == hullNone || type_ == hullRegexp)
                return Inline;
-       return Display;
+       return AlignCenter;
 }
 
 bool InsetMathHull::numberedType() const
@@ -2074,7 +2074,7 @@ int InsetMathHull::plaintext(odocstringstream & os,
         OutputParams const & op, size_t max_length) const
 {
        // disables ASCII-art for export of equations. See #2275.
-       if (0 && display() != Inline) {
+       if (0 && display()) {
                Dimension dim;
                TextMetricsInfo mi;
                metricsT(mi, dim);

-----------------------------------------------------------------------

Summary of changes:
 src/TextMetrics.cpp          |   53 ++++++++++++++++++++++++-----------------
 src/insets/Inset.h           |   35 +++------------------------
 src/insets/InsetBibtex.h     |    2 +-
 src/insets/InsetBox.h        |    2 +
 src/insets/InsetCaption.h    |    2 +-
 src/insets/InsetFloatList.h  |    2 +-
 src/insets/InsetInclude.cpp  |    2 +-
 src/insets/InsetIndex.h      |    2 +-
 src/insets/InsetListings.cpp |    2 +-
 src/insets/InsetNewline.h    |    2 -
 src/insets/InsetNewpage.h    |    2 +-
 src/insets/InsetNomencl.h    |    2 +-
 src/insets/InsetNote.cpp     |    6 ++++
 src/insets/InsetNote.h       |    2 +
 src/insets/InsetRef.h        |    4 ++-
 src/insets/InsetScript.cpp   |    6 ++++
 src/insets/InsetScript.h     |    2 +
 src/insets/InsetSeparator.h  |    2 -
 src/insets/InsetTOC.h        |    2 +-
 src/insets/InsetTabular.cpp  |    8 +++---
 src/insets/InsetVSpace.h     |    2 +-
 src/mathed/InsetMathHull.cpp |   16 ++++++------
 22 files changed, 78 insertions(+), 80 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to