summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/oofposabslikemgr.cc98
-rw-r--r--dw/oofposabslikemgr.hh33
-rw-r--r--dw/oofposabsmgr.cc1
-rw-r--r--dw/oofpositionedmgr.cc83
-rw-r--r--dw/oofpositionedmgr.hh38
-rw-r--r--dw/oofposrelmgr.cc108
-rw-r--r--dw/oofposrelmgr.hh8
7 files changed, 193 insertions, 176 deletions
diff --git a/dw/oofposabslikemgr.cc b/dw/oofposabslikemgr.cc
index 43b86a74..5884957d 100644
--- a/dw/oofposabslikemgr.cc
+++ b/dw/oofposabslikemgr.cc
@@ -42,41 +42,6 @@ void OOFPosAbsLikeMgr::calcWidgetRefSize (Widget *widget, Requisition *size)
size->width = size->ascent = size->descent = 0;
}
-void OOFPosAbsLikeMgr::sizeAllocateStart (OOFAwareWidget *caller,
- Allocation *allocation)
-{
- DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateStart",
- "%p, (%d, %d, %d * (%d + %d))",
- caller, allocation->x, allocation->y, allocation->width,
- allocation->ascent, allocation->descent);
-
- if (caller == container) {
- if (containerAllocationState == NOT_ALLOCATED)
- containerAllocationState = IN_ALLOCATION;
- containerAllocation = *allocation;
- }
-
- DBG_OBJ_LEAVE ();
-}
-
-void OOFPosAbsLikeMgr::sizeAllocateEnd (OOFAwareWidget *caller)
-{
- DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller);
-
- if (caller == container) {
- sizeAllocateChildren ();
-
- bool extremesChanged = !allChildrenConsideredForExtremes ();
- if (extremesChanged || doChildrenExceedContainer () ||
- !allChildrenConsideredForSize ())
- container->oofSizeChanged (extremesChanged);
-
- containerAllocationState = WAS_ALLOCATED;
- }
-
- DBG_OBJ_LEAVE ();
-}
-
void OOFPosAbsLikeMgr::sizeAllocateChildren ()
{
DBG_OBJ_ENTER0 ("resize.oofm", 0, "sizeAllocateChildren");
@@ -104,52 +69,6 @@ void OOFPosAbsLikeMgr::sizeAllocateChildren ()
DBG_OBJ_LEAVE ();
}
-bool OOFPosAbsLikeMgr::doChildrenExceedContainer ()
-{
- DBG_OBJ_ENTER0 ("resize.oofm", 0, "doChildrenExceedContainer");
-
- // This method is called to determine whether the *requisition* of
- // the container must be recalculated. So, we check the allocations
- // of the children against the *requisition* of the container,
- // which may (e. g. within tables) differ from the new allocation.
- // (Generally, a widget may allocated at a different size.)
-
- Requisition containerReq;
- container->sizeRequest (&containerReq);
- bool exceeds = false;
-
- DBG_OBJ_MSG_START ();
-
- for (int i = 0; i < children->size () && !exceeds; i++) {
- Child *child = children->get (i);
- Allocation *childAlloc = child->widget->getAllocation ();
- DBG_OBJ_MSGF ("resize.oofm", 2,
- "Does childAlloc = (%d, %d, %d * %d) exceed container "
- "alloc+req = (%d, %d, %d * %d)?",
- childAlloc->x, childAlloc->y, childAlloc->width,
- childAlloc->ascent + childAlloc->descent,
- containerAllocation.x, containerAllocation.y,
- containerReq.width,
- containerReq.ascent + containerReq.descent);
- if (childAlloc->x + childAlloc->width
- > containerAllocation.x + containerReq.width ||
- childAlloc->y + childAlloc->ascent + childAlloc->descent
- > containerAllocation.y +
- containerReq.ascent + containerReq.descent) {
- exceeds = true;
- DBG_OBJ_MSG ("resize.oofm", 2, "Yes.");
- } else
- DBG_OBJ_MSG ("resize.oofm", 2, "No.");
- }
-
- DBG_OBJ_MSG_END ();
-
- DBG_OBJ_MSGF ("resize.oofm", 1, "=> %s", exceeds ? "true" : "false");
- DBG_OBJ_LEAVE ();
-
- return exceeds;
-}
-
void OOFPosAbsLikeMgr::getSize (Requisition *containerReq, int *oofWidth,
int *oofHeight)
{
@@ -193,7 +112,8 @@ void OOFPosAbsLikeMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth,
for (int i = 0; i < children->size(); i++) {
Child *child = children->get(i);
- // If clause: see getSize().
+ // Children whose position cannot be determined will be
+ // considered later in sizeAllocateEnd.
if (posXDefined (child)) {
int x, width;
Extremes childExtr;
@@ -408,13 +328,13 @@ void OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild (Child *child, int refWidth,
*xPtr = generatorPosX (child) + child->x;
else {
if (!leftDefined && rightDefined)
- *xPtr = refWidth - width - right;
+ *xPtr = refWidth - width - right - containerBoxRestWidth ();
else if (leftDefined && !rightDefined)
- *xPtr = left;
+ *xPtr = left + containerBoxOffsetX ();
else {
*xPtr = left;
if (!widthDefined) {
- width = refWidth - (left + right);
+ width = refWidth - (left + right + containerBoxDiffWidth ());
DBG_OBJ_MSGF ("resize.oofm", 0, "=> width (corrected) = %d",
width);
}
@@ -475,13 +395,15 @@ void OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild (Child *child, int refHeight,
*yPtr = generatorPosY (child) + child->y;
else {
if (!topDefined && bottomDefined)
- *yPtr = refHeight - (ascent + descent) - bottom;
+ *yPtr = refHeight - (ascent + descent) - bottom
+ - containerBoxDiffHeight ();
else if (topDefined && !bottomDefined)
- *yPtr = top;
+ *yPtr = top + containerBoxOffsetY ();
else {
*yPtr = top;
if (!heightDefined) {
- int height = refHeight - (top + bottom);
+ int height =
+ refHeight - (top + bottom + containerBoxDiffHeight ());
splitHeightPreserveAscent (height, &ascent, &descent);
DBG_OBJ_MSGF ("resize.oofm", 0,
"=> ascent + descent (corrected) = %d + %d",
diff --git a/dw/oofposabslikemgr.hh b/dw/oofposabslikemgr.hh
index ef78b602..f9e94a5d 100644
--- a/dw/oofposabslikemgr.hh
+++ b/dw/oofposabslikemgr.hh
@@ -2,7 +2,6 @@
#define __DW_OOFPOSABSLIKEMGR_HH__
#include "oofpositionedmgr.hh"
-#include "oofawarewidget.hh"
namespace dw {
@@ -21,35 +20,8 @@ protected:
inline int containerBoxDiffHeight ()
{ return containerBoxOffsetY () + containerBoxRestHeight (); }
- 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 ());
- }
-
- inline bool posXDefined (Child *child)
- { return posXAbsolute (child) || generatorPosDefined (child); }
-
- inline bool posYDefined (Child *child)
- { return posYAbsolute (child) || generatorPosDefined (child); }
-
- bool doChildrenExceedContainer ();
bool haveExtremesChanged ();
+
void sizeAllocateChildren ();
bool posXAbsolute (Child *child);
@@ -73,9 +45,6 @@ public:
void calcWidgetRefSize (core::Widget *widget, core::Requisition *size);
- void sizeAllocateStart (OOFAwareWidget *caller,
- core::Allocation *allocation);
- void sizeAllocateEnd (OOFAwareWidget *caller);
void getSize (core::Requisition *containerReq, int *oofWidth,
int *oofHeight);
void getExtremes (core::Extremes *containerExtr,
diff --git a/dw/oofposabsmgr.cc b/dw/oofposabsmgr.cc
index ece2eeba..c8bc64b1 100644
--- a/dw/oofposabsmgr.cc
+++ b/dw/oofposabsmgr.cc
@@ -18,7 +18,6 @@
*/
#include "oofposabsmgr.hh"
-#include "oofawarewidget.hh"
namespace dw {
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index afc2b945..28852258 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -18,7 +18,6 @@
*/
#include "oofpositionedmgr.hh"
-#include "oofawarewidget.hh"
#include "../lout/debug.hh"
using namespace lout::object;
@@ -67,6 +66,88 @@ OOFPositionedMgr::~OOFPositionedMgr ()
DBG_OBJ_DELETE ();
}
+void OOFPositionedMgr::sizeAllocateStart (OOFAwareWidget *caller,
+ Allocation *allocation)
+{
+ DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateStart",
+ "%p, (%d, %d, %d * (%d + %d))",
+ caller, allocation->x, allocation->y, allocation->width,
+ allocation->ascent, allocation->descent);
+
+ if (caller == container) {
+ if (containerAllocationState == NOT_ALLOCATED)
+ containerAllocationState = IN_ALLOCATION;
+ containerAllocation = *allocation;
+ }
+
+ DBG_OBJ_LEAVE ();
+}
+
+
+void OOFPositionedMgr::sizeAllocateEnd (OOFAwareWidget *caller)
+{
+ DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller);
+
+ if (caller == container) {
+ sizeAllocateChildren ();
+
+ bool extremesChanged = !allChildrenConsideredForExtremes ();
+ if (extremesChanged || doChildrenExceedContainer () ||
+ !allChildrenConsideredForSize ())
+ container->oofSizeChanged (extremesChanged);
+
+ containerAllocationState = WAS_ALLOCATED;
+ }
+
+ DBG_OBJ_LEAVE ();
+}
+
+bool OOFPositionedMgr::doChildrenExceedContainer ()
+{
+ DBG_OBJ_ENTER0 ("resize.oofm", 0, "doChildrenExceedContainer");
+
+ // This method is called to determine whether the *requisition* of
+ // the container must be recalculated. So, we check the allocations
+ // of the children against the *requisition* of the container,
+ // which may (e. g. within tables) differ from the new allocation.
+ // (Generally, a widget may allocated at a different size.)
+
+ Requisition containerReq;
+ container->sizeRequest (&containerReq);
+ bool exceeds = false;
+
+ DBG_OBJ_MSG_START ();
+
+ for (int i = 0; i < children->size () && !exceeds; i++) {
+ Child *child = children->get (i);
+ Allocation *childAlloc = child->widget->getAllocation ();
+ DBG_OBJ_MSGF ("resize.oofm", 2,
+ "Does childAlloc = (%d, %d, %d * %d) exceed container "
+ "alloc+req = (%d, %d, %d * %d)?",
+ childAlloc->x, childAlloc->y, childAlloc->width,
+ childAlloc->ascent + childAlloc->descent,
+ containerAllocation.x, containerAllocation.y,
+ containerReq.width,
+ containerReq.ascent + containerReq.descent);
+ if (childAlloc->x + childAlloc->width
+ > containerAllocation.x + containerReq.width ||
+ childAlloc->y + childAlloc->ascent + childAlloc->descent
+ > containerAllocation.y +
+ containerReq.ascent + containerReq.descent) {
+ exceeds = true;
+ DBG_OBJ_MSG ("resize.oofm", 2, "Yes.");
+ } else
+ DBG_OBJ_MSG ("resize.oofm", 2, "No.");
+ }
+
+ DBG_OBJ_MSG_END ();
+
+ DBG_OBJ_MSGF ("resize.oofm", 1, "=> %s", exceeds ? "true" : "false");
+ DBG_OBJ_LEAVE ();
+
+ return exceeds;
+}
+
void OOFPositionedMgr::containerSizeChangedForChildren ()
{
DBG_OBJ_ENTER0 ("resize", 0, "containerSizeChangedForChildren");
diff --git a/dw/oofpositionedmgr.hh b/dw/oofpositionedmgr.hh
index 380037b4..4edf11e8 100644
--- a/dw/oofpositionedmgr.hh
+++ b/dw/oofpositionedmgr.hh
@@ -1,7 +1,8 @@
-#ifndef __DW_OOFPOSITIONEDMGR_HH__
+ #ifndef __DW_OOFPOSITIONEDMGR_HH__
#define __DW_OOFPOSITIONEDMGR_HH__
#include "outofflowmgr.hh"
+#include "oofawarewidget.hh"
namespace dw {
@@ -24,6 +25,8 @@ protected:
OOFAwareWidget *container;
core::Allocation containerAllocation;
+ enum { NOT_ALLOCATED, IN_ALLOCATION, WAS_ALLOCATED }
+ containerAllocationState;
lout::container::typed::Vector<Child> *children;
lout::container::typed::HashTable<lout::object::TypedPointer
@@ -40,13 +43,46 @@ protected:
{ return getPosBorder (child->getStyle()->bottom, availHeight, result); }
bool getPosBorder (core::style::Length cssValue, int refLength, int *result);
+
bool allChildrenConsideredForSize ();
bool allChildrenConsideredForExtremes ();
+ bool doChildrenExceedContainer ();
+
+ virtual void sizeAllocateChildren () = 0;
+ virtual bool posXAbsolute (Child *child) = 0;
+ virtual bool posYAbsolute (Child *child) = 0;
+
+ 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;
+ }
+ inline int generatorPosY (Child *child) {
+ assert (generatorPosDefined (child));
+ return child->generator == container ? 0 :
+ child->generator->getAllocation()->y - containerAllocation.y;
+ }
+
+ inline bool posXDefined (Child *child)
+ { return posXAbsolute (child) || generatorPosDefined (child); }
+
+ inline bool posYDefined (Child *child)
+ { return posYAbsolute (child) || generatorPosDefined (child); }
+
public:
OOFPositionedMgr (OOFAwareWidget *container);
~OOFPositionedMgr ();
+ void sizeAllocateStart (OOFAwareWidget *caller,
+ core::Allocation *allocation);
+ void sizeAllocateEnd (OOFAwareWidget *caller);
+
void containerSizeChangedForChildren ();
void draw (core::View *view, core::Rectangle *area,
core::DrawingContext *context);
diff --git a/dw/oofposrelmgr.cc b/dw/oofposrelmgr.cc
index 4799e33c..8fb34cd9 100644
--- a/dw/oofposrelmgr.cc
+++ b/dw/oofposrelmgr.cc
@@ -75,41 +75,25 @@ void OOFPosRelMgr::calcWidgetRefSize (Widget *widget, Requisition *size)
}
-void OOFPosRelMgr::sizeAllocateStart (OOFAwareWidget *caller,
- Allocation *allocation)
+void OOFPosRelMgr::sizeAllocateChildren ()
{
- DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateStart",
- "%p, (%d, %d, %d * (%d + %d))",
- caller, allocation->x, allocation->y, allocation->width,
- allocation->ascent, allocation->descent);
+ DBG_OBJ_ENTER0 ("resize.oofm", 0, "sizeAllocateChildren");
- if (caller == container)
- containerAllocation = *allocation;
-
- DBG_OBJ_LEAVE ();
-}
-
-void OOFPosRelMgr::sizeAllocateEnd (OOFAwareWidget *caller)
-{
- DBG_OBJ_ENTER ("resize.oofm", 0, "sizeAllocateEnd", "%p", caller);
-
- if (caller == container) {
- for (int i = 0; i < children->size (); i++) {
- Child *child = children->get(i);
+ for (int i = 0; i < children->size (); i++) {
+ Child *child = children->get(i);
- Requisition childReq;
- child->widget->sizeRequest (&childReq);
+ Requisition childReq;
+ child->widget->sizeRequest (&childReq);
- Allocation *genAlloc = child->generator == container ?
- &containerAllocation : child->generator->getAllocation (),
- childAlloc;
- childAlloc.x = genAlloc->x + getChildPosX (child);
- childAlloc.y = genAlloc->y + getChildPosY (child);
- childAlloc.width = childReq.width;
- childAlloc.ascent = childReq.ascent;
- childAlloc.descent = childReq.descent;
- child->widget->sizeAllocate (&childAlloc);
- }
+ Allocation *genAlloc = child->generator == container ?
+ &containerAllocation : child->generator->getAllocation (),
+ childAlloc;
+ childAlloc.x = genAlloc->x + getChildPosX (child);
+ childAlloc.y = genAlloc->y + getChildPosY (child);
+ childAlloc.width = childReq.width;
+ childAlloc.ascent = childReq.ascent;
+ childAlloc.descent = childReq.descent;
+ child->widget->sizeAllocate (&childAlloc);
}
DBG_OBJ_LEAVE ();
@@ -122,12 +106,20 @@ void OOFPosRelMgr::getSize (Requisition *containerReq, int *oofWidth,
for (int i = 0; i < children->size (); i++) {
Child *child = children->get(i);
- Requisition childReq;
- child->widget->sizeRequest (&childReq);
- *oofWidth = max (*oofWidth, getChildPosX (child) + childReq.width);
- *oofHeight = max (*oofHeight,
- getChildPosX (child) + childReq.ascent
- + childReq.descent);
+
+ // Children whose position cannot be determined will be
+ // considered later in sizeAllocateEnd.
+ if (posXDefined (child) && posYDefined (child)) {
+ Requisition childReq;
+ child->widget->sizeRequest (&childReq);
+ *oofWidth = max (*oofWidth, getChildPosX (child) + childReq.width);
+ *oofHeight = max (*oofHeight,
+ getChildPosX (child) + childReq.ascent
+ + childReq.descent);
+
+ child->consideredForSize = true;
+ } else
+ child->consideredForSize = false;
}
}
@@ -138,21 +130,39 @@ void OOFPosRelMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth,
for (int i = 0; i < children->size (); i++) {
Child *child = children->get(i);
- Extremes childExtr;
- child->widget->getExtremes (&childExtr);
-
- // Put the extremes of the container in relation to the extremes
- // of the child, as in OOFPosAbsLikeMgr::getExtremes (see
- // comment there).
- *oofMinWidth = max (*oofMinWidth,
- getChildPosX (child, containerExtr->minWidth)
- + childExtr.minWidth);
- *oofMaxWidth = max (*oofMaxWidth,
- getChildPosX (child, containerExtr->maxWidth)
- + childExtr.maxWidth);
+
+ // Children whose position cannot be determined will be
+ // considered later in sizeAllocateEnd.
+ if (posXDefined (child)) {
+ Extremes childExtr;
+ child->widget->getExtremes (&childExtr);
+
+ // Put the extremes of the container in relation to the extremes
+ // of the child, as in OOFPosAbsLikeMgr::getExtremes (see
+ // comment there).
+ *oofMinWidth = max (*oofMinWidth,
+ getChildPosX (child, containerExtr->minWidth)
+ + childExtr.minWidth);
+ *oofMaxWidth = max (*oofMaxWidth,
+ getChildPosX (child, containerExtr->maxWidth)
+ + childExtr.maxWidth);
+
+ child->consideredForExtremes = true;
+ } else
+ child->consideredForExtremes = false;
}
}
+bool OOFPosRelMgr::posXAbsolute (Child *child)
+{
+ return false;
+}
+
+bool OOFPosRelMgr::posYAbsolute (Child *child)
+{
+ return false;
+}
+
int OOFPosRelMgr::getChildPosDim (style::Length posCssValue,
style::Length negCssValue, int refPos,
int refLength)
diff --git a/dw/oofposrelmgr.hh b/dw/oofposrelmgr.hh
index dd9a8144..841ee45b 100644
--- a/dw/oofposrelmgr.hh
+++ b/dw/oofposrelmgr.hh
@@ -2,7 +2,6 @@
#define __DW_OOFPOSRELMGR_HH__
#include "oofpositionedmgr.hh"
-#include "oofawarewidget.hh"
namespace dw {
@@ -11,6 +10,10 @@ namespace oof {
class OOFPosRelMgr: public OOFPositionedMgr
{
protected:
+ void sizeAllocateChildren ();
+ bool posXAbsolute (Child *child);
+ bool posYAbsolute (Child *child);
+
int getChildPosDim (core::style::Length posCssValue,
core::style::Length negCssValue, int refPos,
int refLength);
@@ -37,9 +40,6 @@ public:
void markExtremesChange (int ref);
void calcWidgetRefSize (core::Widget *widget, core::Requisition *size);
- void sizeAllocateStart (OOFAwareWidget *caller,
- core::Allocation *allocation);
- void sizeAllocateEnd (OOFAwareWidget *caller);
void getSize (core::Requisition *containerReq, int *oofWidth,
int *oofHeight);
void getExtremes (core::Extremes *containerExtr, int *oofMinWidth,