Skip to content

Commit

Permalink
Widgets|libappfw: Optional maximum height for dialogs
Browse files Browse the repository at this point in the history
The client's PackagesDialog now limits the maximum height to a
square shape, rather than allowing the dialog to extend to be tall
and narrow.
  • Loading branch information
skyjake committed Jun 25, 2017
1 parent 5272413 commit ec4e362
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/ui/dialogs/packagesdialog.cpp
Expand Up @@ -374,6 +374,8 @@ PackagesDialog::PackagesDialog(String const &titleText)
rightArea().setContentSize(d->browser->rule().width(), d->browser->rule().height());
d->browser->progress().rule().setRect(rightArea().rule());

setMaximumContentHeight(rule().width());

// Setup has been completed, so contents can be updated.
//d->browser->setPopulationEnabled(true);
refreshPackages();
Expand Down
4 changes: 3 additions & 1 deletion doomsday/sdk/libappfw/include/de/widgets/dialogwidget.h
Expand Up @@ -180,6 +180,8 @@ class LIBAPPFW_PUBLIC DialogWidget : public PopupWidget
*/
void setMinimumContentWidth(Rule const &minWidth);

void setMaximumContentHeight(Rule const &maxHeight);

MenuWidget &buttonsMenu();

/**
Expand Down Expand Up @@ -210,7 +212,7 @@ class LIBAPPFW_PUBLIC DialogWidget : public PopupWidget
* @param action Action to trigger after the dialog has been accepted.
*/
void setAcceptanceAction(RefArg<de::Action> action);

de::Action *acceptanceAction() const;

/**
Expand Down
13 changes: 12 additions & 1 deletion doomsday/sdk/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -102,6 +102,7 @@ DENG_GUI_PIMPL(DialogWidget)
QScopedPointer<Untrapper> untrapper;
DialogContentStylist stylist;
IndirectRule *minWidth;
Rule const *maxContentHeight = nullptr;

Impl(Public *i, Flags const &dialogFlags)
: Base(i)
Expand All @@ -112,7 +113,7 @@ DENG_GUI_PIMPL(DialogWidget)
, needButtonUpdate(false)
, animatingGlow(false)
{
minWidth = new IndirectRule;
minWidth = new IndirectRule;

// Initialize the border glow.
normalGlow = style().colors().colorf("glow").w;
Expand Down Expand Up @@ -223,6 +224,7 @@ DENG_GUI_PIMPL(DialogWidget)
~Impl()
{
releaseRef(minWidth);
releaseRef(maxContentHeight);
releaseRef(acceptAction);
}

Expand Down Expand Up @@ -263,6 +265,10 @@ DENG_GUI_PIMPL(DialogWidget)
{
changeRef(maxHeight, *maxHeight - self().anchor().top() - rule("gap"));
}
if (maxContentHeight)
{
changeRef(maxHeight, OperatorRule::minimum(*maxHeight, *maxContentHeight));
}

// Scrollable area content height.
AutoRef<Rule> areaContentHeight = area->contentRule().height() + area->margins().height();
Expand Down Expand Up @@ -495,6 +501,11 @@ void DialogWidget::setMinimumContentWidth(Rule const &minWidth)
d->minWidth->setSource(minWidth);
}

void DialogWidget::setMaximumContentHeight(const de::Rule &maxHeight)
{
changeRef(d->maxContentHeight, maxHeight);
}

MenuWidget &DialogWidget::buttonsMenu()
{
return *d->buttons;
Expand Down
3 changes: 0 additions & 3 deletions doomsday/sdk/libappfw/src/widgets/scrollareawidget.cpp
Expand Up @@ -59,9 +59,6 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
bool scrollBarHover = false;
Rectanglef scrollBarVisRect;
Rectanglef scrollBarLaneRect;
//Drawable drawable;
//GLUniform uMvpMatrix { "uMvpMatrix", GLUniform::Mat4 };
//GLUniform uColor { "uColor", GLUniform::Vec4 };
GuiVertexBuilder verts;

Impl(Public *i) : Base(i)
Expand Down

0 comments on commit ec4e362

Please sign in to comment.