diff options
-rw-r--r-- | dw/layout.cc | 30 | ||||
-rw-r--r-- | dw/layout.hh | 3 |
2 files changed, 31 insertions, 2 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index 49f65b96..b9c6ff98 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -926,7 +926,8 @@ void Layout::resizeIdle () canvasHeightGreater = true; DBG_OBJ_SET_SYM ("canvasHeightGreater", canvasHeightGreater ? "true" : "false"); - // TODO tell widget about change. + assert (topLevel); // No toplevel widget would have no size. + containerSizeChanged (topLevel); } // Set viewport sizes. @@ -1295,7 +1296,32 @@ void Layout::viewportSizeChanged (View *view, int width, int height) DBG_OBJ_SET_NUM ("viewportWidth", viewportWidth); DBG_OBJ_SET_NUM ("viewportHeight", viewportHeight); - // TODO tell widget about change. + if (topLevel) + containerSizeChanged (topLevel); +} + +bool Layout::widgetAffectedByContainerSizeChange (Widget *widget) +{ + return true; // TODO only absolute dimensions? Depending on widget class? +} + +void Layout::containerSizeChanged (Widget *widget) +{ + if (widgetAffectedByContainerSizeChange (widget)) { + widget->queueResize (0, false); + + // TODO Wrong! Iteration must stop when the *container* (not the + // *parent*!) is unaffected. (Does not matter as long as + // widgetAffectedByContainerSizeChange() returns always true.) + + Iterator *it = + widget->iterator ((Content::Type) + (Content::WIDGET_IN_FLOW | Content::WIDGET_OOF_CONT), + false); + while (it->next ()) + containerSizeChanged (it->getContent()->widget); + it->unref (); + } } } // namespace core diff --git a/dw/layout.hh b/dw/layout.hh index 2120d877..0dc3cfbc 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -267,6 +267,9 @@ private: void enterResizeIdle () { resizeIdleCounter++; } void leaveResizeIdle () { resizeIdleCounter--; } + bool widgetAffectedByContainerSizeChange (Widget *widget); + void containerSizeChanged (Widget *widget); + public: Layout (Platform *platform); ~Layout (); |