Skip to content

Commit

Permalink
libappfw|DialogWidget: Specifying a minimum width for a dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 30, 2014
1 parent 6554d2f commit 1d32f4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doomsday/libappfw/include/de/widgets/dialogwidget.h
Expand Up @@ -146,6 +146,15 @@ class LIBAPPFW_PUBLIC DialogWidget : public PopupWidget

ScrollAreaWidget &area();

/**
* Sets the rule for the minimum width of the dialog. The default is that the
* dialog is at least as wide as the content area, or all the button widths
* summed together.
*
* @param minWidth Custom minimum width for the dialog.
*/
void setMinimumContentWidth(Rule const &minWidth);

MenuWidget &buttonsMenu();

/**
Expand Down
12 changes: 11 additions & 1 deletion doomsday/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -98,6 +98,7 @@ public ChildWidgetOrganizer::IFilter
bool animatingGlow;
QScopedPointer<Untrapper> untrapper;
DialogContentStylist stylist;
IndirectRule *minWidth;

Instance(Public *i, Flags const &dialogFlags)
: Base(i)
Expand All @@ -108,6 +109,8 @@ public ChildWidgetOrganizer::IFilter
, needButtonUpdate(false)
, animatingGlow(false)
{
minWidth = new IndirectRule;

// Initialize the border glow.
normalGlow = style().colors().colorf("glow").w;
glow.setValue(normalGlow);
Expand Down Expand Up @@ -182,7 +185,8 @@ public ChildWidgetOrganizer::IFilter
// A blank container widget acts as the popup content parent.
container->rule().setInput(Rule::Width, OperatorRule::maximum(
area->rule().width(),
buttons->rule().width() + extraButtons->rule().width()));
buttons->rule().width() + extraButtons->rule().width(),
*minWidth));

if(flags.testFlag(WithHeading))
{
Expand All @@ -201,6 +205,7 @@ public ChildWidgetOrganizer::IFilter

~Instance()
{
releaseRef(minWidth);
releaseRef(acceptAction);
}

Expand Down Expand Up @@ -432,6 +437,11 @@ ScrollAreaWidget &DialogWidget::area()
return *d->area;
}

void DialogWidget::setMinimumContentWidth(Rule const &minWidth)
{
d->minWidth->setSource(minWidth);
}

MenuWidget &DialogWidget::buttonsMenu()
{
return *d->buttons;
Expand Down

0 comments on commit 1d32f4e

Please sign in to comment.