Skip to content

Commit

Permalink
libappfw|ButtonWidget: Changing background color
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 18, 2014
1 parent 4fb9744 commit c4ba7a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doomsday/libappfw/include/de/widgets/buttonwidget.h
Expand Up @@ -74,6 +74,8 @@ class LIBAPPFW_PUBLIC ButtonWidget : public LabelWidget
*/
void setHoverTextColor(DotPath const &hoverTextId, HoverColorMode mode = ModulateColor);

void setBackgroundColor(DotPath const &bgColorId);

/**
* Sets the action of the button. It gets triggered when the button is
* pressed.
Expand Down
12 changes: 10 additions & 2 deletions doomsday/libappfw/src/widgets/buttonwidget.cpp
Expand Up @@ -30,6 +30,7 @@ DENG2_OBSERVES(Action, Triggered)
State state;
DotPath hoverTextColor;
DotPath originalTextColor;
DotPath bgColorId;
HoverColorMode hoverColorMode;
Action *action;
Animation scale;
Expand All @@ -39,6 +40,7 @@ DENG2_OBSERVES(Action, Triggered)
Instance(Public *i)
: Base(i)
, state(Up)
, bgColorId("background")
, hoverColorMode(ReplaceColor)
, action(0)
, scale(1.f)
Expand Down Expand Up @@ -138,7 +140,7 @@ DENG2_OBSERVES(Action, Triggered)

void setDefaultBackground()
{
self.set(Background(style().colors().colorf("background"),
self.set(Background(style().colors().colorf(bgColorId),
Background::GradientFrame, Vector4f(1, 1, 1, frameOpacity), 6));
}

Expand All @@ -147,7 +149,7 @@ DENG2_OBSERVES(Action, Triggered)
Background bg = self.background();
if(bg.type == Background::GradientFrame)
{
bg.solidFill = style().colors().colorf("background");
bg.solidFill = style().colors().colorf(bgColorId);
bg.color = Vector4f(1, 1, 1, frameOpacity);
self.set(bg);
}
Expand Down Expand Up @@ -184,6 +186,12 @@ void ButtonWidget::setHoverTextColor(DotPath const &hoverTextId, HoverColorMode
d->hoverColorMode = mode;
}

void ButtonWidget::setBackgroundColor(DotPath const &bgColorId)
{
d->bgColorId = bgColorId;
d->updateBackground();
}

void ButtonWidget::setAction(RefArg<Action> action)
{
if(d->action)
Expand Down

0 comments on commit c4ba7a6

Please sign in to comment.