]> git.lyx.org Git - features.git/commitdiff
fix break before minipages too
authorJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 04:59:48 +0000 (04:59 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 10 Mar 2003 04:59:48 +0000 (04:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6411 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C

index e85f2081d7d6ca45247b54c920c54f9340ee1806..670b89adfc880c4a70075c97948b9f30388045f5 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-10  John Levon  <levon@movementarian.org>
+
+       * text.C: fix break before a minipage
+
 2003-03-10  John Levon  <levon@movementarian.org>
 
        * text.C: fix the last commit
index 1c117d7051ca9bfe807d806e66542fa21343c68d..e23daf91d289e4812c60f03e378e30ccf9cf2277 100644 (file)
@@ -727,7 +727,11 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
        // or the end of the par, then choose the possible break
        // nearest that.
 
-       int x = leftMargin(&bv, &row);
+       int const left = leftMargin(&bv, &row);
+       int x = left;
+
+       // pixel width since last breakpoint
+       int chunkwidth = 0;
 
        for (i = pos; i < last; ++i) {
 
@@ -738,19 +742,22 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
                        break;
                }
 
-               x += singleWidth(&bv, par, i, c);
+               int thiswidth = singleWidth(&bv, par, i, c);
 
                // add the auto-hfill from label end to the body
                if (body_pos && i == body_pos) {
-                       x += font_metrics::width(layout->labelsep,
+                       thiswidth += font_metrics::width(layout->labelsep,
                                    getLabelFont(bv.buffer(), par));
                        if (par->isLineSeparator(i - 1))
-                               x-= singleWidth(&bv, par, i - 1);
+                               thiswidth -= singleWidth(&bv, par, i - 1);
                        int left_margin = labelEnd(bv, row);
-                       if (x < left_margin)
-                               x = left_margin;
+                       if (thiswidth < left_margin)
+                               thiswidth = left_margin;
                }
 
+               x += thiswidth;
+               chunkwidth += thiswidth;
+
                Inset * in = par->isInset(i) ? par->getInset(i) : 0;
                bool display = (in && (in->display() || in->needFullRow()));
 
@@ -765,8 +772,9 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
                // break before a character that will fall off
                // the right of the row
                if (x >= width) {
-                       // if no break before or this is a fullrow inset, break here.
-                       if (point == last || display) {
+                       // if no break before or we are at an inset
+                       // that will take up a row, break here
+                       if (point == last || display || chunkwidth >= (width - left)) {
                                if (pos < i)
                                        point = i - 1;
                                else
@@ -777,8 +785,10 @@ LyXText::rowBreakPoint(BufferView & bv, Row const & row) const
 
                if (!in || in->isChar()) {
                        // some insets are line separators too
-                       if (par->isLineSeparator(i))
+                       if (par->isLineSeparator(i)) {
                                point = i;
+                               chunkwidth = 0;
+                       }
                        continue;
                }