summaryrefslogtreecommitdiff
path: root/src/gui
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
parent26ec3807ac2f3ab7ffdb9e04a209385ac39bd6e3 (diff)
downloadplus-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.gz
plus-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.bz2
plus-c52472123eb7847b5cee6b1898c42ef25a5466dd.tar.xz
plus-c52472123eb7847b5cee6b1898c42ef25a5466dd.zip
Add support for themed background for scrollarea.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/scrollarea.cpp34
-rw-r--r--src/gui/widgets/scrollarea.h7
2 files changed, 24 insertions, 17 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");
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 335d810b2..d2032b379 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -46,14 +46,15 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
* Constructor that takes no content. Needed for use with the DropDown
* class.
*/
- ScrollArea(bool opaque = true);
+ ScrollArea(bool opaque = true, const std::string &skin = "");
/**
* Constructor.
*
* @param content the initial content to show in the scroll area
*/
- ScrollArea(gcn::Widget *content, bool opaque = true);
+ ScrollArea(gcn::Widget *content, bool opaque = true,
+ const std::string &skin = "");
/**
* Destructor. Also deletes the content.
@@ -128,7 +129,7 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
/**
* Initializes the scroll area.
*/
- void init();
+ void init(std::string skinName);
void drawButton(gcn::Graphics *graphics, BUTTON_DIR dir);
void drawUpButton(gcn::Graphics *graphics);