summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-16 14:14:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-16 14:14:29 +0300
commit46087564d4184b28740b0c45c1bac199ab1942ec (patch)
tree0591b36aba2ae392eb569828930f030850cbc769 /src/gui/widgets
parentcf9b1182f06b1336f0d1071c267ea36c990430fa (diff)
downloadmanaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.gz
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.bz2
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.xz
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.zip
Improve theme usage.
Removed instance method.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/button.cpp12
-rw-r--r--src/gui/widgets/checkbox.cpp10
-rw-r--r--src/gui/widgets/desktop.cpp5
-rw-r--r--src/gui/widgets/dropdown.cpp17
-rw-r--r--src/gui/widgets/itemcontainer.cpp7
-rw-r--r--src/gui/widgets/label.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp7
-rw-r--r--src/gui/widgets/playerbox.cpp1
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/radiobutton.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp11
-rw-r--r--src/gui/widgets/slider.cpp5
-rw-r--r--src/gui/widgets/tabs/tab.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/textpreview.cpp2
-rw-r--r--src/gui/widgets/window.cpp4
18 files changed, 37 insertions, 68 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 25f821905..010d3d9f3 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -88,7 +88,6 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mBackgroundColor = getThemeColor(Theme::BACKGROUND);
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
@@ -140,7 +139,6 @@ BrowserBox::~BrowserBox()
if (gui)
gui->removeDragged(this);
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 308c75413..8ac4251cf 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -337,13 +337,10 @@ void Button::init()
if (mInstances == 0)
{
- if (Theme::instance())
+ if (theme)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- {
- button[mode] = Theme::instance()->load(
- data[mode], "button.xml");
- }
+ button[mode] = theme->load(data[mode], "button.xml");
}
updateAlpha();
@@ -359,9 +356,8 @@ Button::~Button()
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0 && theme)
{
- Theme *const theme = Theme::instance();
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
@@ -420,7 +416,7 @@ void Button::loadImageSet(const std::string &imageName)
void Button::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index f01495bcf..c44c88980 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -106,9 +106,9 @@ CheckBox::CheckBox(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(Theme::CHECKBOX_OUTLINE);
if (instances == 0)
{
- if (Theme::instance())
+ if (theme)
{
- mSkin = Theme::instance()->load("checkbox.xml", "");
+ mSkin = theme->load("checkbox.xml", "");
updateAlpha();
}
}
@@ -142,8 +142,8 @@ CheckBox::~CheckBox()
if (instances == 0)
{
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
}
@@ -162,7 +162,7 @@ void CheckBox::draw(Graphics *const graphics)
void CheckBox::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 0ff1b17c9..6ae892c81 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -51,7 +51,6 @@ Desktop::Desktop(const Widget2 *const widget) :
Wallpaper::loadWallpapers();
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("desktop.xml", "");
@@ -80,8 +79,8 @@ Desktop::~Desktop()
mWallpaper->decRef();
mWallpaper = nullptr;
}
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
void Desktop::postInit()
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index b1a3c4ac1..53f4a623b 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -85,13 +85,12 @@ DropDown::DropDown(const Widget2 *const widget,
mPopup->setHeight(100);
// Initialize graphics
- if (instances == 0)
+ if (instances == 0 && theme)
{
// Load the background skin
for (int i = 0; i < 2; i ++)
{
- Skin *const skin = Theme::instance()->load(
- dropdownFiles[i], "dropdown.xml");
+ Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
if (skin)
{
if (!i)
@@ -111,7 +110,7 @@ DropDown::DropDown(const Widget2 *const widget,
}
}
if (i)
- Theme::instance()->unload(skin);
+ theme->unload(skin);
}
else
{
@@ -121,11 +120,8 @@ DropDown::DropDown(const Widget2 *const widget,
}
// get the border skin
- if (Theme::instance())
- {
- Theme::instance()->loadRect(skinRect,
- "dropdown_background.xml", "");
- }
+ if (theme)
+ theme->loadRect(skinRect, "dropdown_background.xml", "");
}
instances++;
@@ -181,7 +177,6 @@ DropDown::~DropDown()
buttons[f][i]->decRef();
}
}
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
@@ -193,7 +188,7 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index fe666e6f7..ecabc226f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -168,8 +168,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mName(),
mItemPopup(new ItemPopup),
mShowMatrix(nullptr),
- mSkin(Theme::instance() ? Theme::instance()->load(
- "itemcontainer.xml", "") : nullptr),
+ mSkin(theme ? theme->load("itemcontainer.xml", "") : nullptr),
mEquipedColor(getThemeColor(Theme::ITEM_EQUIPPED)),
mEquipedColor2(getThemeColor(Theme::ITEM_EQUIPPED_OUTLINE)),
mUnEquipedColor(getThemeColor(Theme::ITEM_NOT_EQUIPPED)),
@@ -215,8 +214,8 @@ ItemContainer::~ItemContainer()
mProtectedImg = nullptr;
}
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
delete mItemPopup;
mItemPopup = nullptr;
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index b500ec7bb..7318fc3d1 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -105,7 +105,6 @@ Label::~Label()
mInstances --;
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
@@ -117,7 +116,6 @@ void Label::init()
mForegroundColor2 = getThemeColor(Theme::LABEL_OUTLINE);
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("label.xml", "");
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 6f0c192c6..f2a23253e 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -111,7 +111,6 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(Theme::LISTBOX);
mForegroundColor2 = getThemeColor(Theme::LISTBOX_OUTLINE);
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load(skin, "listbox.xml");
@@ -138,14 +137,14 @@ ListBox::~ListBox()
if (gui)
gui->removeDragged(this);
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
void ListBox::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
mAlpha = alpha;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 2ba452620..6f68f8689 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -86,7 +86,6 @@ void PlayerBox::init(std::string name, std::string selectedName)
setFrameSize(2);
addMouseListener(this);
- Theme *const theme = Theme::instance();
if (theme)
{
if (name.empty())
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1114b4a5e..a8bcec4ea 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -51,7 +51,6 @@ Popup::Popup(const std::string &name,
if (skin == "")
skin = "popup.xml";
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "popup.xml");
@@ -78,7 +77,6 @@ Popup::~Popup()
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 5bccd61ca..e2ff95228 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -70,7 +70,6 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
addWidgetListener(this);
setSize(width, height);
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "progressbar.xml");
@@ -94,7 +93,6 @@ ProgressBar::~ProgressBar()
gui->removeDragged(this);
mInstances--;
- Theme *const theme = Theme::instance();
if (mSkin)
{
if (theme)
@@ -142,7 +140,7 @@ void ProgressBar::logic()
void ProgressBar::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
mAlpha = alpha;
}
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 411216455..4841ececb 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -110,7 +110,6 @@ RadioButton::RadioButton(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(Theme::RADIOBUTTON_OUTLINE);
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load("radio.xml", "");
@@ -142,7 +141,6 @@ RadioButton::~RadioButton()
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
@@ -151,7 +149,7 @@ RadioButton::~RadioButton()
void RadioButton::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 47b8b0985..571297ace 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -195,7 +195,6 @@ void ScrollArea::init(std::string skinName)
// +++ here probably need move background from static
if (skinName == "")
skinName = "scroll_background.xml";
- Theme *const theme = Theme::instance();
if (theme)
{
theme->loadRect(background, skinName, "scroll_background.xml");
@@ -207,8 +206,9 @@ void ScrollArea::init(std::string skinName)
for (int i = 0; i < 2; i ++)
{
- Skin *const skin = Theme::instance()->load(
- buttonFiles[i], "scrollbuttons.xml");
+ Skin *skin = nullptr;
+ if (theme)
+ skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
if (skin)
{
const ImageRect &rect = skin->getBorder();
@@ -230,7 +230,8 @@ void ScrollArea::init(std::string skinName)
for (int f = UP; f < BUTTONS_DIR; f ++)
buttons[f][i] = nullptr;
}
- Theme::instance()->unload(skin);
+ if (theme)
+ theme->unload(skin);
}
}
mScrollbarWidth = mScrollbarSize;
@@ -290,7 +291,7 @@ void ScrollArea::logic()
void ScrollArea::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 700d31416..c9ea9e6c2 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -133,7 +133,7 @@ Slider::~Slider()
delete mVertexes;
mVertexes = nullptr;
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0)
{
for (int mode = 0; mode < 2; mode ++)
Theme::unloadRect(buttons[mode]);
@@ -153,7 +153,6 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
for (int mode = 0; mode < 2; mode ++)
@@ -171,7 +170,7 @@ void Slider::init()
void Slider::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index ede69619e..1e5733a2b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -123,9 +123,8 @@ Tab::~Tab()
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0 && theme)
{
- Theme *const theme = Theme::instance();
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unload(tabImg[mode]);
}
@@ -154,7 +153,6 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- Theme *const theme = Theme::instance();
if (theme)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
@@ -177,7 +175,7 @@ void Tab::init()
void Tab::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 7fe8c1bf3..0a1caa0e5 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -125,7 +125,6 @@ TextField::TextField(const Widget2 *restrict const widget,
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->loadSkinRect(skin, "textfield.xml",
@@ -160,7 +159,6 @@ TextField::~TextField()
instances--;
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
@@ -172,7 +170,7 @@ TextField::~TextField()
void TextField::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 10bd936c6..45e71b800 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -50,7 +50,6 @@ TextPreview::TextPreview(const Widget2 *const widget,
{
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("textpreview.xml", "");
}
@@ -72,7 +71,6 @@ TextPreview::~TextPreview()
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 5a636013b..dda03a438 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -155,7 +155,6 @@ Window::Window(const std::string &caption, const bool modal,
int childPalette = 1;
// Loads the skin
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "window.xml");
@@ -236,7 +235,6 @@ Window::~Window()
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
@@ -1207,7 +1205,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
int Window::getGuiAlpha() const
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
return static_cast<int>(alpha * 255.0F);
}