diff options
author | Sebastian Geerken <devnull@localhost> | 2014-04-09 22:22:08 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-04-09 22:22:08 +0200 |
commit | 7a45186914fd6a805127e430d13e51601fcf47b6 (patch) | |
tree | e42886b0551f07416ef787a7090b1cce79eb0d3c /dw/outofflowmgr.cc | |
parent | eb66c4f173f4791e3e7400ec4beb52e8fc506b40 (diff) |
First step towards small refactoring.
Diffstat (limited to 'dw/outofflowmgr.cc')
-rw-r--r-- | dw/outofflowmgr.cc | 136 |
1 files changed, 76 insertions, 60 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 0c9a92be..4bd6b7ff 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -445,6 +445,8 @@ OutOfFlowMgr::TBInfo::TBInfo (OutOfFlowMgr *oofm, Textblock *textblock, leftFloatsGB = new SortedFloatsVector (oofm, LEFT, SortedFloatsVector::GB); rightFloatsGB = new SortedFloatsVector (oofm, RIGHT, SortedFloatsVector::GB); + + updateAllocation (); } OutOfFlowMgr::TBInfo::~TBInfo () @@ -490,8 +492,7 @@ OutOfFlowMgr::OutOfFlowMgr (Textblock *containingBlock) absolutelyPositioned = new Vector<AbsolutelyPositioned> (1, true); containingBlockWasAllocated = containingBlock->wasAllocated (); - if (containingBlockWasAllocated) - containingBlockAllocation = *(containingBlock->getAllocation()); + containingBlockAllocation = *(containingBlock->getAllocation()); addWidgetInFlow (containingBlock, NULL, 0); } @@ -521,72 +522,87 @@ OutOfFlowMgr::~OutOfFlowMgr () DBG_OBJ_DELETE (); } -void OutOfFlowMgr::sizeAllocateStart (Allocation *containingBlockAllocation) +void OutOfFlowMgr::sizeAllocateStart (Textblock *caller, Allocation *allocation) { - DBG_OBJ_MSG ("resize.oofm", 0, "<b>sizeAllocateStart</b>"); - this->containingBlockAllocation = *containingBlockAllocation; - containingBlockWasAllocated = true; -} - -void OutOfFlowMgr::sizeAllocateEnd () -{ - DBG_OBJ_MSG ("resize.oofm", 0, "<b>sizeAllocateEnd</b>"); + DBG_OBJ_MSGF ("resize.oofm", 0, + "<b>sizeAllocateStart</b> (%p, (%d, %d, %d * (%d + %d)))", + caller, allocation->x, allocation->y, allocation->width, + allocation->ascent, allocation->descent); DBG_OBJ_MSG_START (); - // Move floats from GB lists to the one CB list. - moveFromGBToCB (LEFT); - moveFromGBToCB (RIGHT); + getTextblock(caller)->allocation = *allocation; + getTextblock(caller)->wasAllocated = true; - // Floats and absolutely positioned blocks have to be allocated - sizeAllocateFloats (LEFT); - sizeAllocateFloats (RIGHT); - sizeAllocateAbsolutelyPositioned (); - - // Textblocks have already been allocated here. - - // Check changes of both textblocks and floats allocation. (All is checked - // by hasRelationChanged (...).) - for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = - tbInfosByTextblock->iterator (); - it.hasNext (); ) { - TypedPointer <Textblock> *key = it.getNext (); - TBInfo *tbInfo = tbInfosByTextblock->get (key); - Textblock *tb = key->getTypedValue(); - - int minFloatPos; - Widget *minFloat; - if (hasRelationChanged (tbInfo, &minFloatPos, &minFloat)) - tb->borderChanged (minFloatPos, minFloat); + if (caller == containingBlock) { + containingBlockAllocation = *allocation; + containingBlockWasAllocated = true; } - - // Store some information for later use. - for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = - tbInfosByTextblock->iterator (); - it.hasNext (); ) { - TypedPointer <Textblock> *key = it.getNext (); - TBInfo *tbInfo = tbInfosByTextblock->get (key); - Textblock *tb = key->getTypedValue(); - - tbInfo->updateAllocation (); - tbInfo->availWidth = tb->getAvailWidth (); - } - - // There are cases where some allocated floats (TODO: later also absolutely - // positioned elements?) exceed the CB allocation. - bool sizeChanged = doFloatsExceedCB (LEFT) || doFloatsExceedCB (RIGHT); - // Similar for extremes. (TODO: here also absolutely positioned elements?) - bool extremesChanged = - haveExtremesChanged (LEFT) || haveExtremesChanged (RIGHT); + DBG_OBJ_MSG_END (); +} - for (int i = 0; i < leftFloatsCB->size(); i++) - leftFloatsCB->get(i)->updateAllocation (); +void OutOfFlowMgr::sizeAllocateEnd (Textblock *caller) +{ + DBG_OBJ_MSGF ("resize.oofm", 0, "<b>sizeAllocateEnd</b> (%p)", caller); + DBG_OBJ_MSG_START (); - for (int i = 0; i < rightFloatsCB->size(); i++) - rightFloatsCB->get(i)->updateAllocation (); - - if (sizeChanged || extremesChanged) - containingBlock->oofSizeChanged (extremesChanged); + if (caller == containingBlock) { + // Move floats from GB lists to the one CB list. + moveFromGBToCB (LEFT); + moveFromGBToCB (RIGHT); + + // Floats and absolutely positioned blocks have to be allocated + sizeAllocateFloats (LEFT); + sizeAllocateFloats (RIGHT); + sizeAllocateAbsolutelyPositioned (); + + // Textblocks have already been allocated here. + + // Check changes of both textblocks and floats allocation. (All + // is checked by hasRelationChanged (...).) + for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = + tbInfosByTextblock->iterator (); + it.hasNext (); ) { + TypedPointer <Textblock> *key = it.getNext (); + TBInfo *tbInfo = tbInfosByTextblock->get (key); + Textblock *tb = key->getTypedValue(); + + int minFloatPos; + Widget *minFloat; + if (hasRelationChanged (tbInfo, &minFloatPos, &minFloat)) + tb->borderChanged (minFloatPos, minFloat); + } + + // Store some information for later use. + for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = + tbInfosByTextblock->iterator (); + it.hasNext (); ) { + TypedPointer <Textblock> *key = it.getNext (); + TBInfo *tbInfo = tbInfosByTextblock->get (key); + Textblock *tb = key->getTypedValue(); + + tbInfo->updateAllocation (); + tbInfo->availWidth = tb->getAvailWidth (); + } + + // There are cases where some allocated floats (TODO: later also + // absolutely positioned elements?) exceed the CB allocation. + bool sizeChanged = doFloatsExceedCB (LEFT) || doFloatsExceedCB (RIGHT); + + // Similar for extremes. (TODO: here also absolutely positioned + // elements?) + bool extremesChanged = + haveExtremesChanged (LEFT) || haveExtremesChanged (RIGHT); + + for (int i = 0; i < leftFloatsCB->size(); i++) + leftFloatsCB->get(i)->updateAllocation (); + + for (int i = 0; i < rightFloatsCB->size(); i++) + rightFloatsCB->get(i)->updateAllocation (); + + if (sizeChanged || extremesChanged) + containingBlock->oofSizeChanged (extremesChanged); + } DBG_OBJ_MSG_END (); } |