summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/dropdown.cpp27
-rw-r--r--src/gui/widgets/dropdown.h5
-rw-r--r--src/gui/widgets/listbox.cpp13
-rw-r--r--src/gui/widgets/listbox.h5
-rw-r--r--src/gui/widgets/progressbar.cpp16
-rw-r--r--src/gui/widgets/progressbar.h5
-rw-r--r--src/gui/widgets/scrollarea.cpp29
-rw-r--r--src/gui/widgets/scrollarea.h5
-rw-r--r--src/gui/widgets/slider.cpp39
-rw-r--r--src/gui/widgets/slider.h5
-rw-r--r--src/gui/widgets/tab.cpp35
-rw-r--r--src/gui/widgets/tab.h5
-rw-r--r--src/gui/widgets/textfield.cpp25
-rw-r--r--src/gui/widgets/textfield.h5
-rw-r--r--src/gui/widgets/window.cpp3
15 files changed, 154 insertions, 68 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index e838aab6..d5b324a6 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -32,6 +32,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
#include "utils/dtor.h"
@@ -113,18 +114,14 @@ DropDown::~DropDown()
delete mScrollArea;
}
-void DropDown::draw(gcn::Graphics* graphics)
+void DropDown::updateAlpha()
{
- int h;
+ float alpha = std::max(config.getValue("guialpha", 0.8f),
+ (double)SkinLoader::instance()->getMinimumOpacity());
- if (mDroppedDown)
- h = mFoldedUpHeight;
- else
- h = getHeight();
-
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (mAlpha != alpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = alpha;
buttons[0][0]->setAlpha(mAlpha);
buttons[0][1]->setAlpha(mAlpha);
@@ -136,6 +133,18 @@ void DropDown::draw(gcn::Graphics* graphics)
skin.grid[a]->setAlpha(mAlpha);
}
}
+}
+
+void DropDown::draw(gcn::Graphics* graphics)
+{
+ int h;
+
+ if (mDroppedDown)
+ h = mFoldedUpHeight;
+ else
+ h = getHeight();
+
+ updateAlpha();
const int alpha = (int) (mAlpha * 255.0f);
gcn::Color faceColor = getBaseColor();
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index e593b4e0..6e50bb5d 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -49,6 +49,11 @@ class DropDown : public gcn::DropDown
~DropDown();
+ /**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
void draw(gcn::Graphics *graphics);
void drawFrame(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 49653294..aee0f8d3 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -25,6 +25,7 @@
#include "gui/sdlinput.h"
#include "configuration.h"
+#include "gui/skin.h"
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
@@ -38,13 +39,21 @@ ListBox::ListBox(gcn::ListModel *listModel):
{
}
+void ListBox::updateAlpha()
+{
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+
+ if (mAlpha != alpha)
+ mAlpha = alpha;
+}
+
void ListBox::draw(gcn::Graphics *graphics)
{
if (!mListModel)
return;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ updateAlpha();
graphics->setColor(guiPalette->getColor(Palette::HIGHLIGHT,
(int)(mAlpha * 255.0f)));
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index a92d8bbf..55f26781 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -46,6 +46,11 @@ class ListBox : public gcn::ListBox
*/
void draw(gcn::Graphics *graphics);
+ /**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
// Inherited from KeyListener
void keyPressed(gcn::KeyEvent& keyEvent);
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 7cc020ef..0eda50a1 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -30,6 +30,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
#include "utils/dtor.h"
@@ -120,17 +121,26 @@ void ProgressBar::logic()
}
}
-void ProgressBar::draw(gcn::Graphics *graphics)
+void ProgressBar::updateAlpha()
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+
+ if (mAlpha != alpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = alpha;
for (int i = 0; i < 9; i++)
{
mBorder.grid[i]->setAlpha(mAlpha);
}
}
+}
+
+void ProgressBar::draw(gcn::Graphics *graphics)
+{
+ updateAlpha();
+
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 77670f57..a0a8f951 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -51,6 +51,11 @@ class ProgressBar : public gcn::Widget
void logic();
/**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
+ /**
* Draws the progress bar.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 6cf27bb6..eed0ff33 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -26,6 +26,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
#include "utils/dtor.h"
@@ -182,6 +183,23 @@ void ScrollArea::logic()
}
}
+void ScrollArea::updateAlpha()
+{
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+
+ if (alpha != mAlpha)
+ {
+ mAlpha = alpha;
+ for (int a = 0; a < 9; a++)
+ {
+ background.grid[a]->setAlpha(mAlpha);
+ vMarker.grid[a]->setAlpha(mAlpha);
+ vMarkerHi.grid[a]->setAlpha(mAlpha);
+ }
+ }
+}
+
void ScrollArea::draw(gcn::Graphics *graphics)
{
if (mVBarVisible)
@@ -209,16 +227,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mScrollbarWidth));
}
- if (config.getValue("guialpha", 0.8) != mAlpha)
- {
- mAlpha = config.getValue("guialpha", 0.8);
- for (int a = 0; a < 9; a++)
- {
- background.grid[a]->setAlpha(mAlpha);
- vMarker.grid[a]->setAlpha(mAlpha);
- vMarkerHi.grid[a]->setAlpha(mAlpha);
- }
- }
+ updateAlpha();
drawChildren(graphics);
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 69e99b1f..ede36382 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -65,6 +65,11 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
void logic();
/**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
+ /**
* Draws the scroll area.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 6ce5f849..1e9fe4f5 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -26,6 +26,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip;
Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip;
@@ -117,7 +118,21 @@ void Slider::init()
slider->decRef();
sliderHi->decRef();
+ }
+
+ mInstances++;
+
+ setMarkerLength(hGrip->getWidth());
+}
+
+void Slider::updateAlpha()
+{
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+ if (alpha != mAlpha)
+ {
+ mAlpha = alpha;
hStart->setAlpha(mAlpha);
hMid->setAlpha(mAlpha);
hEnd->setAlpha(mAlpha);
@@ -137,9 +152,6 @@ void Slider::init()
vGripHi->setAlpha(mAlpha);
}
- mInstances++;
-
- setMarkerLength(hGrip->getWidth());
}
void Slider::draw(gcn::Graphics *graphics)
@@ -149,27 +161,8 @@ void Slider::draw(gcn::Graphics *graphics)
int x = 0;
int y = mHasMouse?(h - hStartHi->getHeight()) / 2:(h - hStart->getHeight()) / 2;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- {
- mAlpha = config.getValue("guialpha", 0.8);
- hStart->setAlpha(mAlpha);
- hMid->setAlpha(mAlpha);
- hEnd->setAlpha(mAlpha);
- hGrip->setAlpha(mAlpha);
- hStartHi->setAlpha(mAlpha);
- hMidHi->setAlpha(mAlpha);
- hEndHi->setAlpha(mAlpha);
- hGripHi->setAlpha(mAlpha);
+ updateAlpha();
- vStart->setAlpha(mAlpha);
- vMid->setAlpha(mAlpha);
- vEnd->setAlpha(mAlpha);
- vGrip->setAlpha(mAlpha);
- vStartHi->setAlpha(mAlpha);
- vMidHi->setAlpha(mAlpha);
- vEndHi->setAlpha(mAlpha);
- vGripHi->setAlpha(mAlpha);
- }
if (!mHasMouse)
{
static_cast<Graphics*>(graphics)->drawImage(hStart, x, y);
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
index 85fb2633..55952a1d 100644
--- a/src/gui/widgets/slider.h
+++ b/src/gui/widgets/slider.h
@@ -49,6 +49,11 @@ class Slider : public gcn::Slider {
~Slider();
/**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
+ /**
* Draws the slider.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 3e49263e..99a95d96 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -30,6 +30,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
#include "utils/dtor.h"
@@ -116,6 +117,26 @@ void Tab::init()
mInstances++;
}
+void Tab::updateAlpha()
+{
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+
+ // TODO We don't need to do this for every tab on every draw
+ // Maybe use a config listener to do it as the value changes.
+ if (alpha != mAlpha)
+ {
+ mAlpha = alpha;
+ for (int a = 0; a < 9; a++)
+ {
+ for (int t = 0; t < TAB_COUNT; t++)
+ {
+ tabImg[t].grid[a]->setAlpha(mAlpha);
+ }
+ }
+ }
+}
+
void Tab::draw(gcn::Graphics *graphics)
{
int mode = TAB_STANDARD;
@@ -139,19 +160,7 @@ void Tab::draw(gcn::Graphics *graphics)
}
}
- // TODO We don't need to do this for every tab on every draw
- // Maybe use a config listener to do it as the value changes.
- if (config.getValue("guialpha", 0.8) != mAlpha)
- {
- mAlpha = config.getValue("guialpha", 0.8);
- for (int a = 0; a < 9; a++)
- {
- for (int t = 0; t < TAB_COUNT; t++)
- {
- tabImg[t].grid[a]->setAlpha(mAlpha);
- }
- }
- }
+ updateAlpha();
// draw tab
static_cast<Graphics*>(graphics)->
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index eea2586c..4d3aacda 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -38,6 +38,11 @@ class Tab : public gcn::Tab
~Tab();
/**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
+ /**
* Draw the tabbed area.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 75144658..f19b4d82 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -29,6 +29,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "gui/skin.h"
#include "utils/dtor.h"
@@ -82,8 +83,23 @@ TextField::~TextField()
for_each(skin.grid, skin.grid + 9, dtor<Image*>());
}
+void TextField::updateAlpha()
+{
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
+
+ if (alpha != mAlpha)
+ {
+ mAlpha = alpha;
+ for (int a = 0; a < 9; a++)
+ skin.grid[a]->setAlpha(mAlpha);
+ }
+}
+
void TextField::draw(gcn::Graphics *graphics)
{
+ updateAlpha();
+
if (isFocused())
{
drawCaret(graphics,
@@ -94,17 +110,12 @@ void TextField::draw(gcn::Graphics *graphics)
graphics->setColor(guiPalette->getColor(Palette::TEXT));
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
-
- if (config.getValue("guialpha", 0.8) != mAlpha)
- {
- mAlpha = config.getValue("guialpha", 0.8);
- for (int a = 0; a < 9; a++)
- skin.grid[a]->setAlpha(mAlpha);
- }
}
void TextField::drawFrame(gcn::Graphics *graphics)
{
+ //updateAlpha(); -> Not useful...
+
int w, h, bs;
bs = getFrameSize();
w = getWidth() + bs * 2;
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 30ff2338..9130e441 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -48,6 +48,11 @@ class TextField : public gcn::TextField
virtual void draw(gcn::Graphics *graphics);
/**
+ * Update the alpha value to the graphic components.
+ */
+ void updateAlpha();
+
+ /**
* Draws the background and border.
*/
void drawFrame(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 9c098bdb..0ffae6ea 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -684,7 +684,8 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
int Window::getGuiAlpha()
{
- float alpha = config.getValue("guialpha", 0.8);
+ float alpha = std::max(config.getValue("guialpha", 0.8),
+ (double)SkinLoader::instance()->getMinimumOpacity());
return (int) (alpha * 255.0f);
}