diff options
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/Event.h | 97 | ||||
-rw-r--r-- | src/crepe/api/KeyCodes.h | 6 | ||||
-rw-r--r-- | src/crepe/api/Transform.h | 8 |
3 files changed, 76 insertions, 35 deletions
diff --git a/src/crepe/api/Event.h b/src/crepe/api/Event.h index f2f3daf..265e925 100644 --- a/src/crepe/api/Event.h +++ b/src/crepe/api/Event.h @@ -4,7 +4,7 @@ #include <string> #include "KeyCodes.h" - +#include "types.h" namespace crepe { /** @@ -38,11 +38,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 + ivec2 mouse_pos = {0,0}; //! The mouse button that was pressed. MouseButton button = MouseButton::NONE; @@ -53,11 +50,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 + ivec2 mouse_pos = {0,0}; //! The mouse button that was clicked. MouseButton button = MouseButton::NONE; @@ -68,11 +62,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 + ivec2 mouse_pos = {0,0}; //! The mouse button that was released. MouseButton button = MouseButton::NONE; @@ -83,17 +74,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; + //! new mouse position + ivec2 mouse_pos = {0,0}; + //! The change in mouse position relative to the last position (in pixels). + ivec2 mouse_delta = {0,0}; }; /** @@ -101,12 +85,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 when the scroll happened. + ivec2 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 +107,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 diff --git a/src/crepe/api/KeyCodes.h b/src/crepe/api/KeyCodes.h index fcfc080..f704fbb 100644 --- a/src/crepe/api/KeyCodes.h +++ b/src/crepe/api/KeyCodes.h @@ -13,7 +13,7 @@ enum class MouseButton { }; //! Enumeration for keyboard key inputs, including printable characters, function keys, and keypad keys. -enum class Keycode { +typedef enum { NONE = 0, //!< No key input. SPACE = 32, //!< Spacebar. APOSTROPHE = 39, //!< Apostrophe ('). @@ -150,5 +150,7 @@ enum class Keycode { RIGHT_SUPER = 347, /// \} MENU = 348, //!< Menu key. -}; + //! Not actually a key instead its the amount of keycodes there are for array indexing + NUM_KEYCODES = 512, +} Keycode; } // namespace crepe diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h index 7ee6d65..78407ee 100644 --- a/src/crepe/api/Transform.h +++ b/src/crepe/api/Transform.h @@ -13,6 +13,14 @@ namespace crepe { */ class Transform : public Component { public: + //! Specifies the coordinate space for transformations. + enum Space { + //! coordinates are relative to the active camera + HUD, + //! coordinates are relative to the game world + WORLD, + }; + Space coordinate_space = Space::WORLD; //! Translation (shift) vec2 position = {0, 0}; //! Rotation, in degrees clockwise |