diff options
author | Sebastian Geerken <devnull@localhost> | 2016-05-29 15:07:26 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-05-29 15:07:26 +0200 |
commit | 89020950821028ad0836da9e919259c12e40acff (patch) | |
tree | 2e27917a3d8302d6d8f8eef63db6e727bd603f7a | |
parent | 0af7f4a7e24725573c03933fa9abfec3aaabf640 (diff) |
Fix position for sizeRequest in Textblock widget (simplification).
-rw-r--r-- | dw/textblock.cc | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 262b8872..3b0e14cf 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2306,8 +2306,12 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget, core::SizeParams childParams; DBG_OBJ_ASSOC_CHILD (&childParams); - bool first = true; - int oldXRel = -1; + int oldXRel = leftBorder; + + sizeRequestParams.forChild (this, widget, oldXRel, yRel, &childParams); + widget->sizeRequest (size, childParams.getNumPos (), + childParams.getReferences (), childParams.getX (), + childParams.getY ()); DBG_OBJ_MSG_START (); @@ -2315,35 +2319,34 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget, DBG_OBJ_MSG_START (); int xRel; - if(first) + + 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: // equivalent for only one word + default: // compiler happiness 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: // equivalent for only 1 word - default: // compiler happiness - xRel = leftBorder; - break; - - case core::style::TEXT_ALIGN_RIGHT: - xRel = lineBreakWidth - rightBorder - size->width; - break; - - case core::style::TEXT_ALIGN_CENTER: - xRel = - (leftBorder + lineBreakWidth - rightBorder - size->width) / 2; - break; - } + break; - // Cf. Textblock::calcTextOffset(). - if (xRel < leftBorder) - xRel = leftBorder; + case core::style::TEXT_ALIGN_RIGHT: + xRel = lineBreakWidth - rightBorder - size->width; + break; + + case core::style::TEXT_ALIGN_CENTER: + 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); - if (!first && xRel == oldXRel) + // Stop when the value of xRel has not changed during the last + // iteration. + if (xRel == oldXRel) break; sizeRequestParams.forChild (this, widget, xRel, yRel, &childParams); @@ -2352,7 +2355,6 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget, childParams.getY ()); oldXRel = xRel; - first = false; DBG_OBJ_MSG_END (); } |