]> git.lyx.org Git - lyx.git/commitdiff
Revert "Fix display of a math hull inset in a tight inset"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Mar 2024 14:08:26 +0000 (15:08 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Mar 2024 14:08:26 +0000 (15:08 +0100)
This commit will be replaed by a better solution.

Part of ticket #12320.

This reverts commit 4bbd4a45e7494363903801540102150886fa2c6b.

src/MetricsInfo.cpp
src/MetricsInfo.h
src/Row.cpp
src/RowPainter.cpp
src/TextMetrics.cpp
src/mathed/InsetMathHull.cpp

index 844c1c13f392ca51ab5fc5306453f95dd09e2313..d663c9a77d29ebaa0431057f016667b02b0ab87e 100644 (file)
@@ -152,8 +152,7 @@ int MetricsBase::inPixels(Length const & len) const
 
 MetricsInfo::MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
                          MacroContext const & mc, bool vm, bool tight)
-       : base(bv, font, textwidth), macrocontext(mc), vmode(vm), tight_insets(tight),
-         extrawidth(0)
+       : base(bv, font, textwidth), macrocontext(mc), vmode(vm), tight_insets(tight)
 {}
 
 
index 6f1d404822f2fca5d268a9fa7c388d3422e17d3f..176eabfea839edde13fc52d430a0491de5145a3d 100644 (file)
@@ -109,8 +109,6 @@ public:
        bool vmode;
        /// if true, do not expand insets to max width artificially
        bool tight_insets;
-       /// Extra width required by an inset, in addition to its dimension
-       int extrawidth;
 };
 
 
index 86b4e5014ca80dd69a4f63c8eb459f161107c242..b85ef3d18b05bfb853efe9ddd911c33ac9dcec89 100644 (file)
@@ -510,15 +510,14 @@ void Row::addMarginSpace(pos_type const pos, int const width,
 
 void Row::push_back(Row::Element const & e)
 {
-       dim_.wid += e.dim.wid + ((e.type == INSET) ? e.extra : 0);
+       dim_.wid += e.dim.wid;
        elements_.push_back(e);
 }
 
 
 void Row::pop_back()
 {
-       Element const & e = elements_.back();
-       dim_.wid -= e.dim.wid + ((e.type == INSET) ? e.extra : 0);
+       dim_.wid -= elements_.back().dim.wid;
        elements_.pop_back();
 }
 
index d893fd01eb7736e6a99e4aa17e540efbb5cbcace..77e0ff67e61a005f33a11e7b21c43bf735733226 100644 (file)
@@ -100,7 +100,6 @@ void RowPainter::paintInset(Row::Element const & e) const
        bool const pi_full_repaint = pi_.full_repaint;
        bool const pi_do_spellcheck = pi_.do_spellcheck;
        Change const pi_change = pi_.change;
-       int const pi_textwidth = pi_.base.textwidth;
 
        pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
                pi_.base.bv->buffer().params().getFont().fontInfo();
@@ -108,7 +107,6 @@ void RowPainter::paintInset(Row::Element const & e) const
        pi_.ltr_pos = !e.font.isVisibleRightToLeft();
        pi_.change = pi_.change.changed() ? pi_.change : e.change;
        pi_.do_spellcheck &= e.inset->allowSpellCheck();
-       pi_.base.textwidth += e.extra;
 
        int const x1 = int(x_);
        pi_.base.bv->coordCache().insets().add(e.inset, x1, yo_);
@@ -125,7 +123,6 @@ void RowPainter::paintInset(Row::Element const & e) const
        pi_.change = pi_change;
        pi_.do_spellcheck = pi_do_spellcheck;
        pi_.selected = pi_selected;
-       pi_.base.textwidth = pi_textwidth;
 
 #ifdef DEBUG_METRICS
        Dimension const & dim = pi_.base.bv->coordCache().insets().dim(e.inset);
@@ -559,8 +556,7 @@ void RowPainter::paintOnlyInsets()
                                paintChange(e);
                }
 
-               // extra is the extrawidth band-aid described in redoParagraphs
-               x_ +=  e.full_width() + ((e.type == Row::INSET) ? e.extra : 0);
+               x_ += e.full_width();
        }
 }
 
@@ -595,8 +591,7 @@ void RowPainter::paintText()
                if (e.type != Row::INSET || ! e.inset->canPaintChange(*pi_.base.bv))
                        paintChange(e);
 
-               // extra is the extrawidth band-aid described in redoParagraphs
-               x_ +=  e.full_width() + ((e.type == Row::INSET) ? e.extra : 0);
+               x_ += e.full_width();
        }
 }
 
index 32768970bb66a2acd5275bc8dabc37257ebc6e41..4692918e8ef2175f68b5f0f8cec16c18790bf342 100644 (file)
@@ -485,7 +485,6 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
        par.setBeginOfBody();
        Font const bufferfont = buffer.params().getFont();
        CoordCache::Insets & insetCache = bv_->coordCache().insets();
-       map <Inset const *, int> extrawidths;
        for (auto const & e : par.insetList()) {
                // FIXME Doesn't this HAVE to be non-empty?
                // position already initialized?
@@ -522,17 +521,6 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
                MetricsInfo mi(bv_, font.fontInfo(), w, mc, e.pos == 0, tight_);
                mi.base.outer_font = displayFont(pit, e.pos).fontInfo();
                e.inset->metrics(mi, dim);
-               /* FIXME: This is a kind of hack. This allows InsetMathHull to
-                * state that it needs some elbow room beyond its width, in
-                * order to fit the numbering and/or the left margin (with
-                * left alignment), which are outside of the inset itself.
-                *
-                * To this end, InsetMathHull::metrics() sets a value in
-                * MetricsInfo::extrawidth and this value is recorded later in
-                * the corresponding row element's `extra' field. See ticket
-                * #12320 for details.
-               */
-               extrawidths[e.inset] = mi.extrawidth;
                if (!insetCache.has(e.inset) || insetCache.dim(e.inset) != dim) {
                        insetCache.add(e.inset, dim);
                        changed = true;
@@ -540,11 +528,7 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
        }
 
        // Transform the paragraph into a single row containing all the elements.
-       Row bigrow = tokenizeParagraph(pit);
-       // Add the needed extra width to the row elements of the insets
-       for (auto & e : bigrow)
-               if (e.type == Row::INSET)
-                       e.extra = extrawidths[e.inset];
+       Row const bigrow = tokenizeParagraph(pit);
        // Split the row in several rows fitting in available width
        pm.rows() = breakParagraph(bigrow);
 
index 94d293870d6911365b13c9395d798e864df1306a..30ec93a14fc991708e0f3f8ef9ebfda19cde40a7 100644 (file)
@@ -523,9 +523,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
        if (mi.vmode)
                top_display_margin += theFontMetrics(mi.base.font).maxHeight() + 2;
 
-       int const ind = indent(*mi.base.bv);
-       mi.extrawidth = ind;
-
        if (previewState(mi.base.bv)) {
                preview_->metrics(mi, dim);
                if (previewTooSmall(dim)) {
@@ -557,7 +554,6 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
        if (numberedType()) {
                BufferParams::MathNumber const math_number = buffer().params().getMathNumber();
                int extra_offset = 0;
-               int max_nlwid = 0;
                for (row_type row = 0; row < nrows(); ++row) {
                        rowinfo(row).offset[mi.base.bv] += extra_offset;
                        docstring const nl = nicelabel(row);
@@ -565,6 +561,7 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
                                continue;
                        Dimension dimnl;
                        mathed_string_dim(mi.base.font, nl, dimnl);
+                       int const ind = indent(*mi.base.bv);
                        int const x = ind ? ind : (mi.base.textwidth - dim.wid) / 2;
                        // for some reason metrics does not trigger at the
                        // same point as draw, and therefore we use >= instead of >
@@ -572,10 +569,8 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
                            || (math_number == BufferParams::RIGHT
                                && dimnl.wid >= mi.base.textwidth - x - dim.wid)) {
                                extra_offset += dimnl.height();
-                       } else if (dimnl.wid > max_nlwid)
-                               max_nlwid = dimnl.wid;
+                       }
                }
-               mi.extrawidth += max_nlwid;
                dim.des += extra_offset;
        }