From 2e07a7af24cf8a2928ab6a3431ab5b01b29969bb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 30 May 2015 01:01:04 +0300 Subject: Convert MouseEventType enum into strong typed enum. --- src/enums/events/mouseeventtype.h | 33 +++++++++++++++------------------ src/events/mouseevent.h | 6 +++--- src/gui/gui.cpp | 4 ++-- src/gui/gui.h | 2 +- src/input/mouseinput.h | 6 +++--- 5 files changed, 24 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/enums/events/mouseeventtype.h b/src/enums/events/mouseeventtype.h index 7fa568960..f430953fa 100644 --- a/src/enums/events/mouseeventtype.h +++ b/src/enums/events/mouseeventtype.h @@ -64,24 +64,21 @@ #ifndef ENUMS_EVENTS_MOUSEEVENTTYPE_H #define ENUMS_EVENTS_MOUSEEVENTTYPE_H -namespace MouseEventType +#include "enums/simpletypes/enumdefines.h" + +enumStart(MouseEventType) { - /** - * Mouse event types. - */ - enum Type - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP, - CLICKED, - ENTERED, - EXITED, - DRAGGED, - RELEASED2 = 100 - }; -} // namespace MouseEventType + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP, + CLICKED, + ENTERED, + EXITED, + DRAGGED, + RELEASED2 = 100 +} +enumEnd(MouseEventType); #endif // ENUMS_EVENTS_MOUSEEVENTTYPE_H diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 1be008827..66215da15 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -92,7 +92,7 @@ class MouseEvent: public InputGuiEvent * It's set to zero if another button is used. */ MouseEvent(Widget *const source, - const MouseEventType::Type type, + const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, @@ -150,7 +150,7 @@ class MouseEvent: public InputGuiEvent * * @return The type of the event. */ - MouseEventType::Type getType() const A_WARN_UNUSED + MouseEventTypeT getType() const A_WARN_UNUSED { return mType; } void setX(int n) @@ -163,7 +163,7 @@ class MouseEvent: public InputGuiEvent /** * Holds the type of the mouse event. */ - MouseEventType::Type mType; + MouseEventTypeT mType; /** * Holds the button of the mouse event. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 23b640737..f00821c60 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -802,7 +802,7 @@ void Gui::updateFonts() } void Gui::distributeMouseEvent(Widget *const source, - const MouseEventType::Type type, + const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, const bool force, @@ -853,7 +853,7 @@ void Gui::distributeMouseEvent(Widget *const source, std::list mouseListeners = widget->getMouseListeners(); - const MouseEventType::Type mouseType = event.getType(); + const MouseEventTypeT mouseType = event.getType(); // Send the event to all mouse listeners of the widget. FOR_EACH (std::list::const_iterator, it, mouseListeners) diff --git a/src/gui/gui.h b/src/gui/gui.h index b1d443b81..8a2935208 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -328,7 +328,7 @@ class Gui final void handleMouseInput(); void distributeMouseEvent(Widget *const source, - const MouseEventType::Type type, + const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, const bool force = false, diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h index f84303308..dc5ad8a1a 100644 --- a/src/input/mouseinput.h +++ b/src/input/mouseinput.h @@ -85,12 +85,12 @@ class MouseInput final ~MouseInput() { } - void setType(MouseEventType::Type type) + void setType(MouseEventTypeT type) { mType = type; } - MouseEventType::Type getType() const + MouseEventTypeT getType() const { return mType; } @@ -162,7 +162,7 @@ class MouseInput final /** * Holds the type of the mouse input. */ - MouseEventType::Type mType; + MouseEventTypeT mType; /** * Holds the button of the mouse input. -- cgit v1.2.3-60-g2f50