aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Event.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 14:50:08 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 14:50:08 +0100
commitc3c565f7c8d1e7e9899b8c2fbb1c313a45e4b10b (patch)
tree33b937a5c0cd3413078ac6fd9ccc82ee60763acd /src/crepe/api/Event.h
parent4080a2eec207b35b36f7d0ceae7c2afcfcdfd977 (diff)
parent9232a98b72eee7af4f7f2153c1b2ccedbfa4cc65 (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/text-component
Diffstat (limited to 'src/crepe/api/Event.h')
-rw-r--r--src/crepe/api/Event.h98
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