diff options
-rw-r--r-- | dw/outofflowmgr.cc | 118 | ||||
-rw-r--r-- | dw/textblock.cc | 63 |
2 files changed, 136 insertions, 45 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 96717f26..856944ba 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -873,7 +873,7 @@ void OutOfFlowMgr::sizeAllocateFloats (Side side) for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); - // "ensureFloatSize (vloat)" was already called before. + ensureFloatSize (vloat); Allocation *gbAllocation = getAllocation(vloat->generatingBlock); Allocation *cbAllocation = getAllocation(containingBlock); @@ -1404,11 +1404,15 @@ void OutOfFlowMgr::getSize (int *oofWidth, int *oofHeight) "=> (a: %d, l: %d, r: %d => %d) * (a: %d, l: %d, r: %d => %d)", oofWidthAbsPos, oofWidthtLeft, oofWidthRight, *oofWidth, oofHeightAbsPos, oofHeightLeft, oofHeightRight, *oofHeight); - DBG_OBJ_MSG_END (); + DBG_OBJ_MSG_END (); } void OutOfFlowMgr::getFloatsSize (Side side, int *width, int *height) { + DBG_OBJ_MSGF ("resize.oofm", 0, "<b>getFloatsSize</b> (%s, ...)", + side == LEFT ? "LEFT" : "RIGHT"); + DBG_OBJ_MSG_START (); + SortedFloatsVector *list = getFloatsListForTextblock (containingBlock, side); *width = *height = 0; @@ -1418,6 +1422,7 @@ void OutOfFlowMgr::getFloatsSize (Side side, int *width, int *height) if (vloat->generatingBlock == containingBlock) { ensureFloatSize (vloat); + *width = max (*width, vloat->size.width + side == LEFT ? containingBlock->getStyle()->boxOffsetX () : @@ -1426,19 +1431,46 @@ void OutOfFlowMgr::getFloatsSize (Side side, int *width, int *height) max (*height, vloat->yReal + vloat->size.ascent + vloat->size.descent + containingBlock->getStyle()->boxRestHeight ()); + + DBG_OBJ_MSGF ("resize.oofm", 1, + "considering float %p generated by CB: (%d + %d) * " + "(%d + (%d + %d) + %d) => %d * %d", + vloat->getWidget (), vloat->size.width, + side == LEFT ? + containingBlock->getStyle()->boxOffsetX () : + containingBlock->getStyle()->boxRestWidth (), + vloat->yReal, vloat->size.ascent, vloat->size.descent, + containingBlock->getStyle()->boxRestHeight (), + *width, *height); } else { // The GB must be allocated, but the float may not yet be allocated; // it is ignored in this case. assert (wasAllocated (vloat->generatingBlock)); + DBG_OBJ_MSGF ("resize.oofm", 1, "considering float %p generated by %p", + vloat->getWidget (), vloat->generatingBlock); + if (vloat->getWidget()->wasAllocated ()) { Allocation *fla = vloat->getWidget()->getAllocation (); - *width = max (*width, fla->x + fla->width); + *width = max (*width, + fla->x - containingBlockAllocation.x + fla->width); *height = max (*height, - fla->y + fla->ascent + fla->descent + fla->y - containingBlockAllocation.y + + fla->ascent + fla->descent + containingBlock->getStyle()->boxRestHeight ()); - } + + DBG_OBJ_MSGF ("resize.oofm", 1, "... (%d - %d + %d) * " + "(%d - %d + (%d + %d) + %d) => %d * %d", + fla->x, containingBlockAllocation.x, fla->width, + fla->y, containingBlockAllocation.y, + fla->ascent, fla->descent, + containingBlock->getStyle()->boxRestHeight (), + *width, *height); + } else + DBG_OBJ_MSG ("resize.oofm", 1, "... not allocated"); } } + + DBG_OBJ_MSG_END (); } void OutOfFlowMgr::getExtremes (int *oofMinWidth, int *oofMaxWidth) @@ -1454,6 +1486,10 @@ void OutOfFlowMgr::accumExtremes (SortedFloatsVector *list, Side side, { // Idea for a faster implementation: use incremental resizing? + DBG_OBJ_MSGF ("resize", 0, "<b>accumExtremes</b> (..., %s, ...)", + side == LEFT ? "LEFT" : "RIGHT"); + DBG_OBJ_MSG_START (); + for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); @@ -1462,9 +1498,18 @@ void OutOfFlowMgr::accumExtremes (SortedFloatsVector *list, Side side, Extremes extr; vloat->getWidget()->getExtremes (&extr); + DBG_OBJ_MSGF ("resize", 1, "float %p: (%d + %d) / (%d + %d)", + vloat->getWidget(), extr.minWidth, minBorderDiff, + extr.maxWidth, maxBorderDiff); + + *oofMinWidth = max (*oofMinWidth, extr.minWidth + minBorderDiff); *oofMaxWidth = max (*oofMaxWidth, extr.maxWidth + maxBorderDiff); + + DBG_OBJ_MSGF ("resize", 1, "=> %d / %d", *oofMinWidth, *oofMaxWidth); } + + DBG_OBJ_MSG_END (); } /** @@ -1752,14 +1797,25 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat) // TODO Ugly. Soon to be replaced by cleaner code? See also // comment in Textblock::calcWidgetSize. if (vloat->getWidget()->usesHints ()) { - if (isAbsLength (vloat->getWidget()->getStyle()->width)) - vloat->getWidget()->setWidth - (absLengthVal (vloat->getWidget()->getStyle()->width)); - else if (isPerLength (vloat->getWidget()->getStyle()->width)) - vloat->getWidget()->setWidth - (multiplyWithPerLength (containingBlock->getAvailWidth(), - vloat->getWidget()->getStyle()->width)); - } + if (isAbsLength (vloat->getWidget()->getStyle()->width)) { + int width = absLengthVal (vloat->getWidget()->getStyle()->width); + vloat->getWidget()->setWidth (width); + DBG_OBJ_MSGF ("resize.oofm", 1, "setting absolute width: %d", + width); + } else if (isPerLength (vloat->getWidget()->getStyle()->width)) { + int width = + multiplyWithPerLength (containingBlock->getAvailWidth(), + vloat->getWidget()->getStyle()->width); + vloat->getWidget()->setWidth (width); + DBG_OBJ_MSGF ("resize.oofm", 1, + "setting percentage width: %d * %g = %d", + containingBlock->getAvailWidth(), + perLengthVal (vloat->getWidget()->getStyle()->width), + width); + } else + DBG_OBJ_MSG ("resize.oofm", 1, "setting no width: not defined"); + } else + DBG_OBJ_MSG ("resize.oofm", 1, "setting no width: uses no hints"); // This is a bit hackish: We first request the size, then set // the available width (also considering the one of the @@ -1781,33 +1837,53 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat) // wide, sometimes. Extremes extremes; vloat->getWidget()->getExtremes (&extremes); + DBG_OBJ_MSGF ("resize.oofm", 1, "getExtremes => %d / %d", + extremes.minWidth, extremes.maxWidth); vloat->getWidget()->sizeRequest (&vloat->size); + DBG_OBJ_MSGF ("resize.oofm", 1, "sizeRequest (1) => %d * (%d + %d)", + vloat->size.width, vloat->size.ascent, vloat->size.descent); // Set width ... int width = vloat->size.width; + DBG_OBJ_MSGF ("resize.oofm", 1, "new width: %d", width); + DBG_OBJ_MSG_START (); + // Consider the available width of the containing block (when set): - if (width > containingBlock->getAvailWidth()) + if (width > containingBlock->getAvailWidth()) { width = containingBlock->getAvailWidth(); + DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to availWidth: %d", width); + } // Finally, consider extremes (as described above). - if (width < extremes.minWidth) + if (width < extremes.minWidth) { width = extremes.minWidth; - if (width > extremes.maxWidth) + DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to minWidth: %d", width); + } + if (width > extremes.maxWidth) { width = extremes.maxWidth; + DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to maxWidth: %d", width); + } + + DBG_OBJ_MSG_END (); vloat->getWidget()->setWidth (width); vloat->getWidget()->sizeRequest (&vloat->size); + DBG_OBJ_MSGF ("resize.oofm", 1, "sizeRequest (2) => %d * (%d + %d)", + vloat->size.width, vloat->size.ascent, vloat->size.descent); - //printf (" float %p (%s %p): %d x (%d + %d)\n", - // vloat, vloat->getWidget()->getClassName(), vloat->getWidget(), - // vloat->size.width, vloat->size.ascent, vloat->size.descent); - vloat->cbAvailWidth = containingBlock->getAvailWidth (); vloat->dirty = false; - DBG_OBJ_MSGF ("resize.oofm", 1, "new size: %d * (%d + %d)", + DBG_OBJ_MSGF ("resize.oofm", 1, "final size: %d * (%d + %d)", vloat->size.width, vloat->size.ascent, vloat->size.descent); + DBG_OBJ_SET_NUM_O (vloat->getWidget(), "<Float-size>.width", + vloat->size.width); + DBG_OBJ_SET_NUM_O (vloat->getWidget(), "<Float-size>.ascent", + vloat->size.ascent); + DBG_OBJ_SET_NUM_O (vloat->getWidget(), "<Float-size>.descent", + vloat->size.descent); + // "sizeChangedSinceLastAllocation" is reset in sizeAllocateEnd() DBG_OBJ_MSG_END (); diff --git a/dw/textblock.cc b/dw/textblock.cc index 5d28ce7f..27bc584e 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -332,7 +332,8 @@ Textblock::~Textblock () */ void Textblock::sizeRequestImpl (core::Requisition *requisition) { - PRINTF ("[%p] SIZE_REQUEST: ...\n", this); + DBG_OBJ_MSG ("resize", 0, "<b>sizeRequestImpl</b> ()"); + DBG_OBJ_MSG_START (); rewrap (); showMissingLines (); @@ -340,18 +341,18 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) if (lines->size () > 0) { Line *lastLine = lines->getRef (lines->size () - 1); requisition->width = lastLine->maxLineWidth; - - PRINTF ("[%p] SIZE_REQUEST: lastLine->maxLineWidth = %d\n", - this, lastLine->maxLineWidth); - - PRINTF ("[%p] SIZE_REQUEST: lines[0]->boxAscent = %d\n", - this, lines->getRef(0)->boxAscent); - PRINTF ("[%p] SIZE_REQUEST: lines[%d]->top = %d\n", - this, lines->size () - 1, lastLine->top); - PRINTF ("[%p] SIZE_REQUEST: lines[%d]->boxAscent = %d\n", - this, lines->size () - 1, lastLine->boxAscent); - PRINTF ("[%p] SIZE_REQUEST: lines[%d]->boxDescent = %d\n", - this, lines->size () - 1, lastLine->boxDescent); + + DBG_OBJ_MSGF ("resize", 1, "lines[%d]->maxLineWidth = %d", + lines->size () - 1, lastLine->maxLineWidth); + + DBG_OBJ_MSGF ("resize", 1, "lines[0]->boxAscent = %d", + lines->getRef(0)->boxAscent); + DBG_OBJ_MSGF ("resize", 1, "lines[%d]->top = %d", + lines->size () - 1, lastLine->top); + DBG_OBJ_MSGF ("resize", 1, "lines[%d]->boxAscent = %d", + lines->size () - 1, lastLine->boxAscent); + DBG_OBJ_MSGF ("resize", 1, "lines[%d]->boxDescent = %d", + lines->size () - 1, lastLine->boxDescent); /* Note: the breakSpace of the last line is ignored, so breaks at the end of a textblock are not visible. */ @@ -365,8 +366,8 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) requisition->descent = 0; } - PRINTF ("[%p] SIZE_REQUEST: inner padding = %d, boxDiffWidth = %d\n", - this, innerPadding, getStyle()->boxDiffWidth ()); + DBG_OBJ_MSGF ("resize", 1, "inner padding = %d, boxDiffWidth = %d", + innerPadding, getStyle()->boxDiffWidth ()); requisition->width += innerPadding + getStyle()->boxDiffWidth (); requisition->ascent += verticalOffset + getStyle()->boxOffsetY (); @@ -377,6 +378,9 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) // role (currently) and caring about them (for the future) would // cause too much problems. + DBG_OBJ_MSGF ("resize", 1, "before considering OOF widgets: %d * %d + %d", + requisition->width, requisition->ascent, requisition->descent); + if (outOfFlowMgr) { int oofWidth, oofHeight; outOfFlowMgr->getSize (&oofWidth, &oofHeight); @@ -385,11 +389,19 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) requisition->descent = oofHeight - requisition->ascent; } - if (requisition->width < availWidth) + DBG_OBJ_MSGF ("resize", 1, "before considering availWidth: %d * %d + %d", + requisition->width, requisition->ascent, requisition->descent); + + if (requisition->width < availWidth) { requisition->width = availWidth; + DBG_OBJ_MSGF ("resize", 1, "adjusting to availWidth => %d", + requisition->width); + } + + DBG_OBJ_MSGF ("resize", 1, "=> %d * %d + %d", + requisition->width, requisition->ascent, requisition->descent); - PRINTF ("[%p] SIZE_REQUEST: %d x %d + %d\n", this, requisition->width, - requisition->ascent, requisition->descent); + DBG_OBJ_MSG_END (); } /** @@ -427,7 +439,8 @@ void Textblock::getWordExtremes (Word *word, core::Extremes *extremes) void Textblock::getExtremesImpl (core::Extremes *extremes) { - PRINTF ("[%p] GET_EXTREMES ...\n", this); + DBG_OBJ_MSG ("resize", 0, "<b>getExtremesImpl</b>"); + DBG_OBJ_MSG_START (); fillParagraphs (); @@ -449,16 +462,18 @@ void Textblock::getExtremesImpl (core::Extremes *extremes) int oofMinWidth, oofMaxWidth; outOfFlowMgr->getExtremes (&oofMinWidth, &oofMaxWidth); - //printf ("[%p] extremes: %d / %d, corrected: %d / %d\n", - // this, extremes->minWidth, extremes->maxWidth, - // oofMinWidth, oofMaxWidth); + DBG_OBJ_MSGF ("resize", 1, "extremes: %d / %d, corrected: %d / %d", + extremes->minWidth, extremes->maxWidth, + oofMinWidth, oofMaxWidth); extremes->minWidth = misc::max (extremes->minWidth, oofMinWidth); extremes->maxWidth = misc::max (extremes->maxWidth, oofMaxWidth); } - PRINTF ("[%p] GET_EXTREMES => %d / %d\n", - this, extremes->minWidth, extremes->maxWidth); + DBG_OBJ_MSGF ("resize", 1, "=> %d / %d", + extremes->minWidth, extremes->maxWidth); + + DBG_OBJ_MSG_END (); } |