Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
UI|Home: Smoothly animate heights of menu items
  • Loading branch information
skyjake committed Apr 22, 2016
1 parent 7f7a12c commit 639aa5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/ui/home/panelbuttonwidget.cpp
Expand Up @@ -38,11 +38,11 @@ PanelButtonWidget::PanelButtonWidget(String const &name)
setBehavior(Focusable);

d->drawer->rule()
.setInput(Rule::Top, label().rule().bottom())
.setInput(Rule::Top, icon().rule().bottom())
.setInput(Rule::Left, rule().left());

rule().setInput(Rule::Height, label().rule().height() +
d->drawer->rule().height());
rule().setInput(Rule::Height, new AnimationRule(label().rule().height() +
d->drawer->rule().height(), 0.3));
}

PanelWidget &PanelButtonWidget::panel()
Expand Down
16 changes: 9 additions & 7 deletions doomsday/apps/client/src/ui/widgets/homeitemwidget.cpp
Expand Up @@ -186,21 +186,23 @@ HomeItemWidget::HomeItemWidget(String const &name)
: GuiWidget(name)
, d(new Instance(this))
{
setBehavior(Focusable);
setBehavior(Focusable | ContentClipping);
addEventHandler(new Instance::ClickHandler(*this));

Rule const &iconSize = d->label->margins().height() +
style().fonts().font("default").height() +
style().fonts().font("default").lineSpacing();

AutoRef<Rule> smoothHeight(new AnimationRule(d->label->rule().height(), 0.3));

d->background->rule()
.setInput(Rule::Top, rule().top())
.setInput(Rule::Height, smoothHeight)
.setInput(Rule::Left, d->icon->rule().right())
.setInput(Rule::Right, rule().right())
.setInput(Rule::Bottom, d->label->rule().bottom());
.setInput(Rule::Right, rule().right());

d->icon->rule()
.setSize(iconSize, d->label->rule().height())
.setSize(iconSize, smoothHeight)
.setInput(Rule::Left, rule().left())
.setInput(Rule::Top, rule().top());
d->icon->set(Background(Background::BorderGlow,
Expand All @@ -210,10 +212,10 @@ HomeItemWidget::HomeItemWidget(String const &name)
.setInput(Rule::Top, rule().top())
.setInput(Rule::Left, d->icon->rule().right())
.setInput(Rule::Right, rule().right());
d->label->margins().setRight(*d->labelRightMargin +
rule("gap"));
d->label->margins().setRight(*d->labelRightMargin + rule("gap"));

rule().setInput(Rule::Height, d->label->rule().height());
// Use an animated height rule for smoother list layout behavior.
rule().setInput(Rule::Height, smoothHeight);
}

AssetGroup &HomeItemWidget::assets()
Expand Down

0 comments on commit 639aa5b

Please sign in to comment.