summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-02 16:49:27 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-02 16:49:27 +0300
commit54af8ce9c6d972580d2935498e563988450b94f6 (patch)
tree4e870df77b37c22f874704ab0cbbd554cde79507 /src
parent81bd48dee406603164f35170bb2aa1e82c9fc338 (diff)
downloadmv-54af8ce9c6d972580d2935498e563988450b94f6.tar.gz
mv-54af8ce9c6d972580d2935498e563988450b94f6.tar.bz2
mv-54af8ce9c6d972580d2935498e563988450b94f6.tar.xz
mv-54af8ce9c6d972580d2935498e563988450b94f6.zip
add actions for select next/previous tab in shortcuts window.
Diffstat (limited to 'src')
-rw-r--r--src/actionmanager.cpp20
-rw-r--r--src/actionmanager.h2
-rw-r--r--src/gui/setupactiondata.h12
-rw-r--r--src/gui/widgets/tabbedarea.cpp19
-rw-r--r--src/gui/widgets/tabbedarea.h4
-rw-r--r--src/gui/windows/shortcutwindow.cpp12
-rw-r--r--src/gui/windows/shortcutwindow.h4
-rw-r--r--src/gui/windows/socialwindow.cpp24
-rw-r--r--src/input/keyboarddata.h16
-rw-r--r--src/input/keydata.h2
10 files changed, 94 insertions, 21 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 7c370a372..ce01bc8d6 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -1149,4 +1149,24 @@ impHandler0(showWindows)
return false;
}
+impHandler0(nextShortcutsTab)
+{
+ if (itemShortcutWindow)
+ {
+ itemShortcutWindow->nextTab();
+ return true;
+ }
+ return false;
+}
+
+impHandler0(prevShortcutsTab)
+{
+ if (itemShortcutWindow)
+ {
+ itemShortcutWindow->prevTab();
+ return true;
+ }
+ return false;
+}
+
} // namespace ActionManager
diff --git a/src/actionmanager.h b/src/actionmanager.h
index a2df14202..010344458 100644
--- a/src/actionmanager.h
+++ b/src/actionmanager.h
@@ -94,6 +94,8 @@ namespace ActionManager
decHandler(stopSit);
decHandler(showKeyboard);
decHandler(showWindows);
+ decHandler(nextShortcutsTab);
+ decHandler(prevShortcutsTab);
decHandler(hideWindows);
decHandler(helpWindowShow);
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
index 2b9d694a8..6065f624c 100644
--- a/src/gui/setupactiondata.h
+++ b/src/gui/setupactiondata.h
@@ -497,6 +497,18 @@ static SetupActionData setupActionData2[] =
"",
},
{
+ // TRANSLATORS: input action name
+ N_("Previous Shortcuts tab"),
+ Input::KEY_PREV_SHORTCUTS_TAB,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ N_("Next Shortcuts tab"),
+ Input::KEY_NEXT_SHORTCUTS_TAB,
+ "",
+ },
+ {
"",
Input::KEY_NO_VALUE,
""
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index da6c89d1a..3b0cf1db5 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -725,3 +725,22 @@ void TabbedArea::death(const gcn::Event &event)
else
gcn::BasicContainer::death(event);
}
+
+void TabbedArea::selectNextTab()
+{
+ int tab = getSelectedTabIndex();
+ tab++;
+ if (tab == static_cast<int>(mTabs.size()))
+ tab = 0;
+ setSelectedTab(mTabs[tab].first);
+}
+
+void TabbedArea::selectPrevTab()
+{
+ int tab = getSelectedTabIndex();
+
+ if (tab == 0)
+ tab = static_cast<int>(mTabs.size());
+ tab--;
+ setSelectedTab(mTabs[tab].first);
+}
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index eaac7a6d5..d0f97b688 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -189,6 +189,10 @@ class TabbedArea final : public Widget2,
void adjustWidget(gcn::Widget *const widget) const;
+ void selectNextTab();
+
+ void selectPrevTab();
+
private:
typedef std::vector <std::pair<Tab*, gcn::Widget*> > TabContainer;
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 1d9fa88c2..5cf2ad7df 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -234,6 +234,18 @@ void ShortcutWindow::widgetMoved(const gcn::Event& event)
(*it)->setRedraw(true);
}
+void ShortcutWindow::nextTab()
+{
+ if (mTabs)
+ mTabs->selectNextTab();
+}
+
+void ShortcutWindow::prevTab()
+{
+ if (mTabs)
+ mTabs->selectPrevTab();
+}
+
#ifdef USE_PROFILER
void ShortcutWindow::logicChildren()
{
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
index b7d7f70a1..f4c417c94 100644
--- a/src/gui/windows/shortcutwindow.h
+++ b/src/gui/windows/shortcutwindow.h
@@ -68,6 +68,10 @@ class ShortcutWindow final : public Window
void mouseDragged(gcn::MouseEvent &event) override final;
+ void nextTab();
+
+ void prevTab();
+
#ifdef USE_PROFILER
void logicChildren();
#endif
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 1c6b85153..8b1d0d79c 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -1819,30 +1819,14 @@ void SocialWindow::removePortal(const int x, const int y)
void SocialWindow::nextTab()
{
- if (!mTabs)
- return;
-
- int tab = mTabs->getSelectedTabIndex();
-
- tab++;
- if (tab == mTabs->getNumberOfTabs())
- tab = 0;
-
- mTabs->setSelectedTabByIndex(tab);
+ if (mTabs)
+ mTabs->selectNextTab();
}
void SocialWindow::prevTab()
{
- if (!mTabs)
- return;
-
- int tab = mTabs->getSelectedTabIndex();
-
- if (tab == 0)
- tab = mTabs->getNumberOfTabs();
- tab--;
-
- mTabs->setSelectedTabByIndex(tab);
+ if (mTabs)
+ mTabs->selectPrevTab();
}
void SocialWindow::updateAttackFilter()
diff --git a/src/input/keyboarddata.h b/src/input/keyboarddata.h
index c250b759e..a8817bc6e 100644
--- a/src/input/keyboarddata.h
+++ b/src/input/keyboarddata.h
@@ -2051,7 +2051,21 @@ static const KeyData keyData[Input::KEY_TOTAL] = {
Input::GRP_GUICHAN,
nullptr,
Input::KEY_NO_VALUE, 50,
- COND_DEFAULT}
+ COND_DEFAULT},
+ {"keyShortcutsPrevTab",
+ INPUT_UNKNOWN, Input::KEY_NO_VALUE,
+ INPUT_UNKNOWN, Input::KEY_NO_VALUE,
+ Input::GRP_DEFAULT | Input::GRP_GUI,
+ &ActionManager::prevShortcutsTab,
+ Input::KEY_NO_VALUE, 50,
+ COND_NOINPUT | COND_INGAME},
+ {"keyShortcutsNextTab",
+ INPUT_UNKNOWN, Input::KEY_NO_VALUE,
+ INPUT_UNKNOWN, Input::KEY_NO_VALUE,
+ Input::GRP_DEFAULT | Input::GRP_GUI,
+ &ActionManager::nextShortcutsTab,
+ Input::KEY_NO_VALUE, 50,
+ COND_NOINPUT | COND_INGAME},
};
#endif // INPUT_KEYBOARDDATA_H
diff --git a/src/input/keydata.h b/src/input/keydata.h
index a0fb8341b..d0cbb8d3a 100644
--- a/src/input/keydata.h
+++ b/src/input/keydata.h
@@ -353,6 +353,8 @@ namespace Input
KEY_GUI_U,
KEY_GUI_V,
KEY_GUI_W,
+ KEY_PREV_SHORTCUTS_TAB,
+ KEY_NEXT_SHORTCUTS_TAB,
KEY_TOTAL
};
} // namespace Input