aboutsummaryrefslogtreecommitdiff
path: root/dw/ooffloatsmgr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/ooffloatsmgr.cc')
-rw-r--r--dw/ooffloatsmgr.cc91
1 files changed, 22 insertions, 69 deletions
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 79b76580..4690eac6 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -300,8 +300,6 @@ OOFFloatsMgr::TBInfo::TBInfo (OOFFloatsMgr *oofm, OOFAwareWidget *textblock,
leftFloats = new Vector<Float> (1, false);
rightFloats = new Vector<Float> (1, false);
-
- clearPosition = 0;
}
OOFFloatsMgr::TBInfo::~TBInfo ()
@@ -371,22 +369,9 @@ void OOFFloatsMgr::sizeAllocateEnd (OOFAwareWidget *caller)
{
DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller);
- if (isOOFAwareWidgetRegistered (caller)) {
- // The checks below do not cover "clear position" in all cases,
- // so this is done here separately. This position is stored in
- // TBInfo and calculated at this points; changes will be noticed
- // to the textblock.
- TBInfo *tbInfo = getOOFAwareWidget (caller);
- int newClearPosition = calcClearPosition (caller);
- if (newClearPosition != tbInfo->clearPosition) {
- tbInfo->clearPosition = newClearPosition;
- caller->clearPositionChanged ();
- }
-
- if (caller == container) {
- sizeAllocateFloats (LEFT);
- sizeAllocateFloats (RIGHT);
- }
+ if (caller == container) {
+ sizeAllocateFloats (LEFT);
+ sizeAllocateFloats (RIGHT);
}
DBG_OBJ_LEAVE ();
@@ -1151,20 +1136,15 @@ int OOFFloatsMgr::getFloatHeight (Side side, int y, int h,
/**
* Returns position relative to the textblock "tb".
*/
-int OOFFloatsMgr::getClearPosition (OOFAwareWidget *textblock)
-{
- return getOOFAwareWidget(textblock)->clearPosition;
-}
-
-int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock)
+int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget)
{
- DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", textblock);
+ DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", widget);
int pos;
- if (textblock->getStyle()) {
+ if (widget->getStyle()) {
bool left = false, right = false;
- switch (textblock->getStyle()->clear) {
+ switch (widget->getStyle()->clear) {
case CLEAR_NONE: break;
case CLEAR_LEFT: left = true; break;
case CLEAR_RIGHT: right = true; break;
@@ -1172,8 +1152,8 @@ int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock)
default: assertNotReached ();
}
- pos = max (left ? calcClearPosition (textblock, LEFT) : 0,
- right ? calcClearPosition (textblock, RIGHT) : 0);
+ pos = max (left ? getClearPosition (widget, LEFT) : 0,
+ right ? getClearPosition (widget, RIGHT) : 0);
} else
pos = 0;
@@ -1198,56 +1178,29 @@ bool OOFFloatsMgr::mayAffectBordersAtAll ()
return true;
}
-int OOFFloatsMgr::calcClearPosition (OOFAwareWidget *textblock, Side side)
+int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget, Side side)
{
- // TODO (SRDOP) Implementation
- return 0;
-
-#if 0
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s",
- textblock, side == LEFT ? "LEFT" : "RIGHT");
+ widget, side == LEFT ? "LEFT" : "RIGHT");
int pos;
+ SortedFloatsVector *list = side == LEFT ? leftFloats : rightFloats;
- if (!wasAllocated (textblock))
- // There is no relation yet to floats generated by other
- // textblocks, and this textblocks floats are unimportant for
- // the "clear" property.
+ // Search the last float before (therfore -1) this widget.
+ int i = list->findFloatIndex (widget, -1);
+ if (i < 0)
pos = 0;
else {
- SortedFloatsVector *list = side == LEFT ? leftFloats : rightFloats;
-
- // Search the last float before (therfore -1) this textblock.
- int i = list->findFloatIndex (textblock, -1);
- if (i < 0) {
- pos = 0;
- DBG_OBJ_MSG ("resize.oofm", 1, "no float");
- } else {
- Float *vloat = list->get(i);
- assert (vloat->generatingBlock != textblock);
- if (!wasAllocated (vloat->generatingBlock))
- pos = 0; // See above.
- else {
- ensureFloatSize (vloat);
- pos = max (getAllocation(vloat->generatingBlock)->y + vloat->yReal
- + vloat->size.ascent + vloat->size.descent
- - getAllocation(textblock)->y,
- 0);
- DBG_OBJ_MSGF ("resize.oofm", 1,
- "float %p => max (%d + %d + (%d + %d) - %d, 0)",
- vloat->getWidget (),
- getAllocation(vloat->generatingBlock)->y,
- vloat->yReal, vloat->size.ascent, vloat->size.descent,
- getAllocation(textblock)->y);
- }
- }
+ Float *vloat = list->get(i);
+ assert (vloat->generator != widget);
+ ensureFloatSize (vloat);
+ pos = max (vloat->yReal + vloat->size.ascent + vloat->size.descent
+ - vloat->generator->getGeneratorY (oofmIndex), 0);
}
-
- DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", pos);
- DBG_OBJ_LEAVE ();
+
+ DBG_OBJ_LEAVE_VAL ("%d", pos);
return pos;
-#endif
}
void OOFFloatsMgr::ensureFloatSize (Float *vloat)