From 7a45186914fd6a805127e430d13e51601fcf47b6 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Wed, 9 Apr 2014 22:22:08 +0200 Subject: First step towards small refactoring. --- dw/outofflowmgr.hh | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'dw/outofflowmgr.hh') diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index c5c560c7..109351d5 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -19,14 +19,10 @@ private: Textblock *containingBlock; - // These two values are set by sizeAllocateStart(), and they are - // accessable also within sizeAllocateEnd(), and also for the - // containing block, for which allocation and WAS_ALLOCATED is set - // *after* sizeAllocateEnd(). See the two inline functions - // wasAllocated(Widget*) and getAllocation(Widget*) (further down) - // for usage. - core::Allocation containingBlockAllocation; + // These two values are redundant to TBInfo::wasAllocated and + // TBInfo::allocation, for some special cases. bool containingBlockWasAllocated; + core::Allocation containingBlockAllocation; class WidgetInfo: public lout::object::Object { @@ -174,6 +170,15 @@ private: TBInfo *parent; int parentExtIndex; + + // These two values are set by sizeAllocateStart(), and they are + // accessable also within sizeAllocateEnd() for the same + // textblock, for which allocation and WAS_ALLOCATED is set + // *after* sizeAllocateEnd(). See the two functions + // wasAllocated(Widget*) and getAllocation(Widget*) (further + // down) for usage. + bool wasAllocated; + core::Allocation allocation; // These two lists store all floats generated by this textblock, // as long as this textblock is not allocates. @@ -184,6 +189,10 @@ private: ~TBInfo (); inline Textblock *getTextblock () { return (Textblock*)getWidget (); } + inline void updateAllocation () { + wasAllocated = getWidget()->wasAllocated (); + allocation = *(getWidget()->getAllocation ()); + } }; class AbsolutelyPositioned: public lout::object::Object @@ -219,21 +228,19 @@ private: /** * Variant of Widget::wasAllocated(), which can also be used within - * OOFM::sizeAllocateEnd(), and also for the generating block. + * OOFM::sizeAllocateEnd(). */ - inline bool wasAllocated (core::Widget *widget) { - return widget->wasAllocated () || - (widget == (core::Widget*)containingBlock && - containingBlockWasAllocated); } + inline bool wasAllocated (Textblock *textblock) { + return getTextblock(textblock)->wasAllocated; + } /** * Variant of Widget::getAllocation(), which can also be used - * within OOFM::sizeAllocateEnd(), and also for the generating - * block. + * within OOFM::sizeAllocateEnd(). */ - inline core::Allocation *getAllocation (core::Widget *widget) { - return widget == (core::Widget*)containingBlock ? - &containingBlockAllocation : widget->getAllocation (); } + inline core::Allocation *getAllocation (Textblock *textblock) { + return &(getTextblock(textblock)->allocation); + } void moveExternalIndices (SortedFloatsVector *list, int oldStartIndex, int diff); @@ -362,8 +369,8 @@ public: OutOfFlowMgr (Textblock *containingBlock); ~OutOfFlowMgr (); - void sizeAllocateStart (core::Allocation *containingBlockAllocation); - void sizeAllocateEnd (); + void sizeAllocateStart (Textblock *caller, core::Allocation *allocation); + void sizeAllocateEnd (Textblock *caller); void draw (core::View *view, core::Rectangle *area); void markSizeChange (int ref); -- cgit v1.2.3