diff options
-rw-r--r-- | src/gui/listbox.cpp | 18 | ||||
-rw-r--r-- | src/gui/listbox.h | 3 | ||||
-rw-r--r-- | src/gui/radiobutton.cpp | 39 | ||||
-rw-r--r-- | src/gui/radiobutton.h | 1 |
4 files changed, 42 insertions, 19 deletions
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 990a0ade..1de57593 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -26,6 +26,10 @@ #include "listbox.h" +#include "../configuration.h" + +float ListBox::mAlpha = config.getValue("guialpha", 0.8); + ListBox::ListBox(gcn::ListModel *listModel): gcn::ListBox(listModel) { @@ -36,19 +40,23 @@ void ListBox::draw(gcn::Graphics *graphics) if (!mListModel) return; - graphics->setColor(gcn::Color(235, 200, 115)); + if (config.getValue("guialpha", 0.8) != mAlpha) + mAlpha = config.getValue("guialpha", 0.8); + + const int alpha = mAlpha * 255; + + graphics->setColor(gcn::Color(235, 200, 115, alpha)); graphics->setFont(getFont()); - int fontHeight = getFont()->getHeight(); + const int fontHeight = getFont()->getHeight(); // Draw rectangle below the selected list element - if (mSelected >= 0) { + if (mSelected >= 0) graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight)); - } // Draw the list elements - graphics->setColor(gcn::Color(0, 0, 0)); + graphics->setColor(gcn::Color(0, 0, 0, 255)); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += fontHeight) diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 3d0062bc..15f7afb4 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -49,6 +49,9 @@ class ListBox : public gcn::ListBox void draw(gcn::Graphics *graphics); void mouseDragged(gcn::MouseEvent &event); + + private: + static float mAlpha; }; #endif diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 245112a7..de8d4d9d 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -21,12 +21,14 @@ #include "radiobutton.h" +#include "../configuration.h" #include "../graphics.h" #include "../resources/image.h" #include "../resources/resourcemanager.h" int RadioButton::instances = 0; +float RadioButton::mAlpha = config.getValue("guialpha", 0.8); Image *RadioButton::radioNormal; Image *RadioButton::radioChecked; Image *RadioButton::radioDisabled; @@ -43,6 +45,10 @@ RadioButton::RadioButton(const std::string& caption, const std::string& group, radioChecked = resman->getImage("graphics/gui/radioin.png"); radioDisabled = resman->getImage("graphics/gui/radioout.png"); radioDisabledChecked = resman->getImage("graphics/gui/radioin.png"); + radioNormal->setAlpha(mAlpha); + radioChecked->setAlpha(mAlpha); + radioDisabled->setAlpha(mAlpha); + radioDisabledChecked->setAlpha(mAlpha); } instances++; @@ -63,32 +69,37 @@ RadioButton::~RadioButton() void RadioButton::drawBox(gcn::Graphics* graphics) { + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + radioNormal->setAlpha(mAlpha); + radioChecked->setAlpha(mAlpha); + radioDisabled->setAlpha(mAlpha); + radioDisabledChecked->setAlpha(mAlpha); + } + Image *box = NULL; - if (isSelected()) { - if (isEnabled()) { + if (isSelected()) + { + if (isEnabled()) box = radioChecked; - } else { + else box = radioDisabledChecked; - } - } else if (isEnabled()) { + } + else if (isEnabled()) box = radioNormal; - } else { + else box = radioDisabled; - } - if (box != NULL) { + if (box != NULL) static_cast<Graphics*>(graphics)->drawImage(box, 2, 2); - } } void RadioButton::draw(gcn::Graphics* graphics) { - - graphics->pushClipArea(gcn::Rectangle(1, - 1, - getWidth() - 1, - getHeight() - 1)); + graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1, + getHeight() - 1)); drawBox(graphics); diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h index dcd62802..6ead9da0 100644 --- a/src/gui/radiobutton.h +++ b/src/gui/radiobutton.h @@ -57,6 +57,7 @@ class RadioButton : public gcn::RadioButton { private: static int instances; + static float mAlpha; static Image *radioNormal; static Image *radioChecked; static Image *radioDisabled; |