diff options
author | Sebastian Geerken <devnull@localhost> | 2015-02-03 11:01:28 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-02-03 11:01:28 +0100 |
commit | ac04cad270ed1ad13e99124361b14af6682234e2 (patch) | |
tree | e5961f80e168c12cb4664633ce080b4b44fd9d45 | |
parent | cdc7bebac4c0fa7fe198c4b72c62948ffeb12815 (diff) |
Removed 'reference' of posioned elements.
-rw-r--r-- | dw/oofawarewidget.cc | 8 | ||||
-rw-r--r-- | dw/oofposabslikemgr.cc | 57 | ||||
-rw-r--r-- | dw/oofposabslikemgr.hh | 18 | ||||
-rw-r--r-- | dw/oofposabsmgr.cc | 14 | ||||
-rw-r--r-- | dw/oofposabsmgr.hh | 1 | ||||
-rw-r--r-- | dw/oofposfixedmgr.cc | 5 | ||||
-rw-r--r-- | dw/oofposfixedmgr.hh | 1 | ||||
-rw-r--r-- | dw/oofpositionedmgr.cc | 13 | ||||
-rw-r--r-- | dw/oofpositionedmgr.hh | 9 | ||||
-rw-r--r-- | dw/oofposrelmgr.cc | 6 | ||||
-rw-r--r-- | dw/oofposrelmgr.hh | 2 |
11 files changed, 37 insertions, 97 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc index 9521e916..c1398a64 100644 --- a/dw/oofawarewidget.cc +++ b/dw/oofawarewidget.cc @@ -161,14 +161,8 @@ bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex) // process" in "dw-stacking-context.doc". testWidgetOutOfFlow (widget))); - case OOFM_RELATIVE: // TODO Correct? + case OOFM_RELATIVE: case OOFM_ABSOLUTE: - // We use the toplevel widget as container, i. e. parent widget. - // See also OOFPosAbsMgr::isReference for the definition of the - // "reference widget". - //return widget->getParent() == NULL; - - // The above does not work. Temporary re-enact old behaviour: return widget->instanceOf (OOFAwareWidget::CLASS_ID) && (widget->getParent() == NULL || OOFAwareWidget::testWidgetPositioned (widget)); diff --git a/dw/oofposabslikemgr.cc b/dw/oofposabslikemgr.cc index 5afd6ec5..7d274f90 100644 --- a/dw/oofposabslikemgr.cc +++ b/dw/oofposabslikemgr.cc @@ -18,7 +18,6 @@ */ #include "oofposabslikemgr.hh" -#include "oofawarewidget.hh" using namespace dw::core; using namespace lout::misc; @@ -385,8 +384,7 @@ bool OOFPosAbsLikeMgr::isHPosCalculable (Child *child, bool allocated) { DBG_OBJ_ENTER ("resize.oofm", 0, "isHPosCalculable", "[%p], %s", child->widget, boolToStr (allocated)); - bool b = - allocated || (isHPosComplete (child) && child->reference == container); + bool b = allocated || isHPosComplete (child); DBG_OBJ_LEAVE_VAL ("%s", boolToStr (b)); return b; } @@ -395,8 +393,7 @@ bool OOFPosAbsLikeMgr::isVPosCalculable (Child *child, bool allocated) { DBG_OBJ_ENTER ("resize.oofm", 0, "isVPosCalculable", "[%p], %s", child->widget, boolToStr (allocated)); - bool b = - allocated || (isVPosComplete (child) && child->reference == container); + bool b = allocated || isVPosComplete (child); DBG_OBJ_LEAVE_VAL ("%s", boolToStr (b)); return b; } @@ -475,28 +472,15 @@ void OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild (Child *child, int refWidth, left, right, width, widthDefined ? "true" : "false"); if (xPtr) { - if (!leftDefined && !rightDefined) { - assert (child->generator == container || - (containerAllocationState != NOT_ALLOCATED - && child->generator->wasAllocated ())); - *xPtr = - child->x + (child->generator == container ? 0 : - child->generator->getAllocation()->x - - (containerAllocation.x + containerBoxOffsetX ())); - } else { - assert (child->reference == container || - (containerAllocationState != NOT_ALLOCATED - && child->reference->wasAllocated ())); - int xBase = child->reference == container ? 0 : - child->generator->getAllocation()->x - containerAllocation.x; - DBG_OBJ_MSGF ("resize.oofm", 0, "=> xBase = %d", xBase); - + if (!leftDefined && !rightDefined) + *xPtr = generatorPosX (child) + child->x; + else { if (!leftDefined && rightDefined) - *xPtr = xBase + refWidth - width - right; + *xPtr = refWidth - width - right; else if (leftDefined && !rightDefined) - *xPtr = xBase + left; + *xPtr = left; else { - *xPtr = xBase + left; + *xPtr = left; if (!widthDefined) { width = refWidth - (left + right); DBG_OBJ_MSGF ("resize.oofm", 0, "=> width (corrected) = %d", @@ -555,28 +539,15 @@ void OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild (Child *child, int refHeight, heightDefined ? "true" : "false"); if (yPtr) { - if (!topDefined && !bottomDefined) { - assert (child->generator == container || - (containerAllocationState != NOT_ALLOCATED - && child->generator->wasAllocated ())); - *yPtr = - child->y + (child->generator == container ? 0 : - child->generator->getAllocation()->y - - (containerAllocation.y + containerBoxOffsetY ())); - } else { - assert (child->reference == container || - (containerAllocationState != NOT_ALLOCATED - && child->reference->wasAllocated ())); - int yBase = child->reference == container ? 0 : - child->generator->getAllocation()->y - containerAllocation.y; - DBG_OBJ_MSGF ("resize.oofm", 0, "=> yBase = %d", yBase); - + if (!topDefined && !bottomDefined) + *yPtr = generatorPosY (child) + child->y; + else { if (!topDefined && bottomDefined) - *yPtr = yBase + refHeight - (ascent + descent) - bottom; + *yPtr = refHeight - (ascent + descent) - bottom; else if (topDefined && !bottomDefined) - *yPtr = yBase + top; + *yPtr = top; else { - *yPtr = yBase + top; + *yPtr = top; if (!heightDefined) { int height = refHeight - (top + bottom); splitHeightPreserveAscent (height, &ascent, &descent); diff --git a/dw/oofposabslikemgr.hh b/dw/oofposabslikemgr.hh index 61c3ed8c..a561a407 100644 --- a/dw/oofposabslikemgr.hh +++ b/dw/oofposabslikemgr.hh @@ -2,6 +2,7 @@ #define __DW_OOFPOSABSLIKEMGR_HH__ #include "oofpositionedmgr.hh" +#include "oofawarewidget.hh" namespace dw { @@ -23,6 +24,23 @@ protected: enum { NOT_ALLOCATED, IN_ALLOCATION, WAS_ALLOCATED } containerAllocationState; + inline bool generatorPosDefined (Child *child) { + return child->generator == container || + (containerAllocationState != NOT_ALLOCATED + && child->generator->wasAllocated ()); + } + inline int generatorPosX (Child *child) { + assert (generatorPosDefined (child)); + return child->generator == container ? 0 : + child->generator->getAllocation()->x + - (containerAllocation.x + containerBoxOffsetX ()); + } + inline int generatorPosY (Child *child) { + assert (generatorPosDefined (child)); + return child->generator == container ? 0 : + child->generator->getAllocation()->y + - (containerAllocation.y + containerBoxOffsetY ()); + } bool doChildrenExceedContainer (); bool haveExtremesChanged (); diff --git a/dw/oofposabsmgr.cc b/dw/oofposabsmgr.cc index 5dc8e7f4..ece2eeba 100644 --- a/dw/oofposabsmgr.cc +++ b/dw/oofposabsmgr.cc @@ -35,20 +35,6 @@ OOFPosAbsMgr::~OOFPosAbsMgr () DBG_OBJ_DELETE (); } -bool OOFPosAbsMgr::isReference (core::Widget *widget) -{ - // Only the toplevel widget (as for all) as well as absolutely, - // relatively, and fixedly positioned elements constitute the - // containing block (i. e. the reference widget) for absolutely - // positioned elements (But neither floats nor other elements like - // table cells, or elements with 'overview' set to another value - // than 'visible'). - - return widget->instanceOf (OOFAwareWidget::CLASS_ID) && - (widget->getParent() == NULL || - OOFAwareWidget::testWidgetPositioned (widget)); -} - // Comment for all containerBox* implementations: for the toplevel // widget, assume margin = border = 0 (should perhaps set so when // widgets are constructed), so that the padding area is actually the diff --git a/dw/oofposabsmgr.hh b/dw/oofposabsmgr.hh index 5e00a4ac..153f8ff2 100644 --- a/dw/oofposabsmgr.hh +++ b/dw/oofposabsmgr.hh @@ -10,7 +10,6 @@ namespace oof { class OOFPosAbsMgr: public OOFPosAbsLikeMgr { protected: - bool isReference (core::Widget *widget); int containerBoxOffsetX (); int containerBoxOffsetY (); int containerBoxRestWidth (); diff --git a/dw/oofposfixedmgr.cc b/dw/oofposfixedmgr.cc index ef26de41..1b36cd5c 100644 --- a/dw/oofposfixedmgr.cc +++ b/dw/oofposfixedmgr.cc @@ -34,11 +34,6 @@ OOFPosFixedMgr::~OOFPosFixedMgr () DBG_OBJ_DELETE (); } -bool OOFPosFixedMgr::isReference (core::Widget *widget) -{ - return widget->getParent () == NULL; -} - int OOFPosFixedMgr::containerBoxOffsetX () { return 0; diff --git a/dw/oofposfixedmgr.hh b/dw/oofposfixedmgr.hh index efe46391..3f7b9683 100644 --- a/dw/oofposfixedmgr.hh +++ b/dw/oofposfixedmgr.hh @@ -10,7 +10,6 @@ namespace oof { class OOFPosFixedMgr: public OOFPosAbsLikeMgr { protected: - bool isReference (core::Widget *widget); int containerBoxOffsetX (); int containerBoxOffsetY (); int containerBoxRestWidth (); diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc index fc4ad938..db5cc5e6 100644 --- a/dw/oofpositionedmgr.cc +++ b/dw/oofpositionedmgr.cc @@ -93,17 +93,7 @@ int OOFPositionedMgr::addWidgetOOF (Widget *widget, OOFAwareWidget *generator, DBG_OBJ_ENTER ("construct.oofm", 0, "addWidgetOOF", "%p, %p, %d", widget, generator, externalIndex); - Widget *reference = NULL; - - for (Widget *widget2 = generator; reference == NULL && widget2 != container; - widget2 = widget2->getParent ()) - if (isReference (widget2)) - reference = widget2; - - if (reference == NULL) - reference = container; - - Child *child = new Child (widget, generator, reference, externalIndex); + Child *child = new Child (widget, generator, externalIndex); children->put (child); childrenByWidget->put (new TypedPointer<Widget> (widget), child); @@ -112,7 +102,6 @@ int OOFPositionedMgr::addWidgetOOF (Widget *widget, OOFAwareWidget *generator, DBG_OBJ_ARRSET_PTR ("children", children->size() - 1, widget); DBG_OBJ_SET_PTR_O (widget, "<Positioned>.generator", generator); - DBG_OBJ_SET_PTR_O (widget, "<Positioned>.reference", reference); DBG_OBJ_SET_NUM_O (widget, "<Positioned>.externalIndex", externalIndex); DBG_OBJ_MSGF ("construct.oofm", 1, "=> %d", subRef); diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh index 2962a9d1..a4318a08 100644 --- a/dw/oofpositionedmgr.hh +++ b/dw/oofpositionedmgr.hh @@ -13,19 +13,16 @@ protected: class Child: public lout::object::Object { public: - core::Widget *widget, *reference; + core::Widget *widget; OOFAwareWidget *generator; int externalIndex, x, y; inline Child (core::Widget *widget, OOFAwareWidget *generator, - core::Widget *reference, int externalIndex) + int externalIndex) { this->widget = widget; this->generator = generator; - this->reference = reference; this->externalIndex = externalIndex; - x = y = 0; } + this->externalIndex = externalIndex; x = y = 0; } }; - virtual bool isReference (core::Widget *widget) = 0; - OOFAwareWidget *container; core::Allocation containerAllocation; diff --git a/dw/oofposrelmgr.cc b/dw/oofposrelmgr.cc index 8980e079..4799e33c 100644 --- a/dw/oofposrelmgr.cc +++ b/dw/oofposrelmgr.cc @@ -197,12 +197,6 @@ int OOFPosRelMgr::getAvailHeightOfChild (Widget *child, bool forceValue) return 0; } -bool OOFPosRelMgr::isReference (Widget *widget) -{ - // TODO Remove soon. This implementation will imply reference = container. - return false; -} - } // namespace oof } // namespace dw diff --git a/dw/oofposrelmgr.hh b/dw/oofposrelmgr.hh index bd70ddeb..dd9a8144 100644 --- a/dw/oofposrelmgr.hh +++ b/dw/oofposrelmgr.hh @@ -11,8 +11,6 @@ namespace oof { class OOFPosRelMgr: public OOFPositionedMgr { protected: - bool isReference (core::Widget *widget); - int getChildPosDim (core::style::Length posCssValue, core::style::Length negCssValue, int refPos, int refLength); |