diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-17 09:25:11 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-17 09:25:11 +0100 |
commit | 093493d1ecc082672d80707c31bd95a5175ab2ce (patch) | |
tree | 7a692e5bafff5bfda971ce3e9c91ba48bbd7b5dc /src/crepe/api/Event.h | |
parent | cc2ec343367ebaa3b6a6142532f7a067c3c981a1 (diff) | |
parent | 3c99c73f3c1c31ba97f7e8c74f434c880f8a9036 (diff) |
Merge branch 'wouter/inputSystem' into wouter/button-improvement
Diffstat (limited to 'src/crepe/api/Event.h')
-rw-r--r-- | src/crepe/api/Event.h | 98 |
1 files changed, 65 insertions, 33 deletions
diff --git a/src/crepe/api/Event.h b/src/crepe/api/Event.h index f2f3daf..73bf461 100644 --- a/src/crepe/api/Event.h +++ b/src/crepe/api/Event.h @@ -3,7 +3,8 @@ #include <string> -#include "KeyCodes.h" +#include "api/KeyCodes.h" +#include "types.h" namespace crepe { @@ -38,11 +39,8 @@ public: */ class MousePressEvent : public Event { public: - //! X-coordinate of the mouse position at the time of the event. - int mouse_x = 0; - - //! Y-coordinate of the mouse position at the time of the event. - int mouse_y = 0; + //! mouse position in world coordinates (game units). + vec2 mouse_pos = {0, 0}; //! The mouse button that was pressed. MouseButton button = MouseButton::NONE; @@ -53,11 +51,8 @@ public: */ class MouseClickEvent : public Event { public: - //! X-coordinate of the mouse position at the time of the event. - int mouse_x = 0; - - //! Y-coordinate of the mouse position at the time of the event. - int mouse_y = 0; + //! mouse position in world coordinates (game units). + vec2 mouse_pos = {0, 0}; //! The mouse button that was clicked. MouseButton button = MouseButton::NONE; @@ -68,11 +63,8 @@ public: */ class MouseReleaseEvent : public Event { public: - //! X-coordinate of the mouse position at the time of the event. - int mouse_x = 0; - - //! Y-coordinate of the mouse position at the time of the event. - int mouse_y = 0; + //! mouse position in world coordinates (game units). + vec2 mouse_pos = {0, 0}; //! The mouse button that was released. MouseButton button = MouseButton::NONE; @@ -83,17 +75,10 @@ public: */ class MouseMoveEvent : public Event { public: - //! X-coordinate of the mouse position at the time of the event. - int mouse_x = 0; - - //! Y-coordinate of the mouse position at the time of the event. - int mouse_y = 0; - - // Movement since last event in x - int delta_x = 0; - - // Movement since last event in y - int delta_y = 0; + //! mouse position in world coordinates (game units). + vec2 mouse_pos = {0, 0}; + //! The change in mouse position relative to the last position (in pixels). + ivec2 mouse_delta = {0, 0}; }; /** @@ -101,12 +86,8 @@ public: */ class MouseScrollEvent : public Event { public: - //! X-coordinate of the mouse position at the time of the event. - int mouse_x = 0; - - //! Y-coordinate of the mouse position at the time of the event. - int mouse_y = 0; - + //! mouse position in world coordinates (game units) when the scroll happened. + vec2 mouse_pos = {0, 0}; //! scroll direction (-1 = down, 1 = up) int scroll_direction = 0; //! scroll amount in y axis (from and away from the person). @@ -127,4 +108,55 @@ public: */ class ShutDownEvent : public Event {}; +/** + * \brief Event triggered to indicate the window is overlapped by another window. + * + * When two windows overlap the bottom window gets distorted and that window has to be redrawn. + */ +class WindowExposeEvent : public Event {}; + +/** + * \brief Event triggered to indicate the window is resized. + */ +class WindowResizeEvent : public Event { +public: + //! new window dimensions + ivec2 dimensions = {0, 0}; +}; + +/** + * \brief Event triggered to indicate the window is moved. + */ +class WindowMoveEvent : public Event { +public: + //! The change in position relative to the last position (in pixels). + ivec2 delta_move = {0, 0}; +}; + +/** + * \brief Event triggered to indicate the window is minimized. + */ +class WindowMinimizeEvent : public Event {}; + +/** + * \brief Event triggered to indicate the window is maximized + */ +class WindowMaximizeEvent : public Event {}; + +/** + * \brief Event triggered to indicate the window gained focus + * + * This event is triggered when the window receives focus, meaning it becomes the active window + * for user interaction. + */ +class WindowFocusGainEvent : public Event {}; + +/** + * \brief Event triggered to indicate the window lost focus + * + * This event is triggered when the window loses focus, meaning it is no longer the active window + * for user interaction. + */ +class WindowFocusLostEvent : public Event {}; + } // namespace crepe |