summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-12 12:34:35 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-12 12:34:35 +0300
commit840fd10e1843ac4aac01595fe0701bc35a1bcfd3 (patch)
treece75085aed4df1462740da046af1d050cf899485 /src
parent6ef15759c7e598f4d0c49a262562c9135fab0e5e (diff)
downloadmanaverse-840fd10e1843ac4aac01595fe0701bc35a1bcfd3.tar.gz
manaverse-840fd10e1843ac4aac01595fe0701bc35a1bcfd3.tar.bz2
manaverse-840fd10e1843ac4aac01595fe0701bc35a1bcfd3.tar.xz
manaverse-840fd10e1843ac4aac01595fe0701bc35a1bcfd3.zip
add theming for desktop object.
New theme file: desktop.xml Theme options: showBackground - to show or hide background versionX - version label position by x versionY - version label position by y
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/desktop.cpp25
-rw-r--r--src/gui/widgets/desktop.h3
2 files changed, 25 insertions, 3 deletions
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 9bbe91cbb..d2e132c56 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -38,13 +38,22 @@ Desktop::Desktop(const Widget2 *const widget) :
gcn::WidgetListener(),
mWallpaper(nullptr),
mVersionLabel(nullptr),
+ mSkin(nullptr),
mBackgroundColor(getThemeColor(Theme::BACKGROUND, 128)),
- mBackgroundGrayColor(getThemeColor(Theme::BACKGROUND_GRAY))
+ mBackgroundGrayColor(getThemeColor(Theme::BACKGROUND_GRAY)),
+ mShowBackground(true)
{
addWidgetListener(this);
Wallpaper::loadWallpapers();
+ Theme *const theme = Theme::instance();
+ if (theme)
+ mSkin = theme->load("desktop.xml", "");
+
+ if (mSkin)
+ mShowBackground = mSkin->getOption("showBackground");
+
const std::string appName = branding.getValue("appName", std::string());
if (appName.empty())
{
@@ -66,11 +75,21 @@ Desktop::~Desktop()
mWallpaper->decRef();
mWallpaper = nullptr;
}
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
}
void Desktop::postInit()
{
- add(mVersionLabel, 25, 2);
+ if (mSkin)
+ {
+ add(mVersionLabel, mSkin->getOption("versionX", 25),
+ mSkin->getOption("versionY", 2));
+ }
+ else
+ {
+ add(mVersionLabel, 25, 2);
+ }
}
void Desktop::reloadWallpaper()
@@ -132,7 +151,7 @@ void Desktop::draw(gcn::Graphics *graphics)
void Desktop::setBestFittingWallpaper()
{
- if (!config.getBoolValue("showBackground"))
+ if (!mShowBackground || !config.getBoolValue("showBackground"))
return;
const std::string wallpaperName =
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 112d1e794..824620f3b 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -30,6 +30,7 @@
class Image;
class Label;
+class Skin;
/**
* Desktop widget, for drawing a background image and color.
@@ -69,8 +70,10 @@ class Desktop final : public Container, private gcn::WidgetListener
Image *mWallpaper;
Label *mVersionLabel;
+ Skin *mSkin;
gcn::Color mBackgroundColor;
gcn::Color mBackgroundGrayColor;
+ bool mShowBackground;
};
#endif // GUI_WIDGETS_DESKTOP_H