diff options
author | Sebastian Geerken <devnull@localhost> | 2016-05-29 14:31:01 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-05-29 14:31:01 +0200 |
commit | a55d0b2cb386a4a2bc7ec38b56e06aaf37b00956 (patch) | |
tree | c2f5a7d34658cd294ba7c3ca8c36d93440eae633 | |
parent | ecb465d010bab3b554ef65443a73d682494d5a8a (diff) |
Fix position for sizeRequest in Textblock widget (corrections).
-rw-r--r-- | dw/textblock.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 8a1183de..d18fae88 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2280,16 +2280,20 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget, int lastWord = lines->empty () ? -1 : lines->getLastRef()->lastWord; assert (wordIndex > lastWord); - int xRel0 = boxOffsetX () + leftInnerPadding + // Since the child widget will regard floats, we do not have to include + // floats when calculating left and right border. + int leftBorder = boxOffsetX () + leftInnerPadding + (lines->size () == 0 ? line1OffsetEff : 0); + int rightBorder = boxRestWidth (); + int lastMargin, yLine = yOffsetOfLineToBeCreated (&lastMargin); int yRel = yLine - min (lastMargin, widget->getStyle()->margin.top); DBG_OBJ_MSGF ("resize", 1, - "xRel0 = %d + %d + (%d == 0 ? %d : 0) = %d, " - "yRel = %d - min (%d, %d) = %d", + "leftBorder = %d + %d + (%d == 0 ? %d : 0) = %d, " + "rightBorder = %d, yRel = %d - min (%d, %d) = %d", boxOffsetX (), leftInnerPadding , lines->size (), - line1OffsetEff, xRel0, yLine, lastMargin, + line1OffsetEff, leftBorder, rightBorder, yLine, lastMargin, widget->getStyle()->margin.top, yRel); core::SizeParams childParams; @@ -2305,26 +2309,29 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget, int xRel; if(first) - xRel = xRel0; + xRel = leftBorder; else { switch(widget->getStyle()->textAlign) { case core::style::TEXT_ALIGN_LEFT: case core::style::TEXT_ALIGN_STRING: // see comment in alignLine() case core::style::TEXT_ALIGN_JUSTIFY: default: // compiler happiness - xRel = xRel0; + xRel = leftBorder; break; case core::style::TEXT_ALIGN_RIGHT: - // TODO: Is this correct? - xRel = xRel0 + lineBreakWidth - size->width; + xRel = lineBreakWidth - rightBorder - size->width; break; case core::style::TEXT_ALIGN_CENTER: - // TODO: Is this correct? - xRel = xRel0 + (lineBreakWidth - size->width) / 2; + xRel = + (leftBorder + lineBreakWidth - rightBorder - size->width) / 2; break; } + + // Cf. Textblock::calcTextOffset(). + if (xRel < leftBorder) + xRel = leftBorder; } DBG_OBJ_MSGF ("resize", 2, "xRel = %d, oldXRel = %d", xRel, oldXRel); |