summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-08 20:03:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-13 01:02:40 +0300
commit36b586e32474e0d21de2383aa106869cfef89902 (patch)
tree6db1072a500cc63124c3a9a0712eada375605527
parent960820b57ecf45a4bf5e337bf36adbe02e668fbf (diff)
downloadmanaplus-36b586e32474e0d21de2383aa106869cfef89902.tar.gz
manaplus-36b586e32474e0d21de2383aa106869cfef89902.tar.bz2
manaplus-36b586e32474e0d21de2383aa106869cfef89902.tar.xz
manaplus-36b586e32474e0d21de2383aa106869cfef89902.zip
Change scrollarea theming.
-rw-r--r--data/graphics/gui/CMakeLists.txt19
-rw-r--r--data/graphics/gui/Makefile.am19
-rw-r--r--data/graphics/gui/hscroll_left_default.pngbin358 -> 0 bytes
-rw-r--r--data/graphics/gui/hscroll_left_highlight.pngbin364 -> 0 bytes
-rw-r--r--data/graphics/gui/hscroll_left_pressed.pngbin349 -> 0 bytes
-rw-r--r--data/graphics/gui/hscroll_right_default.pngbin340 -> 0 bytes
-rw-r--r--data/graphics/gui/hscroll_right_highlight.pngbin359 -> 0 bytes
-rw-r--r--data/graphics/gui/hscroll_right_pressed.pngbin350 -> 0 bytes
-rw-r--r--data/graphics/gui/scroll.xml18
-rw-r--r--data/graphics/gui/scroll_background.xml18
-rw-r--r--data/graphics/gui/scroll_highlighted.xml18
-rw-r--r--data/graphics/gui/scrollbuttons.xml8
-rw-r--r--data/graphics/gui/scrollbuttons_pressed.xml8
-rw-r--r--data/graphics/gui/vscroll_down_default.pngbin367 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_down_highlight.pngbin382 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_down_pressed.pngbin376 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_grey.pngbin338 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_highlight.pngbin338 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_up_default.pngbin377 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_up_highlight.pngbin376 -> 0 bytes
-rw-r--r--data/graphics/gui/vscroll_up_pressed.pngbin364 -> 0 bytes
-rw-r--r--data/graphics/gui/window.pngbin4857 -> 11802 bytes
-rw-r--r--src/gui/theme.cpp26
-rw-r--r--src/gui/theme.h3
-rw-r--r--src/gui/widgets/button.cpp22
-rw-r--r--src/gui/widgets/scrollarea.cpp135
-rw-r--r--src/gui/widgets/scrollarea.h3
27 files changed, 141 insertions, 156 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index 2fefbfe6c..67c1352d7 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -9,12 +9,6 @@ SET (FILES
colors.xml
deepbox.png
equipmentbox.png
- hscroll_left_default.png
- hscroll_left_highlight.png
- hscroll_left_pressed.png
- hscroll_right_default.png
- hscroll_right_highlight.png
- hscroll_right_pressed.png
item_shortcut_bgr.png
mouse.png
progress-indicator.png
@@ -23,6 +17,11 @@ SET (FILES
radioout.png
radioout_highlight.png
resize.png
+ scroll.xml
+ scroll_background.xml
+ scroll_highlighted.xml
+ scrollbuttons.xml
+ scrollbuttons_pressed.xml
selection.png
slider.png
slider_hilight.png
@@ -38,14 +37,6 @@ SET (FILES
target-cursor-normal-m.png
target-cursor-normal-s.png
unknown-item.png
- vscroll_down_default.png
- vscroll_down_highlight.png
- vscroll_down_pressed.png
- vscroll_grey.png
- vscroll_highlight.png
- vscroll_up_default.png
- vscroll_up_highlight.png
- vscroll_up_pressed.png
window.png
window.xml
)
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index 0e3e13a1e..e59e2d79a 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -12,12 +12,6 @@ gui_DATA = \
colors.xml \
deepbox.png \
equipmentbox.png \
- hscroll_left_default.png \
- hscroll_left_highlight.png \
- hscroll_left_pressed.png \
- hscroll_right_default.png \
- hscroll_right_highlight.png \
- hscroll_right_pressed.png \
item_shortcut_bgr.png \
mouse.png \
progress-indicator.png \
@@ -26,6 +20,11 @@ gui_DATA = \
radioout.png \
radioout_highlight.png \
resize.png \
+ scroll.xml \
+ scroll_background.xml \
+ scroll_highlighted.xml \
+ scrollbuttons.xml \
+ scrollbuttons_pressed.xml\
selection.png \
slider.png \
slider_hilight.png \
@@ -41,14 +40,6 @@ gui_DATA = \
target-cursor-normal-m.png \
target-cursor-normal-s.png \
unknown-item.png \
- vscroll_down_default.png \
- vscroll_down_highlight.png \
- vscroll_down_pressed.png \
- vscroll_grey.png \
- vscroll_highlight.png \
- vscroll_up_default.png \
- vscroll_up_highlight.png \
- vscroll_up_pressed.png \
window.png \
window.xml
diff --git a/data/graphics/gui/hscroll_left_default.png b/data/graphics/gui/hscroll_left_default.png
deleted file mode 100644
index 2f763d302..000000000
--- a/data/graphics/gui/hscroll_left_default.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_highlight.png b/data/graphics/gui/hscroll_left_highlight.png
deleted file mode 100644
index 6be5ae259..000000000
--- a/data/graphics/gui/hscroll_left_highlight.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/hscroll_left_pressed.png b/data/graphics/gui/hscroll_left_pressed.png
deleted file mode 100644
index b8ebcb463..000000000
--- a/data/graphics/gui/hscroll_left_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_default.png b/data/graphics/gui/hscroll_right_default.png
deleted file mode 100644
index 33fdddd0a..000000000
--- a/data/graphics/gui/hscroll_right_default.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_highlight.png b/data/graphics/gui/hscroll_right_highlight.png
deleted file mode 100644
index e9e633eac..000000000
--- a/data/graphics/gui/hscroll_right_highlight.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/hscroll_right_pressed.png b/data/graphics/gui/hscroll_right_pressed.png
deleted file mode 100644
index 53972f2bb..000000000
--- a/data/graphics/gui/hscroll_right_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/scroll.xml b/data/graphics/gui/scroll.xml
new file mode 100644
index 000000000..0bcdf9ad8
--- /dev/null
+++ b/data/graphics/gui/scroll.xml
@@ -0,0 +1,18 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="41" ypos="164">
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
+ <part type="top-edge" xpos="4" ypos="0" width="3" height="4" />
+ <part type="top-right-corner" xpos="7" ypos="0" width="4" height="4" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="4" height="11" />
+ <part type="bg-quad" xpos="4" ypos="4" width="3" height="11" />
+ <part type="right-edge" xpos="7" ypos="4" width="4" height="11" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="15" width="4" height="4" />
+ <part type="bottom-edge" xpos="4" ypos="15" width="3" height="4" />
+ <part type="bottom-right-corner" xpos="7" ypos="15" width="4" height="4" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scroll_background.xml b/data/graphics/gui/scroll_background.xml
new file mode 100644
index 000000000..4a63cf25c
--- /dev/null
+++ b/data/graphics/gui/scroll_background.xml
@@ -0,0 +1,18 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="41" ypos="186">
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
+ <part type="top-edge" xpos="3" ypos="0" width="26" height="4" />
+ <part type="top-right-corner" xpos="28" ypos="0" width="4" height="4" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="3" width="4" height="26" />
+ <part type="bg-quad" xpos="3" ypos="3" width="26" height="26" />
+ <part type="right-edge" xpos="28" ypos="3" width="4" height="26" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="28" width="4" height="4" />
+ <part type="bottom-edge" xpos="3" ypos="28" width="26" height="4" />
+ <part type="bottom-right-corner" xpos="28" ypos="28" width="4" height="4" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scroll_highlighted.xml b/data/graphics/gui/scroll_highlighted.xml
new file mode 100644
index 000000000..4833972cf
--- /dev/null
+++ b/data/graphics/gui/scroll_highlighted.xml
@@ -0,0 +1,18 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="57" ypos="164">
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
+ <part type="top-edge" xpos="4" ypos="0" width="3" height="4" />
+ <part type="top-right-corner" xpos="7" ypos="0" width="4" height="4" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="4" height="11" />
+ <part type="bg-quad" xpos="4" ypos="4" width="3" height="11" />
+ <part type="right-edge" xpos="7" ypos="4" width="4" height="11" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="15" width="4" height="4" />
+ <part type="bottom-edge" xpos="4" ypos="15" width="3" height="4" />
+ <part type="bottom-right-corner" xpos="7" ypos="15" width="4" height="4" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scrollbuttons.xml b/data/graphics/gui/scrollbuttons.xml
new file mode 100644
index 000000000..2c57cd0ba
--- /dev/null
+++ b/data/graphics/gui/scrollbuttons.xml
@@ -0,0 +1,8 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="41" ypos="100">
+ <part type="left" xpos="0" ypos="0" width="12" height="12" />
+ <part type="right" xpos="0" ypos="16" width="12" height="12" />
+ <part type="down" xpos="0" ypos="32" width="12" height="12" />
+ <part type="up" xpos="0" ypos="48" width="12" height="12" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/scrollbuttons_pressed.xml b/data/graphics/gui/scrollbuttons_pressed.xml
new file mode 100644
index 000000000..f4fb89f15
--- /dev/null
+++ b/data/graphics/gui/scrollbuttons_pressed.xml
@@ -0,0 +1,8 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="57" ypos="100">
+ <part type="left" xpos="0" ypos="0" width="12" height="12" />
+ <part type="right" xpos="0" ypos="16" width="12" height="12" />
+ <part type="down" xpos="0" ypos="32" width="12" height="12" />
+ <part type="up" xpos="0" ypos="48" width="12" height="12" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/vscroll_down_default.png b/data/graphics/gui/vscroll_down_default.png
deleted file mode 100644
index c4292489e..000000000
--- a/data/graphics/gui/vscroll_down_default.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_highlight.png b/data/graphics/gui/vscroll_down_highlight.png
deleted file mode 100644
index ac88f7c73..000000000
--- a/data/graphics/gui/vscroll_down_highlight.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_down_pressed.png b/data/graphics/gui/vscroll_down_pressed.png
deleted file mode 100644
index 9dcc89f6f..000000000
--- a/data/graphics/gui/vscroll_down_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_grey.png b/data/graphics/gui/vscroll_grey.png
deleted file mode 100644
index f99da4676..000000000
--- a/data/graphics/gui/vscroll_grey.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_highlight.png b/data/graphics/gui/vscroll_highlight.png
deleted file mode 100644
index 2e0fcbfc1..000000000
--- a/data/graphics/gui/vscroll_highlight.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_default.png b/data/graphics/gui/vscroll_up_default.png
deleted file mode 100644
index 1cecc3512..000000000
--- a/data/graphics/gui/vscroll_up_default.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_highlight.png b/data/graphics/gui/vscroll_up_highlight.png
deleted file mode 100644
index 7b5009f39..000000000
--- a/data/graphics/gui/vscroll_up_highlight.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/vscroll_up_pressed.png b/data/graphics/gui/vscroll_up_pressed.png
deleted file mode 100644
index 2320ec42f..000000000
--- a/data/graphics/gui/vscroll_up_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index a0d5da63c..81a1526dc 100644
--- a/data/graphics/gui/window.png
+++ b/data/graphics/gui/window.png
Binary files differ
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 779d98768..9bf5adcf6 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -410,6 +410,14 @@ Skin *Theme::readSkin(const std::string &filename)
loadSkinImage(7, "bottom-edge")
else
loadSkinImage(8, "bottom-right-corner")
+ else
+ loadSkinImage(0, "up")
+ else
+ loadSkinImage(1, "down")
+ else
+ loadSkinImage(2, "left")
+ else
+ loadSkinImage(3, "right")
}
else if (xmlNameEqual(partNode, "option"))
{
@@ -818,3 +826,21 @@ void Theme::loadColors(std::string file)
}
}
}
+
+void Theme::loadRect(ImageRect &image, std::string name, int start, int end)
+{
+ Skin *skin = load(name);
+ if (skin)
+ {
+ const ImageRect &rect = skin->getBorder();
+ for (int f = start; f <= end; f ++)
+ {
+ if (rect.grid[f])
+ {
+ rect.grid[f]->incRef();
+ image.grid[f] = rect.grid[f];
+ }
+ }
+ unload(skin);
+ }
+}
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 8c5675454..144cfd274 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -269,6 +269,9 @@ class Theme : public Palette, public ConfigListener
void optionChanged(const std::string &);
+ void loadRect(ImageRect &image, std::string name,
+ int start = 0, int end = 8);
+
private:
Theme();
~Theme();
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 990faaaeb..ba789f2c5 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -173,30 +173,10 @@ void Button::init()
if (mInstances == 0)
{
- // Load the skin
- Image *btn[BUTTON_COUNT];
-
if (Theme::instance())
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- {
- Skin *skin = Theme::instance()->load(data[mode]);
- if (skin)
- {
- const ImageRect &rect = skin->getBorder();
-
- for (int f = 0; f < 9; f ++)
- {
- if (rect.grid[f])
- {
- rect.grid[f]->incRef();
- button[mode].grid[f] = rect.grid[f];
- }
- }
-
- Theme::instance()->unload(skin);
- }
- }
+ Theme::instance()->loadRect(button[mode], data[mode]);
}
updateAlpha();
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 021bd3d15..4e15bc167 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -43,6 +43,12 @@ ImageRect ScrollArea::vMarker;
ImageRect ScrollArea::vMarkerHi;
Image *ScrollArea::buttons[4][2];
+static std::string const buttonFiles[2] =
+{
+ "scrollbuttons.xml",
+ "scrollbuttons_pressed.xml"
+};
+
ScrollArea::ScrollArea():
gcn::ScrollArea(),
mX(0),
@@ -87,29 +93,6 @@ ScrollArea::~ScrollArea()
instances--;
- if (instances == 0)
- {
- for_each(background.grid, background.grid + 9, dtor<Image*>());
- for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>());
- for_each(vMarkerHi.grid, vMarkerHi.grid + 9, dtor<Image*>());
-
- if (buttons[UP][0])
- buttons[UP][0]->decRef();
- if (buttons[UP][1])
- buttons[UP][1]->decRef();
- if (buttons[DOWN][0])
- buttons[DOWN][0]->decRef();
- if (buttons[DOWN][1])
- buttons[DOWN][1]->decRef();
- if (buttons[LEFT][0])
- buttons[LEFT][0]->decRef();
- if (buttons[LEFT][1])
- buttons[LEFT][1]->decRef();
- if (buttons[RIGHT][0])
- buttons[RIGHT][0]->decRef();
- if (buttons[RIGHT][1])
- buttons[RIGHT][1]->decRef();
- }
delete mVertexes;
mVertexes = nullptr;
}
@@ -126,99 +109,39 @@ void ScrollArea::init()
if (instances == 0)
{
- // Load the background skin
- Image *textbox = Theme::getImageFromTheme("deepbox.png");
- const int bggridx[4] = {0, 3, 28, 31};
- const int bggridy[4] = {0, 3, 28, 31};
- int a = 0, x, y;
-
- for (y = 0; y < 3; y++)
+ for (int f = 0; f < 9; f ++)
{
- for (x = 0; x < 3; x++)
- {
- if (textbox)
- {
- background.grid[a] = textbox->getSubImage(
- bggridx[x], bggridy[y],
- bggridx[x + 1] - bggridx[x] + 1,
- bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(
- Client::getGuiAlpha());
- }
- else
- {
- background.grid[a] = nullptr;
- }
- a++;
- }
+ background.grid[f] = nullptr;
+ vMarker.grid[f] = nullptr;
+ vMarkerHi.grid[f] = nullptr;
}
- if (textbox)
- textbox->decRef();
-
- // Load vertical scrollbar skin
- Image *vscroll = Theme::getImageFromTheme("vscroll_grey.png");
- Image *vscrollHi = Theme::getImageFromTheme("vscroll_highlight.png");
-
- int vsgridx[4] = {0, 4, 7, 11};
- int vsgridy[4] = {0, 4, 15, 19};
- a = 0;
+ if (Theme::instance())
+ {
+ Theme::instance()->loadRect(background, "scroll_background.xml");
+ Theme::instance()->loadRect(vMarker, "scroll.xml");
+ Theme::instance()->loadRect(vMarkerHi, "scroll_highlighted.xml");
+ }
- for (y = 0; y < 3; y++)
+ for (int i = 0; i < 2; i ++)
{
- for (x = 0; x < 3; x++)
+ Skin *skin = Theme::instance()->load(buttonFiles[i]);
+ if (skin)
{
- if (vscroll)
- {
- vMarker.grid[a] = vscroll->getSubImage(
- vsgridx[x], vsgridy[y],
- vsgridx[x + 1] - vsgridx[x],
- vsgridy[y + 1] - vsgridy[y]);
- vMarker.grid[a]->setAlpha(
- Client::getGuiAlpha());
- }
- else
- {
- vMarker.grid[a] = nullptr;
- }
- if (vscrollHi)
- {
- vMarkerHi.grid[a] = vscrollHi->getSubImage(
- vsgridx[x], vsgridy[y],
- vsgridx[x + 1] - vsgridx[x],
- vsgridy[y + 1] - vsgridy[y]);
- vMarkerHi.grid[a]->setAlpha(
- Client::getGuiAlpha());
- }
- else
+ const ImageRect &rect = skin->getBorder();
+ for (int f = UP; f < BUTTONS_DIR; f ++)
{
- vMarkerHi.grid[a] = nullptr;
+ rect.grid[f]->incRef();
+ buttons[f][i] = rect.grid[f];
}
- a++;
}
+ else
+ {
+ for (int f = UP; f < BUTTONS_DIR; f ++)
+ buttons[f][i] = nullptr;
+ }
+ Theme::instance()->unload(skin);
}
-
- if (vscroll)
- vscroll->decRef();
- if (vscrollHi)
- vscrollHi->decRef();
-
- buttons[UP][0] =
- Theme::getImageFromTheme("vscroll_up_default.png");
- buttons[DOWN][0] =
- Theme::getImageFromTheme("vscroll_down_default.png");
- buttons[LEFT][0] =
- Theme::getImageFromTheme("hscroll_left_default.png");
- buttons[RIGHT][0] =
- Theme::getImageFromTheme("hscroll_right_default.png");
- buttons[UP][1] =
- Theme::getImageFromTheme("vscroll_up_pressed.png");
- buttons[DOWN][1] =
- Theme::getImageFromTheme("vscroll_down_pressed.png");
- buttons[LEFT][1] =
- Theme::getImageFromTheme("hscroll_left_pressed.png");
- buttons[RIGHT][1] =
- Theme::getImageFromTheme("hscroll_right_pressed.png");
}
instances++;
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 582033071..53a79d20f 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -121,7 +121,8 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
UP = 0,
DOWN,
LEFT,
- RIGHT
+ RIGHT,
+ BUTTONS_DIR
};
/**