summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-11 00:46:34 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-11 00:46:34 +0300
commit632c1797013d8b0a987ab68341b50354afdb1f9d (patch)
treefda998f25feac4696058c8c1a14e430dceac66d6 /src/gui/theme.cpp
parentee39f800bd1809b25cc7c05238e2fa7abccd8ab3 (diff)
downloadManaVerse-632c1797013d8b0a987ab68341b50354afdb1f9d.tar.gz
ManaVerse-632c1797013d8b0a987ab68341b50354afdb1f9d.tar.bz2
ManaVerse-632c1797013d8b0a987ab68341b50354afdb1f9d.tar.xz
ManaVerse-632c1797013d8b0a987ab68341b50354afdb1f9d.zip
Add support for padding in theme configuration files.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp223
1 files changed, 114 insertions, 109 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 12e7736c0..15dafa997 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -65,14 +65,15 @@ static void initDefaultThemePath()
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
- const std::string &name):
+ const std::string &name, int padding):
instances(0),
mFilePath(filePath),
mName(name),
mBorder(skin),
mCloseImage(close),
mStickyImageUp(stickyUp),
- mStickyImageDown(stickyDown)
+ mStickyImageDown(stickyDown),
+ mPadding(padding)
{}
Skin::~Skin()
@@ -321,6 +322,7 @@ Skin *Theme::readSkin(const std::string &filename)
Image *dBorders = Theme::getImageFromTheme(skinSetImage);
ImageRect border;
memset(&border, 0, sizeof(ImageRect));
+ int padding = 3;
// iterate <widget>'s
for_each_xml_child_node(widgetNode, rootNode)
@@ -332,140 +334,143 @@ Skin *Theme::readSkin(const std::string &filename)
XML::getProperty(widgetNode, "type", "unknown");
if (widgetType == "Window")
{
- // Iterate through <part>'s
- // LEEOR / TODO:
- // We need to make provisions to load in a CloseButton image. For
- // now it can just be hard-coded.
for_each_xml_child_node(partNode, widgetNode)
{
- if (!xmlStrEqual(partNode->name, BAD_CAST "part"))
- continue;
-
- 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 width = XML::getProperty(partNode, "width", 1);
- const int height = XML::getProperty(partNode, "height", 1);
-
- if (partType == "top-left-corner")
+ if (xmlStrEqual(partNode->name, BAD_CAST "part"))
{
- if (dBorders)
+ 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 width = XML::getProperty(partNode, "width", 1);
+ const int height = XML::getProperty(partNode, "height", 1);
+
+ if (partType == "top-left-corner")
{
- border.grid[0] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[0] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[0] = 0;
+ }
}
- else
- {
- border.grid[0] = 0;
- }
- }
- else if (partType == "top-edge")
- {
- if (dBorders)
+ else if (partType == "top-edge")
{
- border.grid[1] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[1] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[1] = 0;
+ }
}
- else
+ else if (partType == "top-right-corner")
{
- border.grid[1] = 0;
+ if (dBorders)
+ {
+ border.grid[2] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[2] = 0;
+ }
}
- }
- else if (partType == "top-right-corner")
- {
- if (dBorders)
- {
- border.grid[2] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[2] = 0;
- }
- }
- // MIDDLE ROW
- else if (partType == "left-edge")
- {
- if (dBorders)
- {
- border.grid[3] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[3] = 0;
- }
- }
- else if (partType == "bg-quad")
- {
- if (dBorders)
+ // MIDDLE ROW
+ else if (partType == "left-edge")
{
- border.grid[4] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[3] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[3] = 0;
+ }
}
- else
+ else if (partType == "bg-quad")
{
- border.grid[4] = 0;
+ if (dBorders)
+ {
+ border.grid[4] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[4] = 0;
+ }
}
- }
- else if (partType == "right-edge")
- {
- if (dBorders)
+ else if (partType == "right-edge")
{
- border.grid[5] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[5] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[5] = 0;
+ }
}
- else
- {
- border.grid[5] = 0;
- }
- }
- // BOTTOM ROW
- else if (partType == "bottom-left-corner")
- {
- if (dBorders)
+ // BOTTOM ROW
+ else if (partType == "bottom-left-corner")
{
- border.grid[6] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[6] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[6] = 0;
+ }
}
- else
+ else if (partType == "bottom-edge")
{
- border.grid[6] = 0;
+ if (dBorders)
+ {
+ border.grid[7] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[7] = 0;
+ }
}
- }
- else if (partType == "bottom-edge")
- {
- if (dBorders)
- {
- border.grid[7] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[7] = 0;
- }
- }
- else if (partType == "bottom-right-corner")
- {
- if (dBorders)
+ else if (partType == "bottom-right-corner")
{
- border.grid[8] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[8] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[8] = 0;
+ }
}
+
else
{
- border.grid[8] = 0;
+ logger->log("Theme::readSkin(): Unknown part type '%s'",
+ partType.c_str());
}
}
-
- else
+ else if (xmlStrEqual(partNode->name, BAD_CAST "option"))
{
- logger->log("Theme::readSkin(): Unknown part type '%s'",
- partType.c_str());
+ const std::string name = XML::getProperty(
+ partNode, "name", "");
+ if (name == "padding")
+ padding = XML::getProperty(partNode, "value", 3);
}
}
}
@@ -495,7 +500,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown,
- filename);
+ filename, "", padding);
skin->updateAlpha(mMinimumOpacity);
return skin;
}