summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-18 15:36:51 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-18 15:36:51 +0300
commit3d7cb45edeb4f75bad321d54d84fe2d13b487db9 (patch)
tree074f167b531f47c9df0e7ca68e8d2bbceee8284b /src/gui
parent3042755e9a5ad302f4b5d6f5ed8a06a32fa3f32b (diff)
downloadplus-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.gz
plus-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.bz2
plus-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.tar.xz
plus-3d7cb45edeb4f75bad321d54d84fe2d13b487db9.zip
Move mouseeventtype into separate file.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp56
-rw-r--r--src/gui/gui.h4
-rw-r--r--src/gui/viewport.cpp2
3 files changed, 33 insertions, 29 deletions
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,