diff options
Diffstat (limited to 'dw/oofposrelmgr.cc')
-rw-r--r-- | dw/oofposrelmgr.cc | 87 |
1 files changed, 69 insertions, 18 deletions
diff --git a/dw/oofposrelmgr.cc b/dw/oofposrelmgr.cc index ecb47ba4..3777755c 100644 --- a/dw/oofposrelmgr.cc +++ b/dw/oofposrelmgr.cc @@ -20,6 +20,10 @@ #include "oofposrelmgr.hh" #include "oofawarewidget.hh" +using namespace dw::core; +using namespace lout::object; +using namespace lout::misc; + namespace dw { namespace oof { @@ -50,8 +54,7 @@ void OOFPosRelMgr::markExtremesChange (int ref) { } -void OOFPosRelMgr::calcWidgetRefSize (core::Widget *widget, - core::Requisition *size) +void OOFPosRelMgr::calcWidgetRefSize (Widget *widget, Requisition *size) { DBG_OBJ_ENTER ("resize.oofm", 0, "calcWidgetRefSize", "%p", widget); widget->sizeRequest (size); @@ -59,36 +62,84 @@ void OOFPosRelMgr::calcWidgetRefSize (core::Widget *widget, size->width, size->ascent, size->descent); } -bool OOFPosRelMgr::isReference (core::Widget *widget) + +void OOFPosRelMgr::sizeAllocateStart (OOFAwareWidget *caller, + Allocation *allocation) { - // TODO Remove soon. This implementation will imply reference = container. - return false; + containerAllocation = *allocation; } -// TODO: Check all containerBox* implementations. +void OOFPosRelMgr::sizeAllocateEnd (OOFAwareWidget *caller) +{ + if (caller == container) { + for (int i = 0; i < children->size (); i++) { + Child *child = children->get(i); + + Requisition childReq; + child->widget->sizeRequest (&childReq); + + Allocation childAlloc; + childAlloc.x = containerAllocation.x + + container->getStyle()->boxOffsetX () + child->x; + childAlloc.y = containerAllocation.y + + container->getStyle()->boxOffsetY () + child->y; + childAlloc.width = childReq.width; + childAlloc.ascent = childReq.ascent; + childAlloc.descent = childReq.descent; + child->widget->sizeAllocate (&childAlloc); + } + } +} -int OOFPosRelMgr::containerBoxOffsetX () +void OOFPosRelMgr::getSize (Requisition *containerReq, int *oofWidth, + int *oofHeight) { - return container->getParent () ? - container->boxOffsetX () - container->getStyle()->padding.left : 0; + *oofWidth = *oofHeight = 0; + + for (int i = 0; i < children->size (); i++) { + Child *child = children->get(i); + Requisition childReq; + child->widget->sizeRequest (&childReq); + *oofWidth = max (*oofWidth, child->x + childReq.width); + *oofHeight = max (*oofHeight, + child->y + childReq.ascent + childReq.descent); + } } -int OOFPosRelMgr::containerBoxOffsetY () +void OOFPosRelMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth, + int *oofMaxWidth) { - return container->getParent () ? - container->boxOffsetY () - container->getStyle()->padding.top : 0; + *oofMinWidth = *oofMaxWidth = 0; + + for (int i = 0; i < children->size (); i++) { + Child *child = children->get(i); + Extremes childExtr; + child->widget->getExtremes (&childExtr); + *oofMinWidth = max (*oofMinWidth, child->x + childExtr.minWidth); + *oofMaxWidth = max (*oofMaxWidth, child->x + childExtr.maxWidth); + } } -int OOFPosRelMgr::containerBoxRestWidth () +int OOFPosRelMgr::getAvailWidthOfChild (Widget *child, bool forceValue) { - return container->getParent () ? - container->boxRestWidth () - container->getStyle()->padding.right : 0; + TypedPointer<Widget> key (child); + Child *tshild = childrenByWidget->get (&key); + assert (tshild); + return tshild->generator->getAvailWidthOfChild (child, forceValue); } -int OOFPosRelMgr::containerBoxRestHeight () +int OOFPosRelMgr::getAvailHeightOfChild (Widget *child, bool forceValue) { - return container->getParent () ? - container->boxRestHeight () - container->getStyle()->padding.bottom : 0; + TypedPointer<Widget> key (child); + Child *tshild = childrenByWidget->get (&key); + assert (tshild); + return tshild->generator->getAvailHeightOfChild (child, forceValue); +} + +bool OOFPosRelMgr::isReference (Widget *widget) +{ + // TODO Remove soon. This implementation will imply reference = container. + return false; } } // namespace oof |