summaryrefslogtreecommitdiff
path: root/src/gui/skin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/skin.cpp')
-rw-r--r--src/gui/skin.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index d44c54a8..ac258175 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -19,8 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <algorithm>
+
#include "skin.h"
+#include "../configuration.h"
+#include "../configlistener.h"
#include "../log.h"
#include "../resources/image.h"
@@ -30,6 +34,16 @@
#include "../utils/xml.h"
SkinLoader* skinLoader = NULL;
+ConfigListener *SkinLoader::skinConfigListener = NULL;
+
+class SkinConfigListener : public ConfigListener
+{
+ void optionChanged(const std::string &)
+ {
+ if (skinLoader)
+ skinLoader->updateAlpha();
+ }
+};
Skin::Skin(ImageRect skin, Image* close, std::string name):
instances(0),
@@ -51,6 +65,15 @@ Skin::~Skin()
closeImage->decRef();
}
+void Skin::updateAlpha()
+{
+ const float alpha = config.getValue("guialpha", 0.8);
+
+ for_each(border.grid, border.grid + 9,
+ std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
+ closeImage->setAlpha(alpha);
+}
+
unsigned int Skin::getMinWidth()
{
return (border.grid[0]->getWidth() + border.grid[1]->getWidth()) +
@@ -177,15 +200,34 @@ Skin* SkinLoader::load(const std::string &filename)
Skin* skin = new Skin(border, closeImage);
mSkins[filename] = skin;
+
+ updateAlpha();
+
return skin;
}
-SkinLoader::SkinLoader()
+SkinLoader::SkinLoader() :
+ mSkins()
{
+ skinConfigListener = new SkinConfigListener();
+ // Send GUI alpha changed for initialization
+ skinConfigListener->optionChanged("guialpha");
+ config.addListener("guialpha", skinConfigListener);
}
SkinLoader::~SkinLoader()
{
delete_all(mSkins);
+ config.removeListener("guialpha", skinConfigListener);
+ delete skinConfigListener;
+ skinConfigListener = NULL;
+}
+
+void SkinLoader::updateAlpha()
+{
+ for (SkinIterator iter = mSkins.begin(); iter != mSkins.end(); ++iter)
+ {
+ iter->second->updateAlpha();
+ }
}