summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-08 13:48:58 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-13 01:02:40 +0300
commit960820b57ecf45a4bf5e337bf36adbe02e668fbf (patch)
tree680acda1e45144ec6862cca2a7fef453118bdd1c /src/gui/theme.cpp
parent72edb1ab7036ed859b543046b866d4092d3c6cdb (diff)
downloadmanaplus-960820b57ecf45a4bf5e337bf36adbe02e668fbf.tar.gz
manaplus-960820b57ecf45a4bf5e337bf36adbe02e668fbf.tar.bz2
manaplus-960820b57ecf45a4bf5e337bf36adbe02e668fbf.tar.xz
manaplus-960820b57ecf45a4bf5e337bf36adbe02e668fbf.zip
Improve theming.
Add support for theming button.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 704a1f939..779d98768 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -307,15 +307,33 @@ void Theme::optionChanged(const std::string &)
updateAlpha();
}
-#define loadSkinSubImage(object, name) \
+#define loadSkinImage(obj, name) \
if (partType == name) \
{ \
if (dBorders) \
- object = dBorders->getSubImage(xPos, yPos, width, height); \
+ { \
+ border.grid[obj] = dBorders->getSubImage( \
+ xPos, yPos, width, height); \
+ } \
else \
- object = nullptr; \
+ { \
+ border.grid[obj] = nullptr; \
+ } \
}
+#define loadSkinImage2(obj, name1, name2) \
+ if (partType == name1 || partType == name2) \
+ { \
+ if (dBorders) \
+ { \
+ border.grid[obj] = dBorders->getSubImage( \
+ xPos, yPos, width, height); \
+ } \
+ else \
+ { \
+ border.grid[obj] = nullptr; \
+ } \
+ }
Skin *Theme::readSkin(const std::string &filename)
{
@@ -360,35 +378,38 @@ Skin *Theme::readSkin(const std::string &filename)
XML::getProperty(widgetNode, "type", "unknown");
if (widgetType == "Window")
{
+ const int globalXPos = XML::getProperty(widgetNode, "xpos", 0);
+ const int globalYPos = XML::getProperty(widgetNode, "ypos", 0);
for_each_xml_child_node(partNode, widgetNode)
{
if (xmlNameEqual(partNode, "part"))
{
const std::string partType =
XML::getProperty(partNode, "type", "unknown");
- // TOP ROW
- const int xPos = XML::getProperty(partNode, "xpos", 0);
- const int yPos = XML::getProperty(partNode, "ypos", 0);
+ const int xPos = XML::getProperty(
+ partNode, "xpos", 0) + globalXPos;
+ const int yPos = XML::getProperty(
+ partNode, "ypos", 0) + globalYPos;
const int width = XML::getProperty(partNode, "width", 1);
const int height = XML::getProperty(partNode, "height", 1);
- loadSkinSubImage(border.grid[0], "top-left-corner")
+ loadSkinImage2(0, "top-left-corner", "standart")
else
- loadSkinSubImage(border.grid[1], "top-edge")
+ loadSkinImage2(1, "top-edge", "highlighted")
else
- loadSkinSubImage(border.grid[2], "top-right-corner")
+ loadSkinImage2(2, "top-right-corner", "pressed")
else
- loadSkinSubImage(border.grid[3], "left-edge")
+ loadSkinImage2(3, "left-edge", "disabled")
else
- loadSkinSubImage(border.grid[4], "bg-quad")
+ loadSkinImage(4, "bg-quad")
else
- loadSkinSubImage(border.grid[5], "right-edge")
+ loadSkinImage(5, "right-edge")
else
- loadSkinSubImage(border.grid[6], "bottom-left-corner")
+ loadSkinImage(6, "bottom-left-corner")
else
- loadSkinSubImage(border.grid[7], "bottom-edge")
+ loadSkinImage(7, "bottom-edge")
else
- loadSkinSubImage(border.grid[8], "bottom-right-corner")
+ loadSkinImage(8, "bottom-right-corner")
}
else if (xmlNameEqual(partNode, "option"))
{