diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 60 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.h | 29 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 39 | ||||
-rw-r--r-- | src/gui/widgets/tab.h | 8 |
6 files changed, 119 insertions, 29 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 88a12d68..31d35cb0 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -23,6 +23,11 @@ #include "dropdown.h" +#include "../colour.h" +#include "../listbox.h" +#include "../scrollarea.h" + +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -33,12 +38,12 @@ int DropDown::instances = 0; Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; +float DropDown::mAlpha = config.getValue("guialpha", 0.8); -DropDown::DropDown(gcn::ListModel *listModel, - gcn::ScrollArea *scrollArea, - gcn::ListBox *listBox): - gcn::DropDown::DropDown(listModel, - scrollArea, listBox) +DropDown::DropDown(gcn::ListModel *listModel, gcn::ScrollArea *scrollArea, + gcn::ListBox *listBox, bool opacity): + gcn::DropDown::DropDown(listModel, scrollArea, listBox), + mOpaque(opacity) { setFrameSize(2); @@ -58,6 +63,11 @@ DropDown::DropDown(gcn::ListModel *listModel, buttons[0][1] = resman->getImage("graphics/gui/vscroll_down_pressed.png"); + buttons[0][0]->setAlpha(mAlpha); + buttons[0][1]->setAlpha(mAlpha); + buttons[1][0]->setAlpha(mAlpha); + buttons[1][1]->setAlpha(mAlpha); + // get the border skin Image *boxBorder = resman->getImage("graphics/gui/deepbox.png"); int gridx[4] = {0, 3, 28, 31}; @@ -70,6 +80,7 @@ DropDown::DropDown(gcn::ListModel *listModel, gridx[x], gridy[y], gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); + skin.grid[a]->setAlpha(mAlpha); a++; } } @@ -108,19 +119,44 @@ void DropDown::draw(gcn::Graphics* graphics) h = getHeight(); } - int alpha = getBaseColor().a; + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + + buttons[0][0]->setAlpha(mAlpha); + buttons[0][1]->setAlpha(mAlpha); + buttons[1][0]->setAlpha(mAlpha); + buttons[1][1]->setAlpha(mAlpha); + + for (int a = 0; a < 9; a++) + { + skin.grid[a]->setAlpha(mAlpha); + } + } + + bool valid; + const int alpha = mAlpha * 255; gcn::Color faceColor = getBaseColor(); faceColor.a = alpha; - gcn::Color highlightColor = faceColor + 0x303030; + gcn::Color highlightColor = textColour->getColour('H', valid); highlightColor.a = alpha; gcn::Color shadowColor = faceColor - 0x303030; shadowColor.a = alpha; + if (mOpaque) + { + int red = getBackgroundColor().r; + int green = getBackgroundColor().g; + int blue = getBackgroundColor().b; + graphics->setColor(gcn::Color(red, green, blue, alpha)); + graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h)); + + red = getForegroundColor().r; + green = getForegroundColor().g; + blue = getForegroundColor().b; + graphics->setColor(gcn::Color(red, green, blue, alpha)); + } - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h)); - - graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); if (mListBox->getListModel() && mListBox->getSelected() >= 0) @@ -140,7 +176,7 @@ void DropDown::draw(gcn::Graphics* graphics) { drawChildren(graphics); - // Draw two lines separating the ListBox with se selected + // Draw two lines separating the ListBox with selected // element view. graphics->setColor(highlightColor); graphics->drawLine(0, h, getWidth(), h); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 25ae05f8..e5919dc7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -22,15 +22,8 @@ #ifndef DROPDOWN_H #define DROPDOWN_H -#include <iosfwd> - #include <guichan/widgets/dropdown.hpp> -#include "../listbox.h" -#include "../scrollarea.h" - -#include "../../guichanfwd.h" - class Image; class ImageRect; @@ -56,7 +49,8 @@ class DropDown : public gcn::DropDown */ DropDown(gcn::ListModel *listModel = NULL, gcn::ScrollArea *scrollArea = NULL, - gcn::ListBox *listBox = NULL); + gcn::ListBox *listBox = NULL, + bool opacity = true); /** * Destructor. @@ -67,6 +61,22 @@ class DropDown : public gcn::DropDown void drawFrame(gcn::Graphics* graphics); + /** + * Sets the widget to be opaque, that is sets the widget to display its + * background. + * + * @param opaque True if the widget should be opaque, false otherwise. + */ + void setOpaque(bool opaque) {mOpaque = opaque;} + + /** + * Checks if the widget is opaque, that is if the widget area displays + * its background. + * + * @return True if the widget is opaque, false otherwise. + */ + bool isOpaque() const {return mOpaque;} + protected: /** @@ -80,6 +90,9 @@ class DropDown : public gcn::DropDown static int instances; static Image *buttons[2][2]; static ImageRect skin; + static float mAlpha; + + bool mOpaque; }; #endif // end DROPDOWN_H diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 4b8bb4da..fa264e37 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -23,6 +23,7 @@ #include "resizegrip.h" +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -30,6 +31,7 @@ Image *ResizeGrip::gripImage = 0; int ResizeGrip::mInstances = 0; +float ResizeGrip::mAlpha = config.getValue("guialpha", 0.8); ResizeGrip::ResizeGrip(std::string image) { @@ -38,6 +40,7 @@ ResizeGrip::ResizeGrip(std::string image) // Load the grip image ResourceManager *resman = ResourceManager::getInstance(); gripImage = resman->getImage(image); + gripImage->setAlpha(mAlpha); } mInstances++; @@ -58,5 +61,11 @@ ResizeGrip::~ResizeGrip() void ResizeGrip::draw(gcn::Graphics *graphics) { + if (config.getValue("guialpha", 0.8) != mAlpha) + { + mAlpha = config.getValue("guialpha", 0.8); + gripImage->setAlpha(mAlpha); + } + static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0); } diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 7f1329a2..620c133f 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -24,8 +24,6 @@ #include <guichan/widget.hpp> -#include "../../guichanfwd.h" - class Image; /** @@ -56,6 +54,7 @@ class ResizeGrip : public gcn::Widget private: static Image *gripImage; /**< Resize grip image */ static int mInstances; /**< Number of resize grip instances */ + static float mAlpha; }; #endif diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index c54b2390..22e952e7 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -19,12 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <algorithm> +#include <guichan/widgets/label.hpp> #include "tab.h" - #include "tabbedarea.h" +#include "../../configuration.h" #include "../../graphics.h" #include "../../resources/image.h" @@ -33,6 +33,7 @@ #include "../../utils/dtor.h" int Tab::mInstances = 0; +float Tab::mAlpha = config.getValue("guialpha", 0.8); enum{ TAB_STANDARD, // 0 @@ -79,6 +80,7 @@ Tab::~Tab() void Tab::init() { setFrameSize(0); + mHighlighted = false; if (mInstances == 0) { @@ -98,6 +100,7 @@ void Tab::init() data[x].gridX, data[y].gridY, data[x + 1].gridX - data[x].gridX + 1, data[y + 1].gridY - data[y].gridY + 1); + tabImg[mode].grid[a]->setAlpha(mAlpha); a++; } } @@ -109,16 +112,33 @@ void Tab::init() void Tab::draw(gcn::Graphics *graphics) { - int mode; + int mode = TAB_STANDARD; // check which type of tab to draw - if (mTabbedArea && mTabbedArea->isTabSelected(this)) + if (mTabbedArea) { - mode = TAB_SELECTED; + if(mTabbedArea->isTabSelected(this)) + { + mode = TAB_SELECTED; + // if tab is selected, it doesnt need to highlight activity + mLabel->setForegroundColor(gcn::Color(0, 0, 0)); + mHighlighted = false; + } + else if (mHighlighted) + { + mode = TAB_HIGHLIGHTED; + mLabel->setForegroundColor(gcn::Color(255, 0, 0)); + } } - else + + if (config.getValue("guialpha", 0.8) != mAlpha) { - mode = TAB_STANDARD; + mAlpha = config.getValue("guialpha", 0.8); + for (int a = 0; a < 9; a++) + { + tabImg[TAB_SELECTED].grid[a]->setAlpha(mAlpha); + tabImg[TAB_STANDARD].grid[a]->setAlpha(mAlpha); + } } // draw tab @@ -128,3 +148,8 @@ void Tab::draw(gcn::Graphics *graphics) // draw label drawChildren(graphics); } + +void Tab::setHighlighted(bool high) +{ + mHighlighted = high; +} diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 8382df83..3af4e2bf 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -47,12 +47,20 @@ class Tab : public gcn::Tab */ void draw(gcn::Graphics *graphics); + /** + * Set tab highlighted + */ + void setHighlighted(bool high); + private: /** Load images if no other instances exist yet */ void init(); static ImageRect tabImg[4]; /**< Tab state graphics */ static int mInstances; /**< Number of tab instances */ + static float mAlpha; + + bool mHighlighted; }; #endif |