diff --git a/doomsday/client/include/ui/widgets/scrollareawidget.h b/doomsday/client/include/ui/widgets/scrollareawidget.h index 96d2fea552..f460369ffc 100644 --- a/doomsday/client/include/ui/widgets/scrollareawidget.h +++ b/doomsday/client/include/ui/widgets/scrollareawidget.h @@ -47,6 +47,7 @@ class ScrollAreaWidget : public GuiWidget void setContentWidth(de::Rule const &width); void setContentHeight(int height); void setContentHeight(de::Rule const &height); + void setContentSize(de::Rule const &width, de::Rule const &height); void setContentSize(de::Vector2i const &size); void modifyContentWidth(int delta); diff --git a/doomsday/client/src/ui/widgets/aboutdialog.cpp b/doomsday/client/src/ui/widgets/aboutdialog.cpp index 3045056323..aa7bb71ac0 100644 --- a/doomsday/client/src/ui/widgets/aboutdialog.cpp +++ b/doomsday/client/src/ui/widgets/aboutdialog.cpp @@ -85,8 +85,7 @@ AboutDialog::AboutDialog() : DialogWidget("about") .setAnchorPoint(Vector2f(.5f, 0)); // Total size of the dialog's content. - area().setContentWidth(layout.width()); - area().setContentHeight(layout.height() + homepage->rule().height()); + area().setContentSize(layout.width(), layout.height() + homepage->rule().height()); buttons().items() << new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default, tr("Close")); diff --git a/doomsday/client/src/ui/widgets/notificationwidget.cpp b/doomsday/client/src/ui/widgets/notificationwidget.cpp index b86404b7d1..13494f511e 100644 --- a/doomsday/client/src/ui/widgets/notificationwidget.cpp +++ b/doomsday/client/src/ui/widgets/notificationwidget.cpp @@ -18,6 +18,7 @@ #include "ui/widgets/notificationwidget.h" #include "ui/widgets/guirootwidget.h" +#include "ui/widgets/sequentiallayout.h" #include #include @@ -98,44 +99,26 @@ DENG2_PIMPL(NotificationWidget) { Rule const &gap = self.style().rules().rule("unit"); - Rule const *totalWidth = 0; - Rule const *totalHeight = 0; + // The children are laid out simply in a row from right to left. + SequentialLayout layout(self.rule().right(), self.rule().top(), ui::Left); - WidgetList const children = self.Widget::children(); - for(int i = 0; i < children.size(); ++i) + bool first = true; + foreach(Widget *child, self.childWidgets()) { - GuiWidget &w = children[i]->as(); - - // The children are laid out simply in a row from right to left. - w.rule().setInput(Rule::Top, self.rule().top()); - if(i > 0) - { - w.rule().setInput(Rule::Right, children[i - 1]->as().rule().left() - gap); - changeRef(totalWidth, *totalWidth + gap + w.rule().width()); - } - else + GuiWidget &w = child->as(); + if(first) { - w.rule().setInput(Rule::Right, self.rule().right()); - totalWidth = holdRef(w.rule().width()); - } - - if(!totalHeight) - { - totalHeight = holdRef(w.rule().height()); + layout << w; + first = false; } else { - changeRef(totalHeight, OperatorRule::maximum(*totalHeight, w.rule().height())); + layout.append(w, gap); } } // Update the total size of the notification area. - self.rule() - .setInput(Rule::Width, *totalWidth) - .setInput(Rule::Height, *totalHeight); - - releaseRef(totalWidth); - releaseRef(totalHeight); + self.rule().setSize(layout.width(), layout.height()); } void show() diff --git a/doomsday/client/src/ui/widgets/scrollareawidget.cpp b/doomsday/client/src/ui/widgets/scrollareawidget.cpp index 17045426af..af04a1f782 100644 --- a/doomsday/client/src/ui/widgets/scrollareawidget.cpp +++ b/doomsday/client/src/ui/widgets/scrollareawidget.cpp @@ -185,6 +185,13 @@ void ScrollAreaWidget::setContentHeight(Rule const &height) d->contentRule.setInput(Rule::Height, height); } +void ScrollAreaWidget::setContentSize(Rule const &width, Rule const &height) +{ + DENG2_GUARD(d); + setContentWidth(width); + setContentHeight(height); +} + void ScrollAreaWidget::setContentSize(Vector2i const &size) { DENG2_GUARD(d); diff --git a/doomsday/client/src/ui/widgets/sequentiallayout.cpp b/doomsday/client/src/ui/widgets/sequentiallayout.cpp index aed9b98c6c..3500493198 100644 --- a/doomsday/client/src/ui/widgets/sequentiallayout.cpp +++ b/doomsday/client/src/ui/widgets/sequentiallayout.cpp @@ -83,17 +83,19 @@ DENG2_PIMPL(SequentialLayout) void append(GuiWidget *widget, Rule const *spaceBefore) { + if(spaceBefore) + { + advancePos(*spaceBefore); + } + + if(!widget) return; + widgets << widget; // Override the widget's size as requested. if(fixedWidth) widget->rule().setInput(Rule::Width, *fixedWidth); if(fixedHeight) widget->rule().setInput(Rule::Height, *fixedHeight); - if(spaceBefore) - { - advancePos(*spaceBefore); - } - RuleRectangle &rule = widget->rule(); // Update the minor axis.