diff options
author | Sebastian Geerken <devnull@localhost> | 2016-05-27 13:47:14 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-05-27 13:47:14 +0200 |
commit | 91e3b71937b30e0c0ec38de7b5a0a099edf7ce32 (patch) | |
tree | 483ec252707cd54b138bd3ae779616a08cc3e1b6 /dw/textblock.cc | |
parent | c3291c7a8d3f5f7df51e24bdeed82a2f72cb097b (diff) |
Textblock::getGeneratorWidth() may use caller information to adjust return value. This fixes too small return values of getGeneratorRest().
Diffstat (limited to 'dw/textblock.cc')
-rw-r--r-- | dw/textblock.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 391e660a..28606aca 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -3053,9 +3053,17 @@ int Textblock::getGeneratorRest (int oofmIndex) int xRef, rest; OOFAwareWidget *container = oofContainer[oofmIndex]; - if (container != NULL && findSizeRequestReference (container, &xRef, NULL)) - rest = container->getGeneratorWidth () - (xRef + getGeneratorWidth ()); - else { + if (container != NULL && findSizeRequestReference (container, &xRef, NULL)) { + // This method is typically called within sizeRequest; so, this widget has + // more information to calculate the width that the container, wich will + // result in to too small values (often negative) of the rest. For this + // reason, we use the possibility to pass values from this widget. + + // (Also notice that the return value may actually be negative.) + + int width = getGeneratorWidth (0, 0); + rest = container->getGeneratorWidth (xRef, width) - (xRef + width); + } else { // Only callend for floats, so this should not happen: assertNotReached (); rest = 0; @@ -3065,16 +3073,18 @@ int Textblock::getGeneratorRest (int oofmIndex) return rest; } -int Textblock::getGeneratorWidth () +int Textblock::getGeneratorWidth (int callerX, int callerWidth) { - DBG_OBJ_ENTER0 ("resize", 0, "Textblock::getGeneratorWidth"); + DBG_OBJ_ENTER ("resize", 0, "Textblock::getGeneratorWidth", "%d, %d", + callerX, callerWidth); // Cf. sizeRequestImpl. if (usesMaxGeneratorWidth ()) { DBG_OBJ_LEAVE_VAL ("%d", lineBreakWidth); return lineBreakWidth; } else { - int w0 = lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0, + int w0 = max (lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0, + callerX + callerWidth), w = min (w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth); DBG_OBJ_LEAVE_VAL ("min (%d + %d + %d, %d) = %d", w0, leftInnerPadding, boxDiffWidth (), lineBreakWidth, |