diff --git a/doomsday/client/src/ui/framework/guirootwidget.cpp b/doomsday/client/src/ui/framework/guirootwidget.cpp index 6cb2f2774e..129b49a6ae 100644 --- a/doomsday/client/src/ui/framework/guirootwidget.cpp +++ b/doomsday/client/src/ui/framework/guirootwidget.cpp @@ -30,7 +30,8 @@ using namespace de; -DENG2_PIMPL(GuiRootWidget) +DENG2_PIMPL(GuiRootWidget), +DENG2_OBSERVES(Widget, ChildAddition) { ClientWindow *window; QScopedPointer atlas; ///< Shared atlas for most UI graphics/text. @@ -49,7 +50,9 @@ DENG2_PIMPL(GuiRootWidget) atlas(0), uTexAtlas("uTex", GLUniform::Sampler2D), noFramesDrawnYet(true) - {} + { + self.audienceForChildAddition += this; + } ~Instance() { @@ -166,6 +169,13 @@ DENG2_PIMPL(GuiRootWidget) } } } + + void widgetChildAdded(Widget &child) + { + // Make sure newly added children know the view size. + child.viewResized(); + child.notifyTree(&Widget::viewResized); + } }; GuiRootWidget::GuiRootWidget(ClientWindow *window) diff --git a/doomsday/client/src/ui/framework/guiwidget.cpp b/doomsday/client/src/ui/framework/guiwidget.cpp index 747feac588..6e9de7b253 100644 --- a/doomsday/client/src/ui/framework/guiwidget.cpp +++ b/doomsday/client/src/ui/framework/guiwidget.cpp @@ -29,6 +29,7 @@ using namespace de; DENG2_PIMPL(GuiWidget), +DENG2_OBSERVES(Widget, ChildAddition), DENG2_OBSERVES(ui::Margins, Change) #ifdef DENG2_DEBUG , DENG2_OBSERVES(Widget, ParentChange) @@ -76,6 +77,7 @@ DENG2_OBSERVES(ui::Margins, Change) uBlurStep ("uBlurStep", GLUniform::Vec2), uBlurWindow ("uWindow", GLUniform::Vec4) { + self.audienceForChildAddition += this; margins.audienceForChange += this; #ifdef DENG2_DEBUG @@ -118,6 +120,16 @@ DENG2_OBSERVES(ui::Margins, Change) } #endif + void widgetChildAdded(Widget &child) + { + if(self.hasRoot()) + { + // Make sure newly added children know the view size. + child.viewResized(); + child.notifyTree(&Widget::viewResized); + } + } + void initBlur() { if(blurInited) return; diff --git a/doomsday/client/src/ui/widgets/dialogwidget.cpp b/doomsday/client/src/ui/widgets/dialogwidget.cpp index 73070031a5..ea777a5ffb 100644 --- a/doomsday/client/src/ui/widgets/dialogwidget.cpp +++ b/doomsday/client/src/ui/widgets/dialogwidget.cpp @@ -490,10 +490,6 @@ void DialogWidget::prepare() d->updateContentHeight(); - // Make sure the newly added widget knows the view size. - viewResized(); - notifyTree(&Widget::viewResized); - PopupWidget::open(); } @@ -507,6 +503,7 @@ void DialogWidget::preparePopupForOpening() void DialogWidget::finish(int) { + root().setFocus(0); close(); } diff --git a/doomsday/client/src/ui/widgets/legacywidget.cpp b/doomsday/client/src/ui/widgets/legacywidget.cpp index 7c00984611..2b78696d38 100644 --- a/doomsday/client/src/ui/widgets/legacywidget.cpp +++ b/doomsday/client/src/ui/widgets/legacywidget.cpp @@ -18,6 +18,7 @@ #include "de_platform.h" #include "ui/widgets/legacywidget.h" +#include "clientapp.h" #include "ui/dd_input.h" #include "ui/ui_main.h" #include "ui/ui2_main.h" @@ -147,7 +148,11 @@ LegacyWidget::LegacyWidget(String const &name) void LegacyWidget::viewResized() { - if(BusyMode_Active() || isDisabled() || Sys_IsShuttingDown()) return; + if(BusyMode_Active() || isDisabled() || Sys_IsShuttingDown() || + !ClientApp::windowSystem().hasMain()) + { + return; + } LOG_AS("LegacyWidget"); LOG_TRACE("View resized to ") << root().viewSize().asText(); diff --git a/doomsday/client/src/ui/widgets/popupwidget.cpp b/doomsday/client/src/ui/widgets/popupwidget.cpp index 2a64c1c4c7..c0aef4a378 100644 --- a/doomsday/client/src/ui/widgets/popupwidget.cpp +++ b/doomsday/client/src/ui/widgets/popupwidget.cpp @@ -201,7 +201,7 @@ DENG_GUI_PIMPL(PopupWidget) } }; -PopupWidget::PopupWidget(String const &name) : d(new Instance(this)) +PopupWidget::PopupWidget(String const &name) : GuiWidget(name), d(new Instance(this)) { setBehavior(ChildHitClipping); @@ -337,7 +337,8 @@ void PopupWidget::viewResized() d->uMvpMatrix = root().projMatrix2D(); - update(); + requestGeometry(); + //update(); } void PopupWidget::update() @@ -400,8 +401,11 @@ void PopupWidget::open() // Reparent the popup into the root widget, on top of everything else. d->realParent = Widget::parent(); - d->realParent->remove(*this); - d->realParent->root().add(this); + if(d->realParent != &d->realParent->root()) + { + d->realParent->remove(*this); + d->realParent->root().add(this); + } unsetBehavior(DisableEventDispatchToChildren); @@ -439,8 +443,11 @@ void PopupWidget::dismiss() d->dismissTimer.stop(); // Move back to the original parent widget. - root().remove(*this); - d->realParent->add(this); + if(d->realParent != &root()) + { + root().remove(*this); + d->realParent->add(this); + } popupDismissed(); diff --git a/doomsday/client/src/ui/widgets/sliderwidget.cpp b/doomsday/client/src/ui/widgets/sliderwidget.cpp index 803ab98469..606c6b3164 100644 --- a/doomsday/client/src/ui/widgets/sliderwidget.cpp +++ b/doomsday/client/src/ui/widgets/sliderwidget.cpp @@ -459,9 +459,10 @@ bool SliderWidget::handleEvent(Event const &event) d->updateHover(event.as().pos()); } - if(d->state != Instance::Inert && event.type() == Event::MouseButton) + // Left mouse button can be used to drag/step the value. + if(d->state != Instance::Inert) { - switch(handleMouseClick(event)) + switch(handleMouseClick(event, MouseEvent::Left)) { case MouseClickStarted: d->startGrab(event.as());