summaryrefslogtreecommitdiff
path: root/src/gui/widgets/button.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2009-09-02 23:40:45 +0200
committerBertram <bertram@cegetel.net>2009-09-02 23:40:45 +0200
commitefb541eeef2ad839c885c494c3a065f1f7d5dc03 (patch)
treef8f912a1aa62dfd902153a8dcb3e9d1549ae8e7c /src/gui/widgets/button.cpp
parent63049c5bf3ed38c3cb67edf740ed67f7fed663dd (diff)
downloadmana-efb541eeef2ad839c885c494c3a065f1f7d5dc03.tar.gz
mana-efb541eeef2ad839c885c494c3a065f1f7d5dc03.tar.bz2
mana-efb541eeef2ad839c885c494c3a065f1f7d5dc03.tar.xz
mana-efb541eeef2ad839c885c494c3a065f1f7d5dc03.zip
Added a minimum alpha opacity value handle in SkinLoader and made use of it.
Part 1 of 3 for Mantis #847 Only a few controls follow minimum opacity value at login stage. Part 2 will make all other controls do the same. Part 3 will try to set default gui opacity value as a constant.
Diffstat (limited to 'src/gui/widgets/button.cpp')
-rw-r--r--src/gui/widgets/button.cpp33
1 files changed, 21 insertions, 12 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]);