From ccdaf8cc6f61c322a2308123b03bb91f9ca68ee9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 11 Sep 2012 16:27:16 +0300 Subject: Add new colors for button theming. New colors: BUTTON_PRESSED and BUTTON_HIGHLIGHTED. --- src/gui/theme.cpp | 2 ++ src/gui/theme.h | 2 ++ src/gui/widgets/button.cpp | 21 +++++++++++++++++---- src/gui/widgets/button.h | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 578717b57..99dac7887 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -679,6 +679,8 @@ static int readColorType(const std::string &type) "PROGRESS_BAR", "BUTTON", "BUTTON_DISABLED", + "BUTTON_HIGHLIGHTED", + "BUTTON_PRESSED", "CHECKBOX", "DROPDOWN", "LABEL", diff --git a/src/gui/theme.h b/src/gui/theme.h index cfa9ab49d..04c355e0f 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -171,6 +171,8 @@ class Theme : public Palette, public ConfigListener PROGRESS_BAR, BUTTON, BUTTON_DISABLED, + BUTTON_HIGHLIGHTED, + BUTTON_PRESSED, CHECKBOX, DROPDOWN, LABEL, diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 614ec7313..c8f756f6a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -193,6 +193,8 @@ void Button::init() } mEnabledColor = Theme::getThemeColor(Theme::BUTTON); mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED); + mHighlightedColor = Theme::getThemeColor(Theme::BUTTON_HIGHLIGHTED); + mPressedColor = Theme::getThemeColor(Theme::BUTTON_PRESSED); mInstances++; } @@ -323,10 +325,21 @@ void Button::draw(gcn::Graphics *graphics) // g2->drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); - if (mode == BUTTON_DISABLED) - graphics->setColor(mDisabledColor); - else - graphics->setColor(mEnabledColor); + switch (mode) + { + case BUTTON_DISABLED: + graphics->setColor(mDisabledColor); + break; + case BUTTON_PRESSED: + graphics->setColor(mPressedColor); + break; + case BUTTON_HIGHLIGHTED: + graphics->setColor(mHighlightedColor); + break; + default: + graphics->setColor(mEnabledColor); + break; + } int textX = 0; const int textY = getHeight() / 2 - getFont()->getHeight() / 2; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index e3ff82f0f..f57e9a7cd 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -143,6 +143,8 @@ class Button : public gcn::Button, public gcn::WidgetListener int mYOffset; gcn::Color mEnabledColor; gcn::Color mDisabledColor; + gcn::Color mHighlightedColor; + gcn::Color mPressedColor; Image **mImages; ImageSet *mImageSet; int mImageWidth; -- cgit v1.2.3-60-g2f50