Skip to content

Commit

Permalink
UI|Home|Widgets: Showing and hiding individual Home item action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 5, 2017
1 parent e7f18fc commit 361a2e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions doomsday/apps/client/include/ui/widgets/homeitemwidget.h
Expand Up @@ -76,6 +76,9 @@ class HomeItemWidget : public de::GuiWidget, public de::IAssetGroup

virtual void itemRightClicked();

protected:
void updateButtonLayout();

signals:
void mouseActivity();
void doubleClicked();
Expand Down
32 changes: 27 additions & 5 deletions doomsday/apps/client/src/ui/widgets/homeitemwidget.cpp
Expand Up @@ -135,7 +135,10 @@ DENG_GUI_PIMPL(HomeItemWidget)
buttonHideTimer.setSingleShot(true);
QObject::connect(&buttonHideTimer, &QTimer::timeout, [this] ()
{
for (auto *btn : buttons) btn->hide();
for (auto *button : buttons)
{
button->setAttribute(DontDrawContent);
}
});
}

Expand All @@ -152,7 +155,10 @@ DENG_GUI_PIMPL(HomeItemWidget)
label->rule().top(), ui::Right);
for (auto *button : buttons)
{
layout << *button;
if (!button->behavior().testFlag(Hidden))
{
layout << *button;
}
button->rule().setMidAnchorY(label->rule().midY());
}
changeRef(buttonsWidth, layout.width() + rule("gap"));
Expand All @@ -165,7 +171,18 @@ DENG_GUI_PIMPL(HomeItemWidget)
if (show)
{
buttonHideTimer.stop();
for (auto *button : buttons) button->show();
for (auto *button : buttons)
{
button->setAttribute(DontDrawContent, false);
button->setBehavior(Focusable);
}
}
else
{
for (auto *button : buttons)
{
button->setBehavior(Focusable, false);
}
}

TimeDelta const SPAN = (self().hasBeenUpdated()? 0.4 : 0.0);
Expand Down Expand Up @@ -379,7 +396,6 @@ bool HomeItemWidget::handleEvent(Event const &event)
}
}
}

return GuiWidget::handleEvent(event);
}

Expand Down Expand Up @@ -415,7 +431,8 @@ void HomeItemWidget::addButton(GuiWidget *widget)

d->buttons << widget;
d->label->add(widget);
widget->hide();
widget->setAttribute(DontDrawContent);
widget->setBehavior(Focusable, false);
d->updateButtonLayout();
}

Expand All @@ -441,3 +458,8 @@ void HomeItemWidget::setLabelMinimumRightMargin(Rule const &rule)
{
d->labelMinRightMargin->setSource(rule);
}

void HomeItemWidget::updateButtonLayout()
{
d->updateButtonLayout();
}

0 comments on commit 361a2e5

Please sign in to comment.