summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-31 00:19:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-31 00:19:18 +0300
commit694e07d193e7c5758a7d672b45668651b034003d (patch)
tree20a4aec8dee2b3b5475db9f3667e797fb43c603b /src/gui/widgets
parentc9a84749b3b71d4df6cc3b9b488d60dc4a013a20 (diff)
downloadplus-694e07d193e7c5758a7d672b45668651b034003d.tar.gz
plus-694e07d193e7c5758a7d672b45668651b034003d.tar.bz2
plus-694e07d193e7c5758a7d672b45668651b034003d.tar.xz
plus-694e07d193e7c5758a7d672b45668651b034003d.zip
Convert InputAction enum into strong typed enum.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/button.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/guitable.cpp2
-rw-r--r--src/gui/widgets/inttextfield.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp2
-rw-r--r--src/gui/widgets/radiobutton.cpp2
-rw-r--r--src/gui/widgets/setuptouchitem.cpp8
-rw-r--r--src/gui/widgets/slider.cpp2
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp46
-rw-r--r--src/gui/widgets/tabs/setup_input.h12
-rw-r--r--src/gui/widgets/textbox.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp9
-rw-r--r--src/gui/widgets/textfield.h4
17 files changed, 55 insertions, 50 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 9a6d43518..73a289630 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -843,7 +843,7 @@ void Button::adjustSize()
void Button::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
@@ -854,7 +854,7 @@ void Button::keyPressed(KeyEvent& event)
void Button::keyReleased(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT && mKeyPressed)
{
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 6459c5f1c..20a58bdf1 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -267,7 +267,7 @@ void CheckBox::mouseExited(MouseEvent& event)
void CheckBox::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 0d08dac60..890a2af1f 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -334,7 +334,7 @@ void DropDown::keyPressed(KeyEvent& event)
if (event.isConsumed())
return;
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
switch (actionId)
{
case InputAction::GUI_SELECT:
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index eb6efedb6..7cba5872e 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -33,6 +33,8 @@
#include "gui/popups/textpopup.h"
+#include "input/inputactionoperators.h"
+
#include "resources/emotesprite.h"
#include "resources/image.h"
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index ba29033a9..d5242520f 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -474,7 +474,7 @@ Rect GuiTable::getChildrenArea()
// -- KeyListener notifications
void GuiTable::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index 1ba53b1af..b0e902223 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -53,7 +53,7 @@ IntTextField::IntTextField(const Widget2 *const widget,
void IntTextField::keyPressed(KeyEvent &event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_DELETE
|| action == InputAction::GUI_BACKSPACE)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 15af7c286..eba9fd848 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -42,6 +42,8 @@
#include "gui/windows/inventorywindow.h"
#include "gui/windows/skilldialog.h"
+#include "input/inputactionoperators.h"
+
#include "resources/skillconsts.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 5ab8945a9..8e0bd2921 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -237,7 +237,7 @@ void ListBox::draw(Graphics *graphics)
void ListBox::keyPressed(KeyEvent &event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
distributeActionEvent();
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 9fd9d81aa..a3c4d1797 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -266,7 +266,7 @@ void RadioButton::mouseExited(MouseEvent& event A_UNUSED)
void RadioButton::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (action == InputAction::GUI_SELECT)
{
setSelected(true);
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index 8d1b63dd7..eb8741abc 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -100,7 +100,7 @@ void SetupActionDropDown::createControls()
mDropDown->addActionListener(mParent);
mDropDown->setWidth(mWidth);
mDropDown->setSelected(mModel->getSelectionFromAction(
- atoi(mValue.c_str())));
+ static_cast<InputActionT>(atoi(mValue.c_str()))));
mWidget = mDropDown;
fixFirstItemSize(mLabel);
@@ -118,8 +118,8 @@ void SetupActionDropDown::fromWidget()
if (!mDropDown || !mModel)
return;
- mValue = toString(mModel->getActionFromSelection(
- mDropDown->getSelected()));
+ mValue = toString(static_cast<int>(mModel->getActionFromSelection(
+ mDropDown->getSelected())));
}
void SetupActionDropDown::toWidget()
@@ -128,5 +128,5 @@ void SetupActionDropDown::toWidget()
return;
mDropDown->setSelected(mModel->getSelectionFromAction(
- atoi(mValue.c_str())));
+ static_cast<InputActionT>(atoi(mValue.c_str()))));
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c11dc2627..4adc3003f 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -423,7 +423,7 @@ void Slider::mouseWheelMovedDown(MouseEvent &event)
void Slider::keyPressed(KeyEvent& event)
{
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
if (mOrientation == HORIZONTAL)
{
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 79205617f..4acc9ffd2 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -738,7 +738,7 @@ void TabbedArea::keyPressed(KeyEvent& event)
if (mBlockSwitching || event.isConsumed() || !isFocused())
return;
- const int actionId = event.getActionId();
+ const InputActionT actionId = event.getActionId();
if (actionId == InputAction::GUI_LEFT)
{
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index f1752d781..24a385c0f 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -27,6 +27,7 @@
#include "enums/gui/dialogtype.h"
+#include "input/inputactionoperators.h"
#include "input/inputmanager.h"
#include "input/keyboardconfig.h"
@@ -147,7 +148,7 @@ Setup_Input::~Setup_Input()
void Setup_Input::apply()
{
keyUnresolved();
- int key1, key2;
+ InputActionT key1, key2;
if (inputManager.hasConflicts(key1, key2))
{
@@ -193,7 +194,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
if (setupActionData[selectedData][i].actionId
- == static_cast<int>(InputAction::NO_VALUE))
+ == InputAction::NO_VALUE)
{
mAssignKeyButton->setEnabled(false);
mUnassignKeyButton->setEnabled(false);
@@ -215,7 +216,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.setNewKeyIndex(ik);
mKeyListModel->setElementAt(i, std::string(
gettext(key.name.c_str())).append(": ?"));
@@ -227,12 +228,11 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.setNewKeyIndex(ik);
refreshAssignedKey(mKeyList->getSelected());
inputManager.unassignKey();
- inputManager.setNewKeyIndex(static_cast<int>(
- InputAction::NO_VALUE));
+ inputManager.setNewKeyIndex(InputAction::NO_VALUE);
}
mAssignKeyButton->setEnabled(true);
}
@@ -248,7 +248,7 @@ void Setup_Input::action(const ActionEvent &event)
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- const int ik = key.actionId;
+ const InputActionT ik = key.actionId;
inputManager.makeDefault(ik);
refreshKeys();
}
@@ -277,7 +277,7 @@ void Setup_Input::refreshAssignedKey(const int index)
{
const int selectedData = mKeyListModel->getSelectedData();
const SetupActionData &key = setupActionData[selectedData][index];
- if (key.actionId == static_cast<int>(InputAction::NO_VALUE))
+ if (key.actionId == InputAction::NO_VALUE)
{
const std::string str(" \342\200\225\342\200\225\342\200\225"
"\342\200\225\342\200\225 ");
@@ -297,7 +297,7 @@ void Setup_Input::refreshAssignedKey(const int index)
}
}
-void Setup_Input::newKeyCallback(const int index)
+void Setup_Input::newKeyCallback(const InputActionT index)
{
mKeySetting = false;
const int i = keyToSetupData(index);
@@ -306,7 +306,7 @@ void Setup_Input::newKeyCallback(const int index)
mAssignKeyButton->setEnabled(true);
}
-int Setup_Input::keyToSetupData(const int index) const
+int Setup_Input::keyToSetupData(const InputActionT index) const
{
const int selectedData = mKeyListModel->getSelectedData();
for (int i = 0; i < mActionDataSize[selectedData]; i++)
@@ -318,7 +318,7 @@ int Setup_Input::keyToSetupData(const int index) const
return -1;
}
-std::string Setup_Input::keyToString(const int index) const
+std::string Setup_Input::keyToString(const InputActionT index) const
{
for (int f = 0; f < setupGroups; f ++)
{
@@ -345,13 +345,13 @@ void Setup_Input::keyUnresolved()
if (mKeySetting)
{
newKeyCallback(inputManager.getNewKeyIndex());
- inputManager.setNewKeyIndex(static_cast<int>(InputAction::NO_VALUE));
+ inputManager.setNewKeyIndex(InputAction::NO_VALUE);
}
}
void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
- const int actionStart,
- const int actionEnd,
+ const InputActionT actionStart,
+ const InputActionT actionEnd,
const std::string &text)
{
int k = 0;
@@ -360,7 +360,7 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
{
SetupActionData &data = actionDatas[k];
- const int actionId = data.actionId;
+ const InputActionT actionId = data.actionId;
if (actionId >= actionStart && actionId <= actionEnd)
{
data.name = strprintf(gettext(text.c_str()),
@@ -373,22 +373,22 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
void Setup_Input::fixTranslations()
{
fixTranslation(setupActionDataShortcuts,
- static_cast<int>(InputAction::SHORTCUT_1),
- static_cast<int>(InputAction::SHORTCUT_20),
+ InputAction::SHORTCUT_1,
+ InputAction::SHORTCUT_20,
"Item Shortcut %d");
fixTranslation(setupActionDataEmotes,
- static_cast<int>(InputAction::EMOTE_1),
- static_cast<int>(InputAction::EMOTE_48),
+ InputAction::EMOTE_1,
+ InputAction::EMOTE_48,
"Emote Shortcut %d");
fixTranslation(setupActionDataOutfits,
- static_cast<int>(InputAction::OUTFIT_1),
- static_cast<int>(InputAction::OUTFIT_48),
+ InputAction::OUTFIT_1,
+ InputAction::OUTFIT_48,
"Outfit Shortcut %d");
fixTranslation(setupActionDataMove,
- static_cast<int>(InputAction::MOVE_TO_POINT_1),
- static_cast<int>(InputAction::MOVE_TO_POINT_48),
+ InputAction::MOVE_TO_POINT_1,
+ InputAction::MOVE_TO_POINT_48,
"Move to point Shortcut %d");
}
diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h
index 569c21e2b..eb97dd644 100644
--- a/src/gui/widgets/tabs/setup_input.h
+++ b/src/gui/widgets/tabs/setup_input.h
@@ -24,6 +24,8 @@
#ifndef GUI_WIDGETS_TABS_SETUP_INPUT_H
#define GUI_WIDGETS_TABS_SETUP_INPUT_H
+#include "enums/input/inputaction.h"
+
#include "gui/widgets/tabs/setuptab.h"
class Button;
@@ -63,7 +65,7 @@ class Setup_Input final : public SetupTab
/**
* The callback function when a new key has been pressed.
*/
- void newKeyCallback(const int index);
+ void newKeyCallback(const InputActionT index);
/**
* Shorthand method to update all the keys.
@@ -75,16 +77,16 @@ class Setup_Input final : public SetupTab
*/
void keyUnresolved();
- int keyToSetupData(const int index) const A_WARN_UNUSED;
+ int keyToSetupData(const InputActionT index) const A_WARN_UNUSED;
- std::string keyToString(const int index) const A_WARN_UNUSED;
+ std::string keyToString(const InputActionT index) const A_WARN_UNUSED;
private:
static void fixTranslations();
static void fixTranslation(SetupActionData *const actionDatas,
- const int actionStart,
- const int actionEnd,
+ const InputActionT actionStart,
+ const InputActionT actionEnd,
const std::string &text);
KeyListModel *mKeyListModel;
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 0919656ad..248fbcb9e 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -257,7 +257,7 @@ void TextBox::setText(const std::string& text)
void TextBox::keyPressed(KeyEvent& event)
{
const Key &key = event.getKey();
- const int action = event.getActionId();
+ const InputActionT action = event.getActionId();
switch (action)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 8639d8f80..0d7b3d883 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -365,9 +365,8 @@ void TextField::keyPressed(KeyEvent &event)
bool consumed(false);
#endif
- const int action = event.getActionId();
- if (!inputManager.isActionActive(static_cast<int>(
- InputAction::GUI_CTRL)))
+ const InputActionT action = event.getActionId();
+ if (!inputManager.isActionActive(InputAction::GUI_CTRL))
{
if (!handleNormalKeys(action, consumed))
{
@@ -389,7 +388,7 @@ void TextField::keyPressed(KeyEvent &event)
fixScroll();
}
-bool TextField::handleNormalKeys(const int action, bool &consumed)
+bool TextField::handleNormalKeys(const InputActionT action, bool &consumed)
{
switch (action)
{
@@ -473,7 +472,7 @@ bool TextField::handleNormalKeys(const int action, bool &consumed)
return true;
}
-void TextField::handleCtrlKeys(const int action, bool &consumed)
+void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
{
switch (action)
{
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index ffd956ed2..79ad3f110 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -238,9 +238,9 @@ class TextField notfinal : public Widget,
void fontChanged() override;
- bool handleNormalKeys(const int action, bool &consumed);
+ bool handleNormalKeys(const InputActionT action, bool &consumed);
- void handleCtrlKeys(const int action, bool &consumed);
+ void handleCtrlKeys(const InputActionT action, bool &consumed);
static Skin *mSkin;