diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-18 15:36:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-18 15:36:51 +0300 |
commit | 3d7cb45edeb4f75bad321d54d84fe2d13b487db9 (patch) | |
tree | 074f167b531f47c9df0e7ca68e8d2bbceee8284b /src | |
parent | 3042755e9a5ad302f4b5d6f5ed8a06a32fa3f32b (diff) | |
download | manaverse-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.gz manaverse-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.bz2 manaverse-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.xz manaverse-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.zip |
Move mouseeventtype into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/events/mouseevent.h | 24 | ||||
-rw-r--r-- | src/events/mouseeventtype.h | 87 | ||||
-rw-r--r-- | src/gui/gui.cpp | 56 | ||||
-rw-r--r-- | src/gui/gui.h | 4 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 2 |
7 files changed, 127 insertions, 48 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b956b482..7b5dc4ef3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -913,6 +913,7 @@ SET(SRCS gui/models/listmodel.h gui/models/magicschoolmodel.h events/mouseevent.h + events/mouseeventtype.h listeners/mouselistener.h listeners/openurllistener.h listeners/playerlistener.cpp diff --git a/src/Makefile.am b/src/Makefile.am index d55d674f3..6576b171d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -180,6 +180,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/models/listmodel.h \ gui/models/magicschoolmodel.h \ events/mouseevent.h \ + events/mouseeventtype.h \ listeners/mouselistener.h \ listeners/openurllistener.h \ listeners/playerlistener.cpp \ diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 351684645..213582f47 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -66,6 +66,8 @@ #include "events/inputguievent.h" +#include "events/mouseeventtype.h" + class Widget; /** @@ -89,7 +91,7 @@ class MouseEvent: public InputGuiEvent * It's set to zero if another button is used. */ MouseEvent(Widget *const source, - const unsigned int type, + MouseEventType::Type type, const unsigned int button, const int x, const int y, @@ -147,7 +149,7 @@ class MouseEvent: public InputGuiEvent * * @return The type of the event. */ - unsigned int getType() const A_WARN_UNUSED + MouseEventType::Type getType() const A_WARN_UNUSED { return mType; } void setX(int n) @@ -157,22 +159,6 @@ class MouseEvent: public InputGuiEvent { mY = n; } /** - * Mouse event types. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP, - CLICKED, - ENTERED, - EXITED, - DRAGGED - }; - - /** * Mouse button types. */ enum @@ -187,7 +173,7 @@ class MouseEvent: public InputGuiEvent /** * Holds the type of the mouse event. */ - unsigned int mType; + MouseEventType::Type mType; /** * Holds the button of the mouse event. diff --git a/src/events/mouseeventtype.h b/src/events/mouseeventtype.h new file mode 100644 index 000000000..b16c80c49 --- /dev/null +++ b/src/events/mouseeventtype.h @@ -0,0 +1,87 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Guichan nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EVENTS_MOUSEEVENTTYPE_H +#define EVENTS_MOUSEEVENTTYPE_H + +namespace MouseEventType +{ + /** + * Mouse event types. + */ + enum Type + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP, + CLICKED, + ENTERED, + EXITED, + DRAGGED, + RELEASED2 = 100 + }; +} // namespace + +#endif // EVENTS_MOUSEEVENTTYPE_H diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index cb74090d2..c14f6d924 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -564,7 +564,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) if (Widget::widgetExists(widget)) { distributeMouseEvent(widget, - MouseEvent::EXITED, + MouseEventType::EXITED, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY(), @@ -616,7 +616,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) || !widget->isVisible()) { distributeMouseEvent(widget, - MouseEvent::EXITED, + MouseEventType::EXITED, button, mouseX, mouseY, @@ -686,7 +686,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) && Widget::widgetExists(widget)) { distributeMouseEvent(widget, - MouseEvent::ENTERED, + MouseEventType::ENTERED, button, mouseX, mouseY, @@ -703,7 +703,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) if (mFocusHandler->getDraggedWidget()) { distributeMouseEvent(mFocusHandler->getDraggedWidget(), - MouseEvent::DRAGGED, + MouseEventType::DRAGGED, mLastMouseDragButton, mouseX, mouseY); @@ -712,7 +712,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) { Widget *const sourceWidget = getMouseEventSource(mouseX, mouseY); distributeMouseEvent(sourceWidget, - MouseEvent::MOVED, + MouseEventType::MOVED, button, mouseX, mouseY); @@ -753,7 +753,7 @@ void Gui::handleMousePressed(const MouseInput &mouseInput) mClickCount = 1; } - distributeMouseEvent(sourceWidget, MouseEvent::PRESSED, button, x, y); + distributeMouseEvent(sourceWidget, MouseEventType::PRESSED, button, x, y); mFocusHandler->setLastWidgetPressed(sourceWidget); mFocusHandler->setDraggedWidget(sourceWidget); mLastMouseDragButton = button; @@ -792,7 +792,7 @@ void Gui::updateFonts() } void Gui::distributeMouseEvent(Widget *const source, - const int type, + const MouseEventType::Type type, const int button, const int x, const int y, const bool force, @@ -850,32 +850,32 @@ void Gui::distributeMouseEvent(Widget *const source, { switch (mouseType) { - case MouseEvent::ENTERED: + case MouseEventType::ENTERED: (*it)->mouseEntered(event); break; - case MouseEvent::EXITED: + case MouseEventType::EXITED: (*it)->mouseExited(event); break; - case MouseEvent::MOVED: + case MouseEventType::MOVED: (*it)->mouseMoved(event); break; - case MouseEvent::PRESSED: + case MouseEventType::PRESSED: (*it)->mousePressed(event); break; - case MouseEvent::RELEASED: - case 100: // manual hack for release on target after drag + case MouseEventType::RELEASED: + case MouseEventType::RELEASED2: (*it)->mouseReleased(event); break; - case MouseEvent::WHEEL_MOVED_UP: + case MouseEventType::WHEEL_MOVED_UP: (*it)->mouseWheelMovedUp(event); break; - case MouseEvent::WHEEL_MOVED_DOWN: + case MouseEventType::WHEEL_MOVED_DOWN: (*it)->mouseWheelMovedDown(event); break; - case MouseEvent::DRAGGED: + case MouseEventType::DRAGGED: (*it)->mouseDragged(event); break; - case MouseEvent::CLICKED: + case MouseEventType::CLICKED: (*it)->mouseClicked(event); break; default: @@ -891,7 +891,7 @@ void Gui::distributeMouseEvent(Widget *const source, widget = parent; parent = swap->getParent(); - if (type == MouseEvent::RELEASED) + if (type == MouseEventType::RELEASED) dragDrop.clear(); if (event.isConsumed()) @@ -935,8 +935,10 @@ MouseEvent *Gui::createMouseEvent(Window *const widget) getMouseState(&mouseX, &mouseY); return new MouseEvent(widget, - 0, 0, - mouseX - x, mouseY - y, + MouseEventType::MOVED, + 0, + mouseX - x, + mouseY - y, mClickCount); } @@ -1022,7 +1024,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput) { oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); distributeMouseEvent(oldWidget, - 100, + MouseEventType::RELEASED2, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY()); @@ -1031,7 +1033,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput) sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); distributeMouseEvent(sourceWidget, - MouseEvent::RELEASED, + MouseEventType::RELEASED, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY()); @@ -1040,7 +1042,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput) && mFocusHandler->getLastWidgetPressed() == sourceWidget) { distributeMouseEvent(sourceWidget, - MouseEvent::CLICKED, + MouseEventType::CLICKED, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY()); @@ -1148,7 +1150,7 @@ void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput) sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); distributeMouseEvent(sourceWidget, - MouseEvent::WHEEL_MOVED_DOWN, + MouseEventType::WHEEL_MOVED_DOWN, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY()); @@ -1166,7 +1168,7 @@ void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput) sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); distributeMouseEvent(sourceWidget, - MouseEvent::WHEEL_MOVED_UP, + MouseEventType::WHEEL_MOVED_UP, mouseInput.getButton(), mouseInput.getX(), mouseInput.getY()); @@ -1359,7 +1361,7 @@ void Gui::handleModalFocusGained() if (Widget::widgetExists(widget)) { distributeMouseEvent(widget, - MouseEvent::EXITED, + MouseEventType::EXITED, mLastMousePressButton, mLastMouseX, mLastMouseY, @@ -1404,7 +1406,7 @@ void Gui::handleModalFocusReleased() if (!widgetIsPresentInQueue && Widget::widgetExists(widget)) { distributeMouseEvent(widget, - MouseEvent::ENTERED, + MouseEventType::ENTERED, mLastMousePressButton, mLastMouseX, mLastMouseY, diff --git a/src/gui/gui.h b/src/gui/gui.h index 97604ad3a..6027625cb 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -68,6 +68,8 @@ #include "gui/color.h" +#include "events/mouseeventtype.h" + #include "resources/cursor.h" #include <deque> @@ -325,7 +327,7 @@ class Gui final void handleMouseInput(); void distributeMouseEvent(Widget *const source, - const int type, + const MouseEventType::Type type, const int button, const int x, const int y, const bool force = false, diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index a33104084..6b6850812 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -289,7 +289,7 @@ void Viewport::followMouse() { // We create a mouse event and send it to mouseDragged. MouseEvent event(nullptr, - MouseEvent::DRAGGED, + MouseEventType::DRAGGED, MouseEvent::LEFT, mMouseX, mMouseY, |