diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/button.cpp | 33 | ||||
-rw-r--r-- | src/gui/widgets/button.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/checkbox.cpp | 29 | ||||
-rw-r--r-- | src/gui/widgets/checkbox.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 2 |
5 files changed, 51 insertions, 23 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 2357b263..9f44cdfc 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -28,6 +28,7 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include "gui/skin.h" #include "utils/dtor.h" @@ -101,12 +102,12 @@ void Button::init() data[x].gridX, data[y].gridY, data[x + 1].gridX - data[x].gridX + 1, data[y + 1].gridY - data[y].gridY + 1); - button[mode].grid[a]->setAlpha(mAlpha); a++; } } btn[mode]->decRef(); } + updateAlpha(); } mInstances++; } @@ -124,6 +125,24 @@ Button::~Button() } } +void Button::updateAlpha() +{ + float alpha = std::max(config.getValue("guialpha", 0.8f), + (double)SkinLoader::instance()->getMinimumOpacity()); + + if (mAlpha != alpha) + { + mAlpha = alpha; + for (int a = 0; a < 9; a++) + { + button[BUTTON_DISABLED].grid[a]->setAlpha(mAlpha); + button[BUTTON_PRESSED].grid[a]->setAlpha(mAlpha); + button[BUTTON_HIGHLIGHTED].grid[a]->setAlpha(mAlpha); + button[BUTTON_STANDARD].grid[a]->setAlpha(mAlpha); + } + } +} + void Button::draw(gcn::Graphics *graphics) { int mode; @@ -137,17 +156,7 @@ void Button::draw(gcn::Graphics *graphics) else mode = BUTTON_STANDARD; - if (config.getValue("guialpha", 0.8) != mAlpha) - { - mAlpha = config.getValue("guialpha", 0.8); - for (int a = 0; a < 9; a++) - { - button[BUTTON_DISABLED].grid[a]->setAlpha(mAlpha); - button[BUTTON_PRESSED].grid[a]->setAlpha(mAlpha); - button[BUTTON_HIGHLIGHTED].grid[a]->setAlpha(mAlpha); - button[BUTTON_STANDARD].grid[a]->setAlpha(mAlpha); - } - } + updateAlpha(); static_cast<Graphics*>(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index eebf7931..7eb7e2ef 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -56,6 +56,11 @@ class Button : public gcn::Button */ void draw(gcn::Graphics *graphics); + /** + * Update the alpha value to the button components. + */ + void updateAlpha(); + private: void init(); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index dd57f674..9b4ab2f4 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -28,6 +28,7 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include "gui/skin.h" int CheckBox::instances = 0; float CheckBox::mAlpha = 1.0; @@ -91,6 +92,23 @@ void CheckBox::draw(gcn::Graphics* graphics) graphics->drawText(getCaption(), h - 2, 0); } +void CheckBox::updateAlpha() +{ + float alpha = std::max(config.getValue("guialpha", 0.8f), + (double)SkinLoader::instance()->getMinimumOpacity()); + + if (mAlpha != alpha) + { + mAlpha = alpha; + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); + checkBoxNormal->setAlpha(mAlpha); + checkBoxCheckedHi->setAlpha(mAlpha); + } +} + void CheckBox::drawBox(gcn::Graphics* graphics) { Image *box; @@ -112,16 +130,7 @@ void CheckBox::drawBox(gcn::Graphics* graphics) else box = checkBoxDisabled; - if (config.getValue("guialpha", 0.8) != mAlpha) - { - mAlpha = config.getValue("guialpha", 0.8); - checkBoxNormal->setAlpha(mAlpha); - checkBoxChecked->setAlpha(mAlpha); - checkBoxDisabled->setAlpha(mAlpha); - checkBoxDisabledChecked->setAlpha(mAlpha); - checkBoxNormal->setAlpha(mAlpha); - checkBoxCheckedHi->setAlpha(mAlpha); - } + updateAlpha(); static_cast<Graphics*>(graphics)->drawImage(box, 2, 2); } diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 7a7c8674..a65a5196 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -51,6 +51,11 @@ class CheckBox : public gcn::CheckBox void draw(gcn::Graphics* graphics); /** + * Update the alpha value to the checkbox components. + */ + void updateAlpha(); + + /** * Draws the check box, not the caption. */ void drawBox(gcn::Graphics* graphics); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 1ee84a6f..9c098bdb 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -750,7 +750,7 @@ void Window::center() void Window::checkIfIsOffScreen(bool partially, bool entirely) { // Move the window onto screen if it has become off screen - // For instance, because of resolution change... + // For instance, because of resolution change... // First of all, don't deal when a window hasn't got // any size initialized yet... |