Skip to content

Commit

Permalink
libappfw|ButtonWidget: Button border color can use a style color def
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Aug 21, 2015
1 parent 3ae152a commit 3349dd0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h
Expand Up @@ -13,7 +13,7 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBAPPFW_BUTTONWIDGET_H
Expand Down Expand Up @@ -85,6 +85,8 @@ class LIBAPPFW_PUBLIC ButtonWidget : public LabelWidget

void setBackgroundColor(DotPath const &bgColorId);

void setBorderColor(DotPath const &borderColorId);

/**
* Sets the action of the button. It gets triggered when the button is
* pressed.
Expand Down
27 changes: 21 additions & 6 deletions doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp
Expand Up @@ -13,7 +13,7 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
* http://www.gnu.org/licenses</small>
*/

#include "de/ButtonWidget"
Expand All @@ -32,6 +32,7 @@ DENG2_OBSERVES(Action, Triggered)
DotPath originalTextColor;
Vector4f originalTextModColor;
DotPath bgColorId;
DotPath borderColorId;
HoverColorMode hoverColorMode;
bool infoStyle;
Action *action;
Expand All @@ -43,6 +44,7 @@ DENG2_OBSERVES(Action, Triggered)
: Base(i)
, state(Up)
, bgColorId("background")
, borderColorId("text")
, hoverColorMode(ReplaceColor)
, infoStyle(false)
, action(0)
Expand Down Expand Up @@ -142,10 +144,17 @@ DENG2_OBSERVES(Action, Triggered)
}
}

Vector4f borderColor() const
{
return style().colors().colorf(borderColorId) *
Vector4f(1, 1, 1, frameOpacity);
}

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

void updateBackground()
Expand All @@ -154,9 +163,7 @@ DENG2_OBSERVES(Action, Triggered)
if(bg.type == Background::GradientFrame)
{
bg.solidFill = style().colors().colorf(bgColorId);
/// @todo Make this Style-able. -jk
bg.color = infoStyle? Vector4f(0, 0, 0, frameOpacity) :
Vector4f(1, 1, 1, frameOpacity);
bg.color = borderColor();
self.set(bg);
}
}
Expand Down Expand Up @@ -198,15 +205,17 @@ void ButtonWidget::useInfoStyle(bool yes)
{
d->infoStyle = yes;
if(yes)
{
{
d->originalTextColor = "inverted.text";
setHoverTextColor("inverted.text", ReplaceColor);
setBorderColor("inverted.text");
setBackgroundColor("inverted.background");
}
else
{
d->originalTextColor = "text";
setHoverTextColor("text", ReplaceColor);
setBorderColor("text");
setBackgroundColor("background");
}
setTextColor(d->originalTextColor);
Expand All @@ -232,6 +241,12 @@ void ButtonWidget::setBackgroundColor(DotPath const &bgColorId)
d->updateBackground();
}

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

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

0 comments on commit 3349dd0

Please sign in to comment.