diff options
-rw-r--r-- | dw/ui.cc | 8 | ||||
-rw-r--r-- | dw/widget.cc | 46 | ||||
-rw-r--r-- | dw/widget.hh | 6 |
3 files changed, 49 insertions, 11 deletions
@@ -271,18 +271,24 @@ ComplexButtonResource::ComplexButtonResource () void ComplexButtonResource::init (Widget *widget) { - this->childWidget = widget; + childWidget = widget; layout = new Layout (createPlatform ()); setLayout (layout); DBG_OBJ_ASSOC_CHILD (layout); layout->setWidget (widget); layout->connect (&layoutReceiver); + + if (getEmbed ()) + childWidget->setQuasiParent (getEmbed ()); } void ComplexButtonResource::setEmbed (Embed *embed) { ButtonResource::setEmbed (embed); + + if (childWidget) + childWidget->setQuasiParent (getEmbed ()); } ComplexButtonResource::~ComplexButtonResource () diff --git a/dw/widget.cc b/dw/widget.cc index a04a767c..44c02436 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -70,7 +70,7 @@ Widget::Widget () registerName ("dw::core::Widget", &CLASS_ID); flags = (Flags)(NEEDS_RESIZE | EXTREMES_CHANGED); - parent = generator = container = NULL; + parent = quasiParent = generator = container = NULL; DBG_OBJ_SET_PTR ("container", container); layout = NULL; @@ -174,6 +174,15 @@ void Widget::setParent (Widget *parent) notifySetParent(); } +void Widget::setQuasiParent (Widget *quasiParent) +{ + this->quasiParent = quasiParent; + + // More to do? Compare with setParent(). + + DBG_OBJ_SET_PTR ("quasiParent", quasiParent); +} + void Widget::queueDrawArea (int x, int y, int width, int height) { /** \todo Maybe only the intersection? */ @@ -514,7 +523,7 @@ int Widget::getAvailWidth (bool forceValue) int width; - if (parent == NULL) { + if (parent == NULL && quasiParent == NULL) { DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport"); DBG_OBJ_MSG_START (); @@ -539,11 +548,16 @@ int Widget::getAvailWidth (bool forceValue) } DBG_OBJ_MSG_END (); - } else { + } else if (parent) { DBG_OBJ_MSG ("resize", 1, "delegated to parent"); DBG_OBJ_MSG_START (); width = parent->getAvailWidthOfChild (this, forceValue); DBG_OBJ_MSG_END (); + } else /* if (quasiParent) */ { + DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent"); + DBG_OBJ_MSG_START (); + width = quasiParent->getAvailWidthOfChild (this, forceValue); + DBG_OBJ_MSG_END (); } DBG_OBJ_MSGF ("resize", 1, "=> %d", width); @@ -565,7 +579,7 @@ int Widget::getAvailHeight (bool forceValue) int height; - if (parent == NULL) { + if (parent == NULL && quasiParent == NULL) { DBG_OBJ_MSG ("resize", 1, "no parent, regarding viewport"); DBG_OBJ_MSG_START (); @@ -590,10 +604,15 @@ int Widget::getAvailHeight (bool forceValue) } DBG_OBJ_MSG_END (); - } else { + } else if (parent) { DBG_OBJ_MSG ("resize", 1, "delegated to parent"); DBG_OBJ_MSG_START (); - height = container->getAvailHeightOfChild (this, forceValue); + height = quasiParent->getAvailHeightOfChild (this, forceValue); + DBG_OBJ_MSG_END (); + } else /* if (quasiParent) */ { + DBG_OBJ_MSG ("resize", 1, "delegated to quasiParent"); + DBG_OBJ_MSG_START (); + height = quasiParent->getAvailHeightOfChild (this, forceValue); DBG_OBJ_MSG_END (); } @@ -612,7 +631,7 @@ void Widget::correctRequisition (Requisition *requisition, requisition->width, requisition->ascent, requisition->descent); - if (container == NULL) { + if (container == NULL && quasiParent == NULL) { if (style::isAbsLength (getStyle()->width)) { DBG_OBJ_MSGF ("resize", 1, "absolute width: %dpx", style::absLengthVal (getStyle()->width)); @@ -649,8 +668,12 @@ void Widget::correctRequisition (Requisition *requisition, &requisition->ascent, &requisition->descent); #endif } - } else + } else if (container) container->correctRequisitionOfChild (this, requisition, splitHeightFun); + else // if (quasiParent) + // Here, quasiParent plays the same role as the container. + quasiParent->correctRequisitionOfChild (this, requisition, + splitHeightFun); DBG_OBJ_MSGF ("resize", 1, "=> %d * (%d + %d)", requisition->width, requisition->ascent, @@ -666,7 +689,7 @@ void Widget::correctExtremes (Extremes *extremes) extremes->minWidth, extremes->minWidthIntrinsic, extremes->maxWidth, extremes->maxWidthIntrinsic); - if (container == NULL) { + if (container == NULL && quasiParent == NULL) { if (style::isAbsLength (getStyle()->width)) extremes->minWidth = extremes->maxWidth = style::absLengthVal (getStyle()->width) + boxDiffWidth (); @@ -677,8 +700,11 @@ void Widget::correctExtremes (Extremes *extremes) extremes->minWidth = extremes->maxWidth = applyPerWidth (viewportWidth, getStyle()->width); } - } else + } else if (container) container->correctExtremesOfChild (this, extremes); + else // if (quasiParent) + // Here, quasiParent plays the same role as the container. + quasiParent->correctExtremesOfChild (this, extremes); DBG_OBJ_MSGF ("resize", 1, "=> %d / %d", extremes->minWidth, extremes->maxWidth); diff --git a/dw/widget.hh b/dw/widget.hh index d045ffc2..bfbf1e91 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -105,6 +105,11 @@ private: Widget *parent; /** + * \brief ... + */ + Widget *quasiParent; + + /** * \brief The generating widget, NULL for top-level widgets, or if * not set; in the latter case, the effective generator (see * getGenerator) is the parent. @@ -390,6 +395,7 @@ public: inline bool wasAllocated () { return flags & WAS_ALLOCATED; } void setParent (Widget *parent); + void setQuasiParent (Widget *quasiParent); void setGenerator (Widget *generator) { this->generator = generator; } |