diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-07-05 00:52:39 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-11 02:39:48 +0200 |
commit | 2de4411e9b2b81986f4b9e7c645894e59842590e (patch) | |
tree | 6b67b700991efa739abea72a08c813770405e0e2 | |
parent | 7115ac62eb2069d378d67758a3cd221e6620975d (diff) | |
download | mana-2de4411e9b2b81986f4b9e7c645894e59842590e.tar.gz mana-2de4411e9b2b81986f4b9e7c645894e59842590e.tar.bz2 mana-2de4411e9b2b81986f4b9e7c645894e59842590e.tar.xz mana-2de4411e9b2b81986f4b9e7c645894e59842590e.zip |
Changed the Social button to an image one.
I also made the client able to keep the old behaviour,
and i changed the button api to not require the icon frames size
as it could easily guess them.
-rw-r--r-- | data/graphics/gui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | data/graphics/gui/button-icon-social.png | bin | 0 -> 10159 bytes | |||
-rw-r--r-- | src/gui/widgets/button.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/button.h | 5 | ||||
-rw-r--r-- | src/gui/windowmenu.cpp | 20 | ||||
-rw-r--r-- | src/gui/windowmenu.h | 3 |
6 files changed, 26 insertions, 12 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index 92a1e3ef..d8adb10f 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -1,6 +1,7 @@ SET (FILES bubble.png button.png + button-icon-social.png button_disabled.png buttonhi.png buttonpress.png diff --git a/data/graphics/gui/button-icon-social.png b/data/graphics/gui/button-icon-social.png Binary files differnew file mode 100644 index 00000000..f12304c1 --- /dev/null +++ b/data/graphics/gui/button-icon-social.png diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index b2fa9e89..6770c180 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -83,15 +83,14 @@ Button::Button(const std::string &caption, const std::string &actionEventId, adjustSize(); } -void Button::setButtonIcon(const std::string& iconFile, int frameHeight, - int frameWidth) +void Button::setButtonIcon(const std::string& iconFile) { // We clean up possible older references. if (mButtonIcon) removeButtonIcon(); // If nothing relevant was set, we can quit now. - if (iconFile.empty() || !frameWidth || !frameHeight) + if (iconFile.empty()) return; // Load the icon frames. @@ -99,6 +98,10 @@ void Button::setButtonIcon(const std::string& iconFile, int frameHeight, if (!btnIcons) return; + // Compute the sub images size. + int frameWidth = btnIcons->getWidth() / 4; + int frameHeight = btnIcons->getHeight(); + if (btnIcons->getWidth() > 0 && btnIcons->getHeight() > 0) { mButtonIcon = new Image*[BUTTON_COUNT]; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index cfc5043e..39b3eb75 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -72,15 +72,14 @@ class Button : public gcn::Button * Standard, Highlighted, Pressed, and Disabled. * If the image is too short, the missing states won't be loaded. */ - void setButtonIcon(const std::string& iconFile = std::string(), - int frameHeight = 0, int frameWidth = 0); + void setButtonIcon(const std::string& iconFile = std::string()); /** * Set the button popup text when hovering it for a few seconds. * * @note: An empty text will disable the popup. */ - void setButtonPopupText(const std::string& text = ""); + void setButtonPopupText(const std::string& text = std::string()); void logic(); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 7011c82a..5f7aefa7 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -61,7 +61,7 @@ WindowMenu::WindowMenu(): // if (specialsWindow->hasSpecials()) addButton(N_("Specials"), x, h); - addButton(N_("Social"), x, h); + addButton(N_("Social"), x, h, "button-icon-social.png"); addButton(N_("Shortcut"), x, h); addButton(N_("Setup"), x, h); @@ -156,12 +156,22 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event) } } -void WindowMenu::addButton(const char* text, int &x, int &h) +void WindowMenu::addButton(const std::string& text, int &x, int &h, + const std::string& iconPath) { - Button *btn = new Button(gettext(text), text, this); - btn->setButtonPopupText(gettext(text)); + Button *btn = new Button("", text, this); + if (!iconPath.empty()) + { + btn->setButtonPopupText(gettext(text.c_str())); + btn->setButtonIcon(iconPath); + } + else + { + btn->setCaption(gettext(text.c_str())); + } + btn->setPosition(x, 0); add(btn); x += btn->getWidth() + 3; - h = btn->getHeight(); + h = std::max(h, btn->getHeight()); } diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 2bb3e764..b4b0446d 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -48,7 +48,8 @@ class WindowMenu : public Container, void valueChanged(const gcn::SelectionEvent &event); private: - inline void addButton(const char* text, int &x, int &h); + inline void addButton(const std::string& text, int &x, int &h, + const std::string& iconPath = std::string()); EmotePopup *mEmotePopup; }; |