From d57be9d49c55bc0b85eb8f539ff2029518cfafc0 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 30 Jan 2009 10:56:54 -0700 Subject: 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 --- src/gui/checkbox.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gui/checkbox.cpp') diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index b8fca2b8..7fa4fa81 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -21,12 +21,14 @@ #include "checkbox.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" #include "../resources/resourcemanager.h" int CheckBox::instances = 0; +float CheckBox::mAlpha = config.getValue("guialpha", 0.8); Image *CheckBox::checkBoxNormal; Image *CheckBox::checkBoxChecked; Image *CheckBox::checkBoxDisabled; @@ -43,6 +45,10 @@ CheckBox::CheckBox(const std::string& caption, bool selected): checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10); + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); checkBox->decRef(); } @@ -66,16 +72,25 @@ void CheckBox::drawBox(gcn::Graphics* graphics) { Image *box; - if (isSelected()) { - if (isEnabled()) { + if (isSelected()) + { + if (isEnabled()) box = checkBoxChecked; - } else { + else box = checkBoxDisabledChecked; - } - } else if (isEnabled()) { + } + else if (isEnabled()) box = checkBoxNormal; - } else { + 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); } static_cast(graphics)->drawImage(box, 2, 2); -- cgit v1.2.3-70-g09d2 From c6cf9a6a9c03f17362171aeed1a22244d99b7530 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 17:33:47 -0700 Subject: Disable alpha values affecting two widgets which would otherwise take alpha values under SDL. Signed-off-by: Ira Rice --- src/gui/checkbox.cpp | 14 +++++++++----- src/gui/progressbar.cpp | 5 ++++- src/resources/image.h | 14 +++++++++++++- 3 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/gui/checkbox.cpp') diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 7fa4fa81..511ed34c 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -45,10 +45,13 @@ CheckBox::CheckBox(const std::string& caption, bool selected): checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10); - checkBoxNormal->setAlpha(mAlpha); - checkBoxChecked->setAlpha(mAlpha); - checkBoxDisabled->setAlpha(mAlpha); - checkBoxDisabledChecked->setAlpha(mAlpha); + if (config.getValue("opengl", 0)) + { + checkBoxNormal->setAlpha(mAlpha); + checkBoxChecked->setAlpha(mAlpha); + checkBoxDisabled->setAlpha(mAlpha); + checkBoxDisabledChecked->setAlpha(mAlpha); + } checkBox->decRef(); } @@ -84,7 +87,8 @@ void CheckBox::drawBox(gcn::Graphics* graphics) else box = checkBoxDisabled; - if (config.getValue("guialpha", 0.8) != mAlpha) + if (config.getValue("guialpha", 0.8) != mAlpha && + config.getValue("opengl", 0)) { mAlpha = config.getValue("guialpha", 0.8); checkBoxNormal->setAlpha(mAlpha); diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 5e8e6655..a1b847c8 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -103,7 +103,10 @@ void ProgressBar::draw(gcn::Graphics *graphics) { if (config.getValue("guialpha", 0.8) != mAlpha) { - mAlpha = config.getValue("guialpha", 0.8); + if (config.getValue("opengl", 0)) + mAlpha = config.getValue("guialpha", 0.8); + else + mAlpha = 1.0f; for (int i = 0; i < 9; i++) { mBorder.grid[i]->setAlpha(mAlpha); diff --git a/src/resources/image.h b/src/resources/image.h index a4048803..5b376053 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -91,6 +91,12 @@ class Image : public Resource */ virtual void unload(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return this; } + /** * Returns the width of the image. */ @@ -114,7 +120,7 @@ class Image : public Resource /** * Sets the alpha value of this image. */ - void setAlpha(float alpha); + virtual void setAlpha(float alpha); /** * Returns the alpha value of this image. @@ -180,6 +186,12 @@ class SubImage : public Image */ ~SubImage(); + /** + * Returns the image. + */ + virtual const Image* getImage() const + { return mParent; } + /** * Creates a new image with the desired clipping rectangle. * -- cgit v1.2.3-70-g09d2