diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/theme.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/checkbox.cpp | 79 |
2 files changed, 58 insertions, 27 deletions
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; + } } } |