summaryrefslogtreecommitdiff
path: root/src/gui/button.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-30 10:56:54 -0700
committerIra Rice <irarice@gmail.com>2009-01-30 10:56:54 -0700
commitd57be9d49c55bc0b85eb8f539ff2029518cfafc0 (patch)
treedf3726aab3d3a4227330496e3b54803a713b1e7d /src/gui/button.cpp
parentcc37b4a9153379d5c5529ba85305d36efba2cd85 (diff)
downloadmana-client-d57be9d49c55bc0b85eb8f539ff2029518cfafc0.tar.gz
mana-client-d57be9d49c55bc0b85eb8f539ff2029518cfafc0.tar.bz2
mana-client-d57be9d49c55bc0b85eb8f539ff2029518cfafc0.tar.xz
mana-client-d57be9d49c55bc0b85eb8f539ff2029518cfafc0.zip
Exposed most gui elements to take alpha values. There are still a few
spots that could also be fixed up as well, but require other methods to fix them (the filled color rectangles on the progress bars, as well as the text on them as well, as an example). Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/button.cpp')
-rw-r--r--src/gui/button.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 9b624015..d578202e 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -21,6 +21,7 @@
#include "button.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -35,6 +36,7 @@
#include <algorithm>
int Button::mInstances = 0;
+float Button::mAlpha = config.getValue("guialpha", 0.8);
enum{
BUTTON_STANDARD, // 0
@@ -100,6 +102,7 @@ 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++;
}
}
@@ -126,17 +129,25 @@ void Button::draw(gcn::Graphics *graphics)
{
int mode;
- if (!isEnabled()) {
+ if (!isEnabled())
mode = BUTTON_DISABLED;
- }
- else if (isPressed() || mIsLogged) {
+ else if (isPressed() || mIsLogged)
mode = BUTTON_PRESSED;
- }
- else if (mHasMouse || isFocused()) {
+ else if (mHasMouse || isFocused())
mode = BUTTON_HIGHLIGHTED;
- }
- else {
+ 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);
+ }
}
static_cast<Graphics*>(graphics)->
@@ -147,7 +158,8 @@ void Button::draw(gcn::Graphics *graphics)
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
- switch (getAlignment()) {
+ switch (getAlignment())
+ {
case gcn::Graphics::LEFT:
textX = 4;
break;
@@ -163,10 +175,8 @@ void Button::draw(gcn::Graphics *graphics)
graphics->setFont(getFont());
- if (isPressed()) {
+ if (isPressed())
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
- }
- else {
+ else
graphics->drawText(getCaption(), textX, textY, getAlignment());
- }
}