From 41c60459864f504b89f9b08642c701402d9bef2d Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 1 Sep 2014 03:38:05 +0200 Subject: [PATCH] Realign all parent boxes when autosizedwidgets change size --- apps/openmw/mwgui/widgets.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 6a5a43be7..853b90b0f 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -544,19 +544,22 @@ namespace MWGui void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w) { - if (w->getParent () != 0) + MyGUI::Widget * parent = w->getParent(); + if (parent != 0) { - Box* b = dynamic_cast(w->getParent()); - if (b) - b->notifyChildrenSizeChanged (); - else + if (mExpandDirection == MyGUI::Align::Left) + { + int hdiff = getRequestedSize ().width - w->getSize().width; + w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0)); + } + w->setSize(getRequestedSize ()); + + while (parent != 0) { - if (mExpandDirection == MyGUI::Align::Left) - { - int hdiff = getRequestedSize ().width - w->getSize().width; - w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0)); - } - w->setSize(getRequestedSize ()); + Box * b = dynamic_cast(parent); + if (b) + b->notifyChildrenSizeChanged(); + parent = parent->getParent(); } } }