summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-14 13:26:55 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-14 13:35:40 +0300
commit02c0cfce7cdfc712b508d3351136353b2e72b972 (patch)
tree6cae129608fbb06c0e2c66681ad49482e1b5381a
parent8ba9dc8011a3b17d97828f9a8b800f8ad56459bf (diff)
downloadmanaverse-02c0cfce7cdfc712b508d3351136353b2e72b972.tar.gz
manaverse-02c0cfce7cdfc712b508d3351136353b2e72b972.tar.bz2
manaverse-02c0cfce7cdfc712b508d3351136353b2e72b972.tar.xz
manaverse-02c0cfce7cdfc712b508d3351136353b2e72b972.zip
Change checkbox theming.
-rw-r--r--data/graphics/gui/CMakeLists.txt2
-rw-r--r--data/graphics/gui/Makefile.am2
-rw-r--r--data/graphics/gui/checkbox.pngbin802 -> 0 bytes
-rw-r--r--data/graphics/gui/checkbox.xml10
-rw-r--r--data/graphics/gui/window.pngbin17037 -> 17784 bytes
-rw-r--r--src/gui/theme.cpp6
-rw-r--r--src/gui/widgets/checkbox.cpp79
7 files changed, 70 insertions, 29 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index e5f01895a..713c6ffd2 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -5,7 +5,7 @@ SET (FILES
button_highlighted.xml
button_pressed.xml
buttonplay.png
- checkbox.png
+ checkbox.xml
circle-off.xml
circle-on.xml
colors.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index d2e5c1534..81c7da04f 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -8,7 +8,7 @@ gui_DATA = \
button_highlighted.xml \
button_pressed.xml \
buttonplay.png \
- checkbox.png \
+ checkbox.xml \
circle-off.xml \
circle-on.xml \
colors.xml \
diff --git a/data/graphics/gui/checkbox.png b/data/graphics/gui/checkbox.png
deleted file mode 100644
index 29b64100a..000000000
--- a/data/graphics/gui/checkbox.png
+++ /dev/null
Binary files differ
diff --git a/data/graphics/gui/checkbox.xml b/data/graphics/gui/checkbox.xml
new file mode 100644
index 000000000..7e6161bb0
--- /dev/null
+++ b/data/graphics/gui/checkbox.xml
@@ -0,0 +1,10 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="190" ypos="0">
+ <part type="normal" xpos="0" ypos="0" width="9" height="9" />
+ <part type="checked" xpos="9" ypos="0" width="9" height="9" />
+ <part type="disabled" xpos="18" ypos="0" width="9" height="9" />
+ <part type="disabled-checked" xpos="27" ypos="0" width="9" height="9" />
+ <part type="normal-highlighted" xpos="36" ypos="0" width="9" height="9" />
+ <part type="checked-highlighted" xpos="45" ypos="0" width="9" height="9" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index 814111175..9e797bc0f 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 77fe24d51..e01799ea7 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -329,25 +329,31 @@ static SkinParameter skinParam[] =
{0, "up"},
{0, "hstart"},
{0, "in"},
+ {0, "normal"},
{1, "top-edge"},
{1, "highlighted"},
{1, "down"},
{1, "hmiddle"},
{1, "in-highlighted"},
+ {1, "checked"},
{2, "top-right-corner"},
{2, "pressed"},
{2, "left"},
{2, "hend"},
{2, "out"},
+ {2, "disabled"},
{3, "left-edge"},
{3, "disabled"},
{3, "right"},
{3, "hgrip"},
{3, "out-highlighted"},
+ {3, "disabled-checked"},
{4, "bg-quad"},
{4, "vstart"},
+ {4, "normal-highlighted"},
{5, "right-edge"},
{5, "vmiddle"},
+ {5, "checked-highlighted"},
{6, "bottom-left-corner"},
{6, "vend"},
{7, "bottom-edge"},
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 133a5da1d..ab08a95d0 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -53,22 +53,29 @@ CheckBox::CheckBox(const std::string &caption, bool selected,
{
if (instances == 0)
{
- Image *checkBox = Theme::getImageFromTheme("checkbox.png");
- if (checkBox)
+ if (Theme::instance())
{
- checkBoxNormal = checkBox->getSubImage(0, 0, 9, 10);
- checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10);
- checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10);
- checkBoxDisabledChecked = checkBox->getSubImage(27, 0, 9, 10);
- checkBoxNormalHi = checkBox->getSubImage(36, 0, 9, 10);
- checkBoxCheckedHi = checkBox->getSubImage(45, 0, 9, 10);
- checkBoxNormal->setAlpha(mAlpha);
- checkBoxChecked->setAlpha(mAlpha);
- checkBoxDisabled->setAlpha(mAlpha);
- checkBoxDisabledChecked->setAlpha(mAlpha);
- checkBoxNormalHi->setAlpha(mAlpha);
- checkBoxCheckedHi->setAlpha(mAlpha);
- checkBox->decRef();
+ ImageRect rect;
+ Theme::instance()->loadRect(rect, "checkbox.xml", 0, 5);
+ checkBoxNormal = rect.grid[0];
+ checkBoxChecked = rect.grid[1];
+ checkBoxDisabled = rect.grid[2];
+ checkBoxDisabledChecked = rect.grid[3];
+ checkBoxNormalHi = rect.grid[4];
+ checkBoxCheckedHi = rect.grid[5];
+
+ if (checkBoxNormal)
+ checkBoxNormal->setAlpha(mAlpha);
+ if (checkBoxChecked)
+ checkBoxChecked->setAlpha(mAlpha);
+ if (checkBoxDisabled)
+ checkBoxDisabled->setAlpha(mAlpha);
+ if (checkBoxDisabledChecked)
+ checkBoxDisabledChecked->setAlpha(mAlpha);
+ if (checkBoxNormalHi)
+ checkBoxNormalHi->setAlpha(mAlpha);
+ if (checkBoxCheckedHi)
+ checkBoxCheckedHi->setAlpha(mAlpha);
}
else
{
@@ -98,18 +105,36 @@ CheckBox::~CheckBox()
if (instances == 0)
{
- delete checkBoxNormal;
- checkBoxNormal = nullptr;
- delete checkBoxChecked;
- checkBoxChecked = nullptr;
- delete checkBoxDisabled;
- checkBoxDisabled = nullptr;
- delete checkBoxDisabledChecked;
- checkBoxDisabledChecked = nullptr;
- delete checkBoxNormalHi;
- checkBoxNormalHi = nullptr;
- delete checkBoxCheckedHi;
- checkBoxCheckedHi = nullptr;
+ if (checkBoxNormal)
+ {
+ checkBoxNormal->decRef();
+ checkBoxNormal = nullptr;
+ }
+ if (checkBoxChecked)
+ {
+ checkBoxChecked->decRef();
+ checkBoxChecked = nullptr;
+ }
+ if (checkBoxDisabled)
+ {
+ checkBoxDisabled->decRef();
+ checkBoxDisabled = nullptr;
+ }
+ if (checkBoxDisabledChecked)
+ {
+ checkBoxDisabledChecked->decRef();
+ checkBoxDisabledChecked = nullptr;
+ }
+ if (checkBoxNormalHi)
+ {
+ checkBoxNormalHi->decRef();
+ checkBoxNormalHi = nullptr;
+ }
+ if (checkBoxCheckedHi)
+ {
+ checkBoxCheckedHi->decRef();
+ checkBoxCheckedHi = nullptr;
+ }
}
}