aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-10-06 03:29:11 +0200
committerSebastian Geerken <devnull@localhost>2014-10-06 03:29:11 +0200
commit10fb76e9b12ae211c7afd8c8514ffbd5119cc7e3 (patch)
tree3ef41f5c00593624155380c6f60008f4f30d5b79
parent000ad0ab90444230f5bebc5c0a5b28f572e6a013 (diff)
Fixed floats clearance.
-rw-r--r--dw/outofflowmgr.cc32
-rw-r--r--dw/outofflowmgr.hh4
-rw-r--r--dw/textblock.cc9
-rw-r--r--dw/textblock.hh1
4 files changed, 38 insertions, 8 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index a9e0acc3..a128a5c4 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -474,6 +474,7 @@ OutOfFlowMgr::TBInfo::TBInfo (OutOfFlowMgr *oofm, Textblock *textblock,
wasAllocated = getWidget()->wasAllocated ();
allocation = *(getWidget()->getAllocation ());
+ clearPosition = 0;
}
OutOfFlowMgr::TBInfo::~TBInfo ()
@@ -605,6 +606,17 @@ void OutOfFlowMgr::sizeAllocateEnd (Textblock *caller)
sizeAllocateFloats (RIGHT, rightFloatsCB->findFloatIndex (caller, -1));
}
+ // 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 = getTextblock (caller);
+ int newClearPosition = calcClearPosition (caller);
+ if (newClearPosition != tbInfo->clearPosition) {
+ tbInfo->clearPosition = newClearPosition;
+ caller->clearPositionChanged ();
+ }
+
if (caller == containingBlock) {
// In the size allocation process, the *last* OOFM method called
// is sizeAllocateEnd, with the containing block as an
@@ -2225,6 +2237,11 @@ int OutOfFlowMgr::getFloatHeight (Textblock *textblock, Side side, int y, int h,
*/
int OutOfFlowMgr::getClearPosition (Textblock *tb)
{
+ return getTextblock(tb)->clearPosition;
+}
+
+int OutOfFlowMgr::calcClearPosition (Textblock *tb)
+{
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p", tb);
int pos;
@@ -2239,8 +2256,8 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb)
default: assertNotReached ();
}
- pos = max (left ? getClearPosition (tb, LEFT) : 0,
- right ? getClearPosition (tb, RIGHT) : 0);
+ pos = max (left ? calcClearPosition (tb, LEFT) : 0,
+ right ? calcClearPosition (tb, RIGHT) : 0);
} else
pos = 0;
@@ -2250,7 +2267,7 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb)
return pos;
}
-int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side)
+int OutOfFlowMgr::calcClearPosition (Textblock *tb, Side side)
{
DBG_OBJ_ENTER ("resize.oofm", 0, "getClearPosition", "%p, %s",
tb, side == LEFT ? "LEFT" : "RIGHT");
@@ -2277,11 +2294,12 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side)
pos = 0; // See above.
else {
ensureFloatSize (vloat);
- pos = getAllocation(vloat->generatingBlock)->y + vloat->yReal
- + vloat->size.ascent + vloat->size.descent
- - getAllocation(tb)->y;
+ pos = max (getAllocation(vloat->generatingBlock)->y + vloat->yReal
+ + vloat->size.ascent + vloat->size.descent
+ - getAllocation(tb)->y,
+ 0);
DBG_OBJ_MSGF ("resize.oofm", 1,
- "float %p => %d + %d + (%d + %d) - %d",
+ "float %p => max (%d + %d + (%d + %d) - %d, 0)",
vloat->getWidget (),
getAllocation(vloat->generatingBlock)->y,
vloat->yReal, vloat->size.ascent, vloat->size.descent,
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index b7283815..a42afd1d 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -186,6 +186,7 @@ private:
// down) for usage.
bool wasAllocated;
core::Allocation allocation;
+ int clearPosition;
// These two lists store all floats generated by this textblock,
// as long as this textblock is not allocates.
@@ -321,7 +322,8 @@ private:
int getFloatHeight (Textblock *textblock, Side side, int y, int h,
Textblock *lastGB, int lastExtIndex);
- int getClearPosition (Textblock *tb, Side side);
+ int calcClearPosition (Textblock *tb, Side side);
+ int calcClearPosition (Textblock *tb);
void ensureFloatSize (Float *vloat);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 1e5280b5..4c8ce87c 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3068,6 +3068,15 @@ void Textblock::borderChanged (int y, Widget *vloat)
DBG_OBJ_LEAVE ();
}
+void Textblock::clearPositionChanged ()
+{
+ DBG_OBJ_ENTER0 ("resize", 0, "clearPositionChanged");
+ // Not very efficient (actually, a rewrapping could be easily
+ // avoided), but this case should not occur very often.
+ queueResize (0, false);
+ DBG_OBJ_LEAVE ();
+}
+
void Textblock::oofSizeChanged (bool extremesChanged)
{
DBG_OBJ_ENTER ("resize", 0, "oofSizeChanged", "%s",
diff --git a/dw/textblock.hh b/dw/textblock.hh
index e7ff5c63..c95dfff9 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -834,6 +834,7 @@ public:
bool includeFirstSpace, bool includeLastSpace);
void borderChanged (int y, core::Widget *vloat);
+ void clearPositionChanged ();
void oofSizeChanged (bool extremesChanged);
inline int getLineBreakWidth () { return lineBreakWidth; }
};