From 8cc6679b676103c7c6696947ea43ad439e9754c5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 Jul 2012 00:29:22 +0300 Subject: Add theme option to show hide opaque background for some windows. --- src/gui/widgets/playerbox.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/gui/widgets/playerbox.cpp') diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index f0a6a5e89..423f26563 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -38,14 +38,18 @@ PlayerBox::PlayerBox(Being *being, std::string skin): mBeing(being), - mAlpha(1.0) + mAlpha(1.0), + mSkin(nullptr), + mDrawBackground(false) { init(skin); } PlayerBox::PlayerBox(std::string skin): mBeing(nullptr), - mAlpha(1.0) + mAlpha(1.0), + mSkin(nullptr), + mDrawBackground(false) { init(skin); } @@ -53,7 +57,10 @@ PlayerBox::PlayerBox(std::string skin): PlayerBox::~PlayerBox() { if (Theme::instance()) + { + Theme::instance()->unload(mSkin); Theme::instance()->unloadRect(mBackground); + } mBeing = nullptr; } @@ -66,7 +73,9 @@ void PlayerBox::init(std::string skin) { if (skin.empty()) skin = "playerbox_background.xml"; - Theme::instance()->loadRect(mBackground, skin); + mSkin = Theme::instance()->loadSkinRect(mBackground, skin); + if (mSkin) + mDrawBackground = (mSkin->getOption("drawbackground") != 0); } else { @@ -98,10 +107,14 @@ void PlayerBox::draw(gcn::Graphics *graphics) void PlayerBox::drawFrame(gcn::Graphics *graphics) { - int w, h, bs; - bs = getFrameSize(); - w = getWidth() + bs * 2; - h = getHeight() + bs * 2; + if (mDrawBackground) + { + int w, h, bs; + bs = getFrameSize(); + w = getWidth() + bs * 2; + h = getHeight() + bs * 2; - static_cast(graphics)->drawImageRect(0, 0, w, h, mBackground); + static_cast(graphics)->drawImageRect( + 0, 0, w, h, mBackground); + } } -- cgit v1.2.3-60-g2f50