Navigation Menu

Skip to content

Commit

Permalink
libappfw: Added an inverted style for TabWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 10, 2014
1 parent 3a688de commit c657191
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doomsday/libappfw/include/de/widgets/tabwidget.h
Expand Up @@ -52,6 +52,8 @@ class LIBAPPFW_PUBLIC TabWidget : public GuiWidget
public:
TabWidget(String const &name = "");

void useInvertedStyle();

/**
* Items representing the tabs in the widget.
*
Expand Down
28 changes: 27 additions & 1 deletion doomsday/libappfw/src/widgets/tabwidget.cpp
Expand Up @@ -33,11 +33,13 @@ DENG2_PIMPL(TabWidget)
ui::Data::Pos current;
MenuWidget *buttons;
bool needUpdate;
bool invertedStyle;

Instance(Public *i)
: Base(i)
, current(0)
, needUpdate(false)
, invertedStyle(false)
{
self.add(buttons = new MenuWidget);
buttons->enableScrolling(false);
Expand All @@ -63,6 +65,11 @@ DENG2_PIMPL(TabWidget)
btn.setFont("tab.label");
btn.margins().set("dialog.gap");

if(invertedStyle)
{
btn.useInfoStyle();
}

btn.audienceForPress() += this;
}

Expand Down Expand Up @@ -98,7 +105,16 @@ DENG2_PIMPL(TabWidget)
bool const sel = (i == current);
ButtonWidget &w = buttons->itemWidget<ButtonWidget>(buttons->items().at(i));
w.setFont(sel? "tab.selected" : "tab.label");
w.setTextColor(sel? "tab.selected" : "text");
if(!invertedStyle)
{
w.setTextColor(sel? "tab.selected" : "text");
w.setHoverTextColor(sel? "tab.selected" : "text");
}
else
{
w.setTextColor(sel? "tab.inverted.selected" : "inverted.text");
w.setHoverTextColor(sel? "tab.inverted.selected" : "inverted.text");
}
}
}
};
Expand All @@ -109,6 +125,16 @@ TabWidget::TabWidget(String const &name)
rule().setInput(Rule::Height, d->buttons->rule().height());
}

void TabWidget::useInvertedStyle()
{
d->invertedStyle = true;
foreach(Widget *w, d->buttons->childWidgets())
{
// Restyle each existing button.
w->as<ButtonWidget>().useInfoStyle();
}
}

ui::Data &TabWidget::items()
{
return d->buttons->items();
Expand Down

0 comments on commit c657191

Please sign in to comment.