From 3349dd0f8a547317efa66c7bf5616b891419cce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Fri, 21 Aug 2015 18:36:17 +0300 Subject: [PATCH] libappfw|ButtonWidget: Button border color can use a style color def --- .../include/de/widgets/buttonwidget.h | 4 ++- .../sdk/libappfw/src/widgets/buttonwidget.cpp | 27 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h b/doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h index 3def37888a..f7afb9212f 100644 --- a/doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h +++ b/doomsday/sdk/libappfw/include/de/widgets/buttonwidget.h @@ -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 + * http://www.gnu.org/licenses */ #ifndef LIBAPPFW_BUTTONWIDGET_H @@ -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. diff --git a/doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp b/doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp index 033fc4f8e9..65664f991b 100644 --- a/doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp +++ b/doomsday/sdk/libappfw/src/widgets/buttonwidget.cpp @@ -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 + * http://www.gnu.org/licenses */ #include "de/ButtonWidget" @@ -32,6 +32,7 @@ DENG2_OBSERVES(Action, Triggered) DotPath originalTextColor; Vector4f originalTextModColor; DotPath bgColorId; + DotPath borderColorId; HoverColorMode hoverColorMode; bool infoStyle; Action *action; @@ -43,6 +44,7 @@ DENG2_OBSERVES(Action, Triggered) : Base(i) , state(Up) , bgColorId("background") + , borderColorId("text") , hoverColorMode(ReplaceColor) , infoStyle(false) , action(0) @@ -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() @@ -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); } } @@ -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); @@ -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) { if(d->action)