summaryrefslogtreecommitdiff
path: root/src/gui/widgets/scrollarea.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-03 01:31:04 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-04 23:57:02 +0300
commitc52472123eb7847b5cee6b1898c42ef25a5466dd (patch)
treea7ca7f0db7b347ed54726fab11f5a01feecb6c8f /src/gui/widgets/scrollarea.cpp
parent26ec3807ac2f3ab7ffdb9e04a209385ac39bd6e3 (diff)
downloadmv-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.gz
mv-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.bz2
mv-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.xz
mv-c52472123eb7847b5cee6b1898c42ef25a5466dd.zip
Add support for themed background for scrollarea.
Diffstat (limited to 'src/gui/widgets/scrollarea.cpp')
-rw-r--r--src/gui/widgets/scrollarea.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 214874f69..6bc75d5a2 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -49,7 +49,7 @@ static std::string const buttonFiles[2] =
"scrollbuttons_pressed.xml"
};
-ScrollArea::ScrollArea(bool opaque):
+ScrollArea::ScrollArea(bool opaque, const std::string &skin):
gcn::ScrollArea(),
mX(0),
mY(0),
@@ -65,10 +65,11 @@ ScrollArea::ScrollArea(bool opaque):
mDrawHeight(0)
{
addWidgetListener(this);
- init();
+ init(skin);
}
-ScrollArea::ScrollArea(gcn::Widget *widget, bool opaque):
+ScrollArea::ScrollArea(gcn::Widget *widget, bool opaque,
+ const std::string &skin):
gcn::ScrollArea(widget),
mX(0),
mY(0),
@@ -83,7 +84,7 @@ ScrollArea::ScrollArea(gcn::Widget *widget, bool opaque):
mDrawWidth(0),
mDrawHeight(0)
{
- init();
+ init(skin);
}
ScrollArea::~ScrollArea()
@@ -92,18 +93,21 @@ ScrollArea::~ScrollArea()
delete getContent();
instances--;
- if (instances == 0 && Theme::instance())
+ Theme *theme = Theme::instance();
+ if (theme)
{
- Theme *theme = Theme::instance();
theme->unloadRect(background);
- theme->unloadRect(vMarker);
- theme->unloadRect(vMarkerHi);
- for (int i = 0; i < 2; i ++)
+ if (instances == 0)
{
- for (int f = UP; f < BUTTONS_DIR; f ++)
+ theme->unloadRect(vMarker);
+ theme->unloadRect(vMarkerHi);
+ for (int i = 0; i < 2; i ++)
{
- if (buttons[f][i])
- buttons[f][i]->decRef();
+ for (int f = UP; f < BUTTONS_DIR; f ++)
+ {
+ if (buttons[f][i])
+ buttons[f][i]->decRef();
+ }
}
}
}
@@ -112,7 +116,7 @@ ScrollArea::~ScrollArea()
mVertexes = nullptr;
}
-void ScrollArea::init()
+void ScrollArea::init(std::string skinName)
{
setOpaque(mOpaque);
@@ -121,6 +125,9 @@ void ScrollArea::init()
setLeftButtonScrollAmount(2);
setRightButtonScrollAmount(2);
+ if (skinName == "")
+ skinName = "scroll_background.xml";
+ Theme::instance()->loadRect(background, skinName);
if (instances == 0)
{
for (int f = 0; f < 9; f ++)
@@ -132,7 +139,6 @@ void ScrollArea::init()
if (Theme::instance())
{
- Theme::instance()->loadRect(background, "scroll_background.xml");
Theme::instance()->loadRect(vMarker, "scroll.xml");
Theme::instance()->loadRect(vMarkerHi, "scroll_highlighted.xml");
}