aboutsummaryrefslogtreecommitdiff
path: root/dw/outofflowmgr.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-03-01 14:13:26 +0100
committerSebastian Geerken <devnull@localhost>2014-03-01 14:13:26 +0100
commitc6ed8cafa4d87ec46be2211a72c427ad922207de (patch)
treeb9a869ade04fabf16b4cfc46264762e99fc857fc /dw/outofflowmgr.cc
parente90220c5150e9bc679d777e9907e3504a5baef54 (diff)
Fixed bug in OOFM::getSize (confusing widget coordinates with canvas coordinates).
Diffstat (limited to 'dw/outofflowmgr.cc')
-rw-r--r--dw/outofflowmgr.cc118
1 files changed, 97 insertions, 21 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 ();