summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-01 13:56:14 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-01 13:56:14 +0300
commit020c5e1b6abd52135a3b87fc38238498d7ac6e3d (patch)
treee95676cc3d718f1ed0fc35ec6b59e2fe6e84cf72
parent9c47e5cfc0e91071e0b5ad12b08f7d0c017d7856 (diff)
downloadmanaplus-020c5e1b6abd52135a3b87fc38238498d7ac6e3d.tar.gz
manaplus-020c5e1b6abd52135a3b87fc38238498d7ac6e3d.tar.bz2
manaplus-020c5e1b6abd52135a3b87fc38238498d7ac6e3d.tar.xz
manaplus-020c5e1b6abd52135a3b87fc38238498d7ac6e3d.zip
Add theming support for top right buttons.
New theme file: windowmenu.xml Options in windowmenu.xml: padding - padding from window borders spacing - space between buttons.
-rw-r--r--data/graphics/gui/CMakeLists.txt1
-rw-r--r--data/graphics/gui/Makefile.am1
-rw-r--r--data/graphics/gui/windowmenu.xml6
-rw-r--r--src/gui/windowmenu.cpp23
-rw-r--r--src/gui/windowmenu.h3
5 files changed, 26 insertions, 8 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index d71f54822..f0244d697 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -72,6 +72,7 @@ SET (FILES
unknown-item.png
window.png
window.xml
+ windowmenu.xml
world.xml
)
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index b058a10b5..c691404e9 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -75,6 +75,7 @@ gui_DATA = \
unknown-item.png \
window.png \
window.xml \
+ windowmenu.xml \
world.xml
EXTRA_DIST = \
diff --git a/data/graphics/gui/windowmenu.xml b/data/graphics/gui/windowmenu.xml
new file mode 100644
index 000000000..3d9e84289
--- /dev/null
+++ b/data/graphics/gui/windowmenu.xml
@@ -0,0 +1,6 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <option name="padding" value="1" />
+ <option name="spacing" value="1" />
+ </widget>
+</skinset>
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index c7bccb9bc..dcf5f18bc 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -68,11 +68,15 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
gcn::ActionListener(),
gcn::SelectionListener(),
gcn::MouseListener(),
+ mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "")
+ : nullptr),
+ mPadding(mSkin ? mSkin->getPadding() : 1),
+ mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
mTextPopup(new TextPopup),
mHaveMouse(false),
mAutoHide(1)
{
- int x = 0;
+ int x = mPadding;
int h = 0;
setFocusable(false);
@@ -168,6 +172,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
addButton(N_("SET"),
_("Setup"), x, h, Input::KEY_WINDOW_SETUP, setupWindow);
+ x += mPadding - mSpacing;
if (mainGraphics)
setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h));
@@ -241,7 +246,7 @@ void WindowMenu::addButton(const char *const text,
const bool visible)
{
Button *const btn = new Button(this, gettext(text), text, this);
- btn->setPosition(x, 0);
+ btn->setPosition(x, mPadding);
btn->setDescription(description);
btn->setTag(key);
add(btn);
@@ -254,8 +259,8 @@ void WindowMenu::addButton(const char *const text,
else
*/
{
- x += btn->getWidth() + 3;
- h = btn->getHeight();
+ x += btn->getWidth() + mSpacing;
+ h = btn->getHeight() + 2 * mPadding;
}
mButtons.push_back(btn);
mButtonNames[text] = new ButtonInfo(btn, window, visible);
@@ -339,10 +344,11 @@ void WindowMenu::showButton(const std::string &name, const bool visible)
void WindowMenu::updateButtons()
{
- int x = 0, h = 0;
+ int x = mPadding, h = 0;
std::vector <Button*>::const_iterator it, it_end;
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
safeRemove(*it);
+ const int pad2 = 2 * mPadding;
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
{
Button *const btn = dynamic_cast<Button *const>(*it);
@@ -350,12 +356,13 @@ void WindowMenu::updateButtons()
continue;
if (btn->isVisible())
{
- btn->setPosition(x, 0);
+ btn->setPosition(x, mPadding);
add(btn);
- x += btn->getWidth() + 3;
- h = btn->getHeight();
+ x += btn->getWidth() + mSpacing;
+ h = btn->getHeight() + pad2;
}
}
+ x += mPadding - mSpacing;
if (mainGraphics)
setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h));
}
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 635febaec..10fec6fb4 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -108,6 +108,9 @@ class WindowMenu final : public Container,
void updateButtons();
+ Skin *mSkin;
+ int mPadding;
+ int mSpacing;
TextPopup *mTextPopup;
std::vector <Button*> mButtons;
std::map <std::string, ButtonInfo*> mButtonNames;