diff options
-rw-r--r-- | data/graphics/gui/CMakeLists.txt | 3 | ||||
-rw-r--r-- | data/graphics/gui/Makefile.am | 3 | ||||
-rw-r--r-- | data/graphics/gui/dropdown.xml | 6 | ||||
-rw-r--r-- | data/graphics/gui/dropdown_background.xml | 18 | ||||
-rw-r--r-- | data/graphics/gui/dropdown_pressed.xml | 6 | ||||
-rw-r--r-- | data/graphics/gui/window.png | bin | 11802 -> 11875 bytes | |||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 81 |
7 files changed, 67 insertions, 50 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index dcd6ec8ce..8ba9034b0 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -11,6 +11,9 @@ SET (FILES close_button.png colors.xml deepbox.png + dropdown.xml + dropdown_background.xml + dropdown_pressed.xml equipmentbox.png item_shortcut_bgr.png mouse.png diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index cedb9011a..a0546aaa3 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -14,6 +14,9 @@ gui_DATA = \ close_button.png \ colors.xml \ deepbox.png \ + dropdown.xml \ + dropdown_background.xml \ + dropdown_pressed.xml \ equipmentbox.png \ item_shortcut_bgr.png \ mouse.png \ diff --git a/data/graphics/gui/dropdown.xml b/data/graphics/gui/dropdown.xml new file mode 100644 index 000000000..d9002dcfc --- /dev/null +++ b/data/graphics/gui/dropdown.xml @@ -0,0 +1,6 @@ +<skinset name="Default" image="window.png"> + <widget type="Window" xpos="89" ypos="100"> + <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/dropdown_background.xml b/data/graphics/gui/dropdown_background.xml new file mode 100644 index 000000000..4a63cf25c --- /dev/null +++ b/data/graphics/gui/dropdown_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/dropdown_pressed.xml b/data/graphics/gui/dropdown_pressed.xml new file mode 100644 index 000000000..ac310d613 --- /dev/null +++ b/data/graphics/gui/dropdown_pressed.xml @@ -0,0 +1,6 @@ +<skinset name="Default" image="window.png"> + <widget type="Window" xpos="105" ypos="100"> + <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/window.png b/data/graphics/gui/window.png Binary files differindex 81a1526dc..f0da0dce7 100644 --- a/data/graphics/gui/window.png +++ b/data/graphics/gui/window.png diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 0fc3675a2..8727f940f 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -48,6 +48,12 @@ Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; float DropDown::mAlpha = 1.0; +static std::string const dropdownFiles[2] = +{ + "dropdown.xml", + "dropdown_pressed.xml" +}; + DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, std::string eventId): gcn::DropDown::DropDown(listModel, @@ -60,47 +66,37 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, if (instances == 0) { // Load the background skin - - // Get the button skin - buttons[1][0] = Theme::getImageFromTheme("vscroll_up_default.png"); - buttons[0][0] = Theme::getImageFromTheme("vscroll_down_default.png"); - buttons[1][1] = Theme::getImageFromTheme("vscroll_up_pressed.png"); - buttons[0][1] = Theme::getImageFromTheme("vscroll_down_pressed.png"); - - if (buttons[0][0]) - buttons[0][0]->setAlpha(mAlpha); - if (buttons[0][1]) - buttons[0][1]->setAlpha(mAlpha); - if (buttons[1][0]) - buttons[1][0]->setAlpha(mAlpha); - if (buttons[1][1]) - buttons[1][1]->setAlpha(mAlpha); - - // get the border skin - Image *boxBorder = Theme::getImageFromTheme("deepbox.png"); - if (boxBorder) + for (int i = 0; i < 2; i ++) { - int gridx[4] = {0, 3, 28, 31}; - int gridy[4] = {0, 3, 28, 31}; - int a = 0, x, y; - - for (y = 0; y < 3; y++) + Skin *skin = Theme::instance()->load(dropdownFiles[i]); + if (skin) { - for (x = 0; x < 3; x++) + const ImageRect &rect = skin->getBorder(); + for (int f = 0; f < 2; f ++) { - skin.grid[a] = boxBorder->getSubImage(gridx[x], gridy[y], - gridx[x + 1] - - gridx[x] + 1, - gridy[y + 1] - - gridy[y] + 1); - if (skin.grid[a]) - skin.grid[a]->setAlpha(mAlpha); - a++; + if (rect.grid[f]) + { + rect.grid[f]->incRef(); + buttons[f][i] = rect.grid[f]; + buttons[f][i]->setAlpha(mAlpha); + } + else + { + buttons[f][i] = nullptr; + } } } - - boxBorder->decRef(); + else + { + for (int f = 0; f < 2; f ++) + buttons[f][i] = nullptr; + } + Theme::instance()->unload(skin); } + + // get the border skin + if (Theme::instance()) + Theme::instance()->loadRect(skin, "dropdown_background.xml"); } instances++; @@ -119,21 +115,6 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, DropDown::~DropDown() { instances--; - // Free images memory - if (instances == 0) - { - if (buttons[0][0]) - buttons[0][0]->decRef(); - if (buttons[0][1]) - buttons[0][1]->decRef(); - if (buttons[1][0]) - buttons[1][0]->decRef(); - if (buttons[1][1]) - buttons[1][1]->decRef(); - - for_each(skin.grid, skin.grid + 9, dtor<Image*>()); - } - delete mScrollArea; mScrollArea = nullptr; } |