diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-28 20:24:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-28 20:29:17 +0300 |
commit | 95b811f2852627f65feaeaf0b67532b00903f31c (patch) | |
tree | 157492041c1f5b37824dacfa830d51b1765c7fda /src/gui | |
parent | 5ed8cf4555496ff5636c09ac12be91fb67a2a283 (diff) | |
download | plus-95b811f2852627f65feaeaf0b67532b00903f31c.tar.gz plus-95b811f2852627f65feaeaf0b67532b00903f31c.tar.bz2 plus-95b811f2852627f65feaeaf0b67532b00903f31c.tar.xz plus-95b811f2852627f65feaeaf0b67532b00903f31c.zip |
improve windowmenu.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windowmenu.cpp | 20 | ||||
-rw-r--r-- | src/gui/windowmenu.h | 4 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 45db47d58..57feba81c 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -66,7 +66,6 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : int h = 0; setFocusable(false); - // TRANSLATORS: short button name for who is online window. addButton(N_("ONL"), _("Who is online"), x, h, Input::KEY_WINDOW_ONLINE); @@ -196,7 +195,7 @@ WindowMenu::~WindowMenu() for (std::vector <Button*>::iterator it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) { - Button *btn = dynamic_cast<Button*>(*it); + Button *const btn = dynamic_cast<Button*>(*it); if (!btn) continue; if (!btn->isVisible()) @@ -286,16 +285,17 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event) const int x = event.getX(); const int y = event.getY(); const int key = btn->getTag(); + const gcn::Rectangle &rect = mDimension; if (key != Input::KEY_NO_VALUE) { - mTextPopup->show(x + getX(), y + getY(), btn->getDescription(), + mTextPopup->show(x + rect.x, y + rect.y, btn->getDescription(), // TRANSLATORS: short key name strprintf(_("Key: %s"), inputManager.getKeyValueString( key).c_str())); } else { - mTextPopup->show(x + getX(), y + getY(), btn->getDescription()); + mTextPopup->show(x + rect.x, y + rect.y, btn->getDescription()); } } @@ -322,7 +322,8 @@ void WindowMenu::showButton(const std::string &name, const bool visible) void WindowMenu::updateButtons() { - int x = mPadding, h = 0; + int x = mPadding; + int h = 0; FOR_EACH (std::vector <Button*>::const_iterator, it, mButtons) safeRemove(*it); const int pad2 = 2 * mPadding; @@ -365,8 +366,9 @@ void WindowMenu::loadButtons() for (int f = 0; f < 30; f ++) { - std::string str = config.getValue("windowmenu" + toString(f), ""); - if (str == "" || str == "SET") + const std::string str = config.getValue( + "windowmenu" + toString(f), ""); + if (str.empty() || str == "SET") continue; const ButtonInfo *const info = dynamic_cast<ButtonInfo *const>( mButtonNames[str]); @@ -392,10 +394,10 @@ void WindowMenu::loadButtons() updateButtons(); } -void WindowMenu::saveButtons() +void WindowMenu::saveButtons() const { int i = 0; - for (std::vector <Button*>::iterator it = mButtons.begin(), + for (std::vector <Button*>::const_iterator it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) { diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 3a438e735..b3b77b16f 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -109,12 +109,12 @@ class WindowMenu final : public Container, void loadButtons(); - void saveButtons(); + void saveButtons() const; void optionChanged(const std::string &name) override; protected: - void drawChildren(gcn::Graphics* graphics); + void drawChildren(gcn::Graphics* graphics) override; private: inline void addButton(const char *const text, |