summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-12 22:43:27 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-13 00:20:30 +0300
commit262ce6d0ee2737e8d24914e4ed35c29cc335060b (patch)
treef539503bcc7880e5138201e32c08853836a55ee8
parent1bff74b3a86602ba62f3eba2e482436418975432 (diff)
downloadmanaverse-262ce6d0ee2737e8d24914e4ed35c29cc335060b.tar.gz
manaverse-262ce6d0ee2737e8d24914e4ed35c29cc335060b.tar.bz2
manaverse-262ce6d0ee2737e8d24914e4ed35c29cc335060b.tar.xz
manaverse-262ce6d0ee2737e8d24914e4ed35c29cc335060b.zip
Add theming support for background for scrollbars.
By default background is transparent.
-rw-r--r--data/graphics/gui/CMakeLists.txt2
-rw-r--r--data/graphics/gui/Makefile.am2
-rw-r--r--data/graphics/gui/scroll_hbackground.xml12
-rw-r--r--data/graphics/gui/scroll_vbackground.xml13
-rw-r--r--src/gui/widgets/scrollarea.cpp69
-rw-r--r--src/gui/widgets/scrollarea.h2
6 files changed, 88 insertions, 12 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index f0e54313d..46a1db548 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -32,7 +32,9 @@ SET (FILES
resize.xml
scroll.xml
scroll_background.xml
+ scroll_hbackground.xml
scroll_highlighted.xml
+ scroll_vbackground.xml
scrollbuttons.xml
scrollbuttons_pressed.xml
sell.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index 824d7644f..bae374b8e 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -35,7 +35,9 @@ gui_DATA = \
resize.xml \
scroll.xml \
scroll_background.xml \
+ scroll_hbackground.xml \
scroll_highlighted.xml \
+ scroll_vbackground.xml \
scrollbuttons.xml \
scrollbuttons_pressed.xml\
sell.xml \
diff --git a/data/graphics/gui/scroll_hbackground.xml b/data/graphics/gui/scroll_hbackground.xml
new file mode 100644
index 000000000..d8f9f6168
--- /dev/null
+++ b/data/graphics/gui/scroll_hbackground.xml
@@ -0,0 +1,12 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="135" ypos="164">
+ <!-- Left Row -->
+ <part type="left-edge" xpos="0" ypos="0" width="6" height="12" />
+
+ <!-- Middle Row -->
+ <part type="bg-quad" xpos="6" ypos="0" width="6" height="12" />
+
+ <!-- Right Row -->
+ <part type="right-edge" xpos="12" ypos="0" width="6" height="12" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scroll_vbackground.xml b/data/graphics/gui/scroll_vbackground.xml
new file mode 100644
index 000000000..69566c35f
--- /dev/null
+++ b/data/graphics/gui/scroll_vbackground.xml
@@ -0,0 +1,13 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="121" ypos="164">
+
+ <!-- Top Row -->
+ <part type="top-edge" xpos="0" ypos="0" width="12" height="6" />
+
+ <!-- Middle Row -->
+ <part type="bg-quad" xpos="0" ypos="6" width="12" height="6" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-edge" xpos="0" ypos="12" width="12" height="6" />
+ </widget>
+</skinset>
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 0804a3b6e..bc0375601 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -39,6 +39,8 @@ float ScrollArea::mAlpha = 1.0;
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
ImageRect ScrollArea::vMarkerHi;
+ImageRect ScrollArea::vBackground;
+ImageRect ScrollArea::hBackground;
Image *ScrollArea::buttons[4][2];
static std::string const buttonFiles[2] =
@@ -101,6 +103,8 @@ ScrollArea::~ScrollArea()
{
theme->unloadRect(vMarker);
theme->unloadRect(vMarkerHi);
+ theme->unloadRect(vBackground);
+ theme->unloadRect(hBackground);
for (int i = 0; i < 2; i ++)
{
for (int f = UP; f < BUTTONS_DIR; f ++)
@@ -127,7 +131,10 @@ void ScrollArea::init(std::string skinName)
if (skinName == "")
skinName = "scroll_background.xml";
- Theme::instance()->loadRect(background, skinName, "scroll_background.xml");
+ Theme *const theme = Theme::instance();
+ if (theme)
+ theme->loadRect(background, skinName, "scroll_background.xml");
+
if (instances == 0)
{
for (int f = 0; f < 9; f ++)
@@ -135,13 +142,16 @@ void ScrollArea::init(std::string skinName)
background.grid[f] = nullptr;
vMarker.grid[f] = nullptr;
vMarkerHi.grid[f] = nullptr;
+ vBackground.grid[f] = nullptr;
+ hBackground.grid[f] = nullptr;
}
- if (Theme::instance())
+ if (theme)
{
- Theme::instance()->loadRect(vMarker, "scroll.xml", "");
- Theme::instance()->loadRect(vMarkerHi, "scroll_highlighted.xml",
- "scroll.xml");
+ theme->loadRect(vMarker, "scroll.xml", "");
+ theme->loadRect(vMarkerHi, "scroll_highlighted.xml", "scroll.xml");
+ theme->loadRect(vBackground, "scroll_vbackground.xml", "");
+ theme->loadRect(hBackground, "scroll_hbackground.xml", "");
}
for (int i = 0; i < 2; i ++)
@@ -230,6 +240,10 @@ void ScrollArea::updateAlpha()
{
if (background.grid[a])
background.grid[a]->setAlpha(mAlpha);
+ if (hBackground.grid[a])
+ hBackground.grid[a]->setAlpha(mAlpha);
+ if (vBackground.grid[a])
+ vBackground.grid[a]->setAlpha(mAlpha);
if (vMarker.grid[a])
vMarker.grid[a]->setAlpha(mAlpha);
if (vMarkerHi.grid[a])
@@ -260,7 +274,6 @@ void ScrollArea::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-//void ScrollArea::drawFrame(gcn::Graphics *graphics A_UNUSED)
void ScrollArea::drawFrame(gcn::Graphics *graphics)
{
if (mOpaque)
@@ -381,17 +394,49 @@ void ScrollArea::drawRightButton(gcn::Graphics *const graphics)
void ScrollArea::drawVBar(gcn::Graphics *const graphics)
{
const gcn::Rectangle dim = getVerticalBarDimension();
- graphics->setColor(mGray);
- graphics->fillRectangle(dim);
- graphics->setColor(mBackground);
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ if (vBackground.grid[4])
+ {
+ g->drawImagePattern(vBackground.grid[4],
+ dim.x, dim.y, dim.width, dim.height);
+ }
+ if (vBackground.grid[1])
+ {
+ g->drawImagePattern(vBackground.grid[1],
+ dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight());
+ }
+ if (vBackground.grid[7])
+ {
+ g->drawImagePattern(vBackground.grid[7],
+ dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
+ dim.width, vBackground.grid[7]->getHeight());
+ }
}
void ScrollArea::drawHBar(gcn::Graphics *const graphics)
{
const gcn::Rectangle dim = getHorizontalBarDimension();
- graphics->setColor(mGray);
- graphics->fillRectangle(dim);
- graphics->setColor(mBackground);
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ if (hBackground.grid[4])
+ {
+ g->drawImagePattern(hBackground.grid[4],
+ dim.x, dim.y, dim.width, dim.height);
+ }
+
+ if (hBackground.grid[3])
+ {
+ g->drawImagePattern(hBackground.grid[3],
+ dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height);
+ }
+
+ if (hBackground.grid[5])
+ {
+ g->drawImagePattern(hBackground.grid[5],
+ dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y,
+ hBackground.grid[5]->getWidth(), dim.height);
+ }
}
void ScrollArea::drawVMarker(gcn::Graphics *const graphics)
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 6d99be1ae..4abff1398 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -146,6 +146,8 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
static ImageRect background;
static ImageRect vMarker;
static ImageRect vMarkerHi;
+ static ImageRect vBackground;
+ static ImageRect hBackground;
static Image *buttons[4][2];
int mX, mY;