]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
avoid float-conversion warning and simplify size computation
[lyx.git] / src / TextMetrics.cpp
index f29202c668644dc6dada33af211f7fd25ac7435b..da9e404cb013813a1cd437f8165322426e13095b 100644 (file)
@@ -385,7 +385,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                Cursor & cur = const_cast<Cursor &>(bv_->cursor());
                // In some cases, we do not know how to record undo
                if (&cur.inset() == &text_->inset())
-                       cur.recordUndo(ATOMIC_UNDO, pit, pit);
+                       cur.recordUndo(pit, pit);
 
                int const moveCursor = par.fixBiblio(buffer);
 
@@ -446,7 +446,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                MacroContext mc(&buffer, parPos);
                MetricsInfo mi(bv_, font.fontInfo(), w, mc);
                ii->inset->metrics(mi, dim);
-               Dimension const old_dim = pm.insetDimension(ii->inset);
+               Dimension const old_dim = pm.insetDimension(ii->inset);
                if (old_dim != dim) {
                        pm.setInsetDimension(ii->inset, dim);
                        changed = true;
@@ -777,7 +777,7 @@ private:
 
 /** This is the function where the hard work is done. The code here is
  * very sensitive to small changes :) Note that part of the
- * intelligence is also in Row::shorten_if_needed
+ * intelligence is also in Row::shortenIfNeeded.
  */
 void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit) const
 {
@@ -900,12 +900,6 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
        // if the row is too large, try to cut at last separator.
        row.shortenIfNeeded(body_pos, width);
 
-       // if the row ends with a separator that is not at end of
-       // paragraph, remove it
-       if (!row.empty() && row.back().type == Row::SEPARATOR
-           && row.endpos() < par.size())
-               row.pop_back();
-
        // make sure that the RTL elements are in reverse ordering
        row.reverseRTL(text_->isRTL(par));
 }
@@ -1616,12 +1610,16 @@ int TextMetrics::leftMargin(int max_width,
        l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
                tclass.leftmargin());
 
-       if (par.getDepth() != 0) {
+       int depth = par.getDepth();
+       if (depth != 0) {
                // find the next level paragraph
                pit_type newpar = text_->outerHook(pit);
                if (newpar != pit_type(pars.size())) {
                        if (pars[newpar].layout().isEnvironment()) {
-                               l_margin = leftMargin(max_width, newpar);
+                               int nestmargin = depth * nestMargin();
+                               if (text_->isMainText())
+                                       nestmargin += changebarMargin();
+                               l_margin = max(leftMargin(max_width, newpar), nestmargin);
                                // Remove the parindent that has been added
                                // if the paragraph was empty.
                                if (pars[newpar].empty() &&
@@ -1736,7 +1734,7 @@ int TextMetrics::leftMargin(int max_width,
        }
 
        if (!par.params().leftIndent().zero())
-               l_margin += par.params().leftIndent().inPixels(max_width);
+               l_margin += par.params().leftIndent().inPixels(max_width, labelfont_metrics.em());
 
        LyXAlignment align;
 
@@ -1878,12 +1876,13 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                }
 
                // Row signature; has row changed since last paint?
-               row.setCrc(pm.computeRowSignature(row, bparams));
+               if (pi.pain.isDrawingEnabled())
+                       row.setCrc(pm.computeRowSignature(row, bparams));
                bool row_has_changed = row.changed()
                        || rowSlice == bv_->lastRowSlice();
 
                // Take this opportunity to spellcheck the row contents.
-               if (row_has_changed && lyxrc.spellcheck_continuously) {
+               if (row_has_changed && pi.do_spellcheck && lyxrc.spellcheck_continuously) {
                        text_->getPar(pit).spellCheck();
                }
 
@@ -1916,7 +1915,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                        LYXERR(Debug::PAINTING, foreword << "pit=" << pit << " row=" << i
                                << " row_selection="    << row.selection()
                                << " full_repaint="     << pi.full_repaint
-                               << " row_has_changed="  << row_has_changed);
+                               << " row_has_changed="  << row_has_changed
+                               << " drawingEnabled=" << pi.pain.isDrawingEnabled());
                }
 
                // Backup full_repaint status and force full repaint