diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-07 17:06:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-07 17:06:23 +0300 |
commit | a225638721d2bba53c15379d48ddab04d7568e24 (patch) | |
tree | 1c357290f2525a247a40fb5a887fddfe0728768d | |
parent | d2b06398ce43e1ad46078571b41d05df7c1d344b (diff) | |
download | manaplus-a225638721d2bba53c15379d48ddab04d7568e24.tar.gz manaplus-a225638721d2bba53c15379d48ddab04d7568e24.tar.bz2 manaplus-a225638721d2bba53c15379d48ddab04d7568e24.tar.xz manaplus-a225638721d2bba53c15379d48ddab04d7568e24.zip |
Remove unused events flags.
-rw-r--r-- | src/events/inputguievent.h | 69 | ||||
-rw-r--r-- | src/events/keyevent.h | 34 | ||||
-rw-r--r-- | src/events/mouseevent.h | 14 | ||||
-rw-r--r-- | src/gui/gui.cpp | 27 | ||||
-rw-r--r-- | src/gui/gui.h | 10 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 12 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 4 | ||||
-rw-r--r-- | src/input/keyinput.h | 87 |
8 files changed, 13 insertions, 244 deletions
diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h index 2e5136ea2..dbd2593d7 100644 --- a/src/events/inputguievent.h +++ b/src/events/inputguievent.h @@ -79,61 +79,14 @@ class InputGuiEvent: public Event * Constructor. * * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. * @param isMetaPressed True if meta is pressed, false otherwise. */ - InputGuiEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed) : + InputGuiEvent(Widget *const source) : Event(source), - mShiftPressed(shiftPressed), - mControlPressed(controlPressed), - mAltPressed(altPressed), - mMetaPressed(metaPressed), mIsConsumed(false) { } /** - * Checks if shift is pressed. - * - * @return True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool isShiftPressed() const A_WARN_UNUSED - { return mShiftPressed; } - - /** - * Checks if control is pressed. - * - * @return True if control was pressed at the same time as the key, - * false otherwise. - */ - bool isControlPressed() const A_WARN_UNUSED - { return mControlPressed; } - - /** - * Checks if alt is pressed. - * - * @return True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool isAltPressed() const A_WARN_UNUSED - { return mAltPressed; } - - /** - * Checks whether meta is pressed. - * - * @return True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool isMetaPressed() const A_WARN_UNUSED - { return mMetaPressed; } - - /** * Marks the event as consumed. Input event listeners may discard * consumed input or act on consumed input. An example of a widget * that discards consumed input is the ScrollArea widget that @@ -158,26 +111,6 @@ class InputGuiEvent: public Event protected: /** - * True if shift is pressed, false otherwise. - */ - bool mShiftPressed; - - /** - * True if control is pressed, false otherwise. - */ - bool mControlPressed; - - /** - * True if alt is pressed, false otherwise. - */ - bool mAltPressed; - - /** - * True if meta is pressed, false otherwise. - */ - bool mMetaPressed; - - /** * True if the input event is consumed, * false otherwise. */ diff --git a/src/events/keyevent.h b/src/events/keyevent.h index 360d229d7..16bc707c1 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -90,36 +90,21 @@ class KeyEvent: public InputGuiEvent * Constructor. * * @param source The source widget of the event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the event. A value from KeyEventType. - * @param numericPad True if the event occured on the numeric pad, * false otherwise. * @param key The key of the event. */ KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, const unsigned int type, - const bool numericPad, const int actionId, const Key &key) : - InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), + InputGuiEvent(source), mKey(key), #ifdef USE_SDL2 mText(), #endif mType(type), - mActionId(actionId), - mIsNumericPad(numericPad) + mActionId(actionId) { } /** @@ -137,16 +122,6 @@ class KeyEvent: public InputGuiEvent { return mType; } /** - * Checks if the key event occured on the numeric pad. - * - * @return True if key event occured on the numeric pad, - * false otherwise. - * - */ - bool isNumericPad() const A_WARN_UNUSED - { return mIsNumericPad; } - - /** * Gets the key of the event. * * @return The key of the event. @@ -181,11 +156,6 @@ class KeyEvent: public InputGuiEvent unsigned int mType; int mActionId; - - /** - * True if the numeric pad was used, false otherwise. - */ - bool mIsNumericPad; }; #endif // EVENTS_KEYEVENT_H diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 8ef65cca4..06b51e82a 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -86,10 +86,6 @@ class MouseEvent: public InputGuiEvent * Constructor. * * @param source The source widget of the mouse event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the mouse event. * @param button The button of the mouse event. * @param x The x coordinate of the event relative to the source widget. @@ -98,20 +94,12 @@ class MouseEvent: public InputGuiEvent * It's set to zero if another button is used. */ MouseEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, const unsigned int type, const unsigned int button, const int x, const int y, const int clickCount) : - InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), + InputGuiEvent(source), mType(type), mButton(button), mX(x), diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0b0290be4..d5fbd6e86 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -87,6 +87,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" +#include "input/inputmanager.h" #include "input/keydata.h" #include "input/keyinput.h" #include "input/mouseinput.h" @@ -141,10 +142,6 @@ Gui::Gui() : mInput(nullptr), mFocusHandler(new FocusHandler), mKeyListeners(), - mShiftPressed(false), - mMetaPressed(false), - mControlPressed(false), - mAltPressed(false), mLastMousePressButton(0), mLastMousePressTimeStamp(0), mLastMouseX(0), @@ -428,15 +425,8 @@ bool Gui::handleKeyInput() { const KeyInput keyInput = guiInput->dequeueKeyInput(); - // Save modifiers state - mShiftPressed = keyInput.isShiftPressed(); - mMetaPressed = keyInput.isMetaPressed(); - mControlPressed = keyInput.isControlPressed(); - mAltPressed = keyInput.isAltPressed(); - KeyEvent keyEventToGlobalKeyListeners(nullptr, - mShiftPressed, mControlPressed, mAltPressed, mMetaPressed, - keyInput.getType(), keyInput.isNumericPad(), + keyInput.getType(), keyInput.getActionId(), keyInput.getKey()); #ifdef USE_SDL2 @@ -463,8 +453,7 @@ bool Gui::handleKeyInput() if (mFocusHandler->getFocused()) { KeyEvent keyEvent(getKeyEventSource(), - mShiftPressed, mControlPressed, mAltPressed, mMetaPressed, - keyInput.getType(), keyInput.isNumericPad(), + keyInput.getType(), keyInput.getActionId(), keyInput.getKey()); #ifdef USE_SDL2 if (!keyInput.getText().empty()) @@ -488,7 +477,7 @@ bool Gui::handleKeyInput() == static_cast<int>(Input::KEY_GUI_TAB) && keyInput.getType() == KeyInput::PRESSED) { - if (keyInput.isShiftPressed()) + if (inputManager.isActionActive(Input::KEY_GUI_MOD)) mFocusHandler->tabPrevious(); else mFocusHandler->tabNext(); @@ -852,8 +841,8 @@ void Gui::distributeMouseEvent(Widget* source, int type, int button, return; } - MouseEvent mouseEvent(source, mShiftPressed, mControlPressed, - mAltPressed, mMetaPressed, type, button, + MouseEvent mouseEvent(source, + type, button, x, y, mClickCount); Widget* parent = source; @@ -965,8 +954,8 @@ MouseEvent *Gui::createMouseEvent(Window *const widget) getAbsolutePosition(widget, x, y); getMouseState(&mouseX, &mouseY); - return new MouseEvent(widget, mShiftPressed, - mControlPressed, mAltPressed, mMetaPressed, 0, 0, + return new MouseEvent(widget, + 0, 0, mouseX - x, mouseY - y, mClickCount); } diff --git a/src/gui/gui.h b/src/gui/gui.h index 85388b8c4..fdd9eaaec 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -446,16 +446,6 @@ class Gui final KeyListenerList mKeyListeners; /** - * True if shift is pressed, false otherwise. - */ - bool mShiftPressed; - - /** - * True if meta is pressed, false otherwise. - */ - bool mMetaPressed; - - /** * True if control is pressed, false otherwise. */ bool mControlPressed; diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index b0ac7d613..c1e02e9b2 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -303,18 +303,6 @@ void SDLInput::pushInput(const SDL_Event &event) void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput) { keyInput.setKey(Key(convertKeyCharacter(event))); - keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT); - keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL); - keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT); - keyInput.setMetaPressed(event.key.keysym.mod & KMOD_META); -#ifdef USE_SDL2 - const int code = event.key.keysym.scancode; - keyInput.setNumericPad((code >= SDL_SCANCODE_KP_DIVIDE - && code <= SDL_SCANCODE_KP_PERIOD) || code == SDL_SCANCODE_KP_EQUALS); -#else - const int code = event.key.keysym.sym; - keyInput.setNumericPad(code >= SDLK_KP0 && code <= SDLK_KP_EQUALS); -#endif const int actionId = inputManager.getActionByKey(event); if (actionId >= 0) keyInput.setActionId(actionId); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 96760f8c7..7ae209b92 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -281,10 +281,6 @@ void Viewport::_followMouse() { // We create a mouse event and send it to mouseDragged. MouseEvent mouseEvent(nullptr, - 0, - false, - false, - false, MouseEvent::DRAGGED, MouseEvent::LEFT, mMouseX, diff --git a/src/input/keyinput.h b/src/input/keyinput.h index 9920cfa17..b7b7a7936 100644 --- a/src/input/keyinput.h +++ b/src/input/keyinput.h @@ -79,12 +79,7 @@ class KeyInput final #ifdef USE_SDL2 mText(), #endif - mActionId(-2), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) + mActionId(-2) { } ~KeyInput() @@ -120,56 +115,6 @@ class KeyInput final return mKey; } - bool isShiftPressed() const - { - return mShiftPressed; - } - - void setShiftPressed(bool pressed) - { - mShiftPressed = pressed; - } - - bool isControlPressed() const - { - return mControlPressed; - } - - void setControlPressed(bool pressed) - { - mControlPressed = pressed; - } - - bool isAltPressed() const - { - return mAltPressed; - } - - void setAltPressed(bool pressed) - { - mAltPressed = pressed; - } - - bool isMetaPressed() const - { - return mMetaPressed; - } - - void setMetaPressed(bool pressed) - { - mMetaPressed = pressed; - } - - bool isNumericPad() const - { - return mNumericPad; - } - - void setNumericPad(bool numpad) - { - mNumericPad = numpad; - } - void setActionId(const int n) { mActionId = n; @@ -208,36 +153,6 @@ class KeyInput final #endif int mActionId; - - /** - * True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool mShiftPressed; - - /** - * True if control was pressed at the same time as the key, - * false otherwise. - */ - bool mControlPressed; - - /** - * True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool mAltPressed; - - /** - * True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool mMetaPressed; - - /** - * True if the numeric pad was used when the key was pressed, - * false otherwise. - */ - bool mNumericPad; }; #endif // INPUT_KEYINPUT_H |