Events
- group events
Defines
-
EVENT_CLASS_TYPE(type)
Macro to define the type of an event.
-
EVENT_CLASS_CATEGORY(category)
Macro to define the category of an event.
Enums
-
enum class EventType
Enum representing different types of events.
Values:
-
enumerator None
-
enumerator WindowClose
-
enumerator WindowResize
-
enumerator WindowFocus
-
enumerator WindowLostFocus
-
enumerator WindowMoved
-
enumerator FileDrop
-
enumerator AppTick
-
enumerator AppUpdate
-
enumerator AppRender
-
enumerator KeyPressed
-
enumerator KeyReleased
-
enumerator KeyTyped
-
enumerator MouseButtonPressed
-
enumerator MouseButtonReleased
-
enumerator MouseMoved
-
enumerator MouseScrolled
-
enumerator None
Functions
-
class WindowResizeEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for window resize.
Public Functions
-
inline unsigned int GetWidth() const
Get the width of the window.
- Returns:
The width of the window.
-
inline unsigned int GetHeight() const
Get the height of the window.
- Returns:
The height of the window.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline unsigned int GetWidth() const
-
class FileDropEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for Dropping a file.
Public Functions
-
inline uint64_t GetTimestamp() const
Get the timestamp of the event.
- Returns:
The timestamp of the event.
-
inline uint32_t GetWindowID() const
Get the window ID of the event.
- Returns:
The window ID of the event.
-
inline float GetX() const
Get the x position of the event.
- Returns:
The x position of the event.
-
inline float GetY() const
Get the y position of the event.
- Returns:
The y position of the event.
-
inline const std::string &GetSource() const
Get the source of the event.
- Returns:
The source of the event.
-
inline const std::string &GetFile() const
Get the file of the event.
- Returns:
The file of the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline uint64_t GetTimestamp() const
-
class AppUpdateEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for application update.
-
class AppRenderEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for application render.
-
class Event
- #include <Event.h>
Base class for all events.
Subclassed by Coffee::AppRenderEvent, Coffee::AppTickEvent, Coffee::AppUpdateEvent, Coffee::FileDropEvent, Coffee::KeyEvent, Coffee::MouseButtonEvent, Coffee::MouseMovedEvent, Coffee::MouseScrolledEvent, Coffee::WindowCloseEvent, Coffee::WindowResizeEvent
Public Functions
-
virtual EventType GetEventType() const = 0
Get the type of the event.
- Returns:
The event type.
-
virtual const char *GetName() const = 0
Get the name of the event.
- Returns:
The event name.
-
virtual int GetCategoryFlags() const = 0
Get the category flags of the event.
- Returns:
The category flags.
-
inline virtual std::string ToString() const
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline bool IsInCategory(EventCategory category)
Check if the event is in a specific category.
- Parameters:
category – The category to check.
- Returns:
True if the event is in the category, false otherwise.
-
virtual EventType GetEventType() const = 0
-
class EventDispatcher
- #include <Event.h>
Event dispatcher to handle events.
Public Functions
-
template<typename T, typename F>
inline bool Dispatch(const F &func) Dispatches the event if it matches the type.
- Template Parameters:
T – The event type.
F – The function type.
- Parameters:
func – The function to call if the event matches the type.
- Returns:
True if the event was dispatched, false otherwise.
-
template<typename T, typename F>
-
class KeyEvent : public Coffee::Event
- #include <KeyEvent.h>
Base class for key events.
Subclassed by Coffee::KeyPressedEvent, Coffee::KeyReleasedEvent, Coffee::KeyTypedEvent
Public Functions
-
inline KeyCode GetKeyCode() const
Get the key code associated with the event.
- Returns:
The key code.
-
inline KeyCode GetKeyCode() const
-
class KeyPressedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key press.
Public Functions
-
inline KeyPressedEvent(const KeyCode keycode, bool isRepeat = false)
Constructor for KeyPressedEvent.
- Parameters:
keycode – The key code associated with the event.
isRepeat – Whether the key press is a repeat.
-
inline bool IsRepeat() const
Check if the key press is a repeat.
- Returns:
True if the key press is a repeat, false otherwise.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyPressedEvent(const KeyCode keycode, bool isRepeat = false)
-
class KeyReleasedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key release.
Public Functions
-
inline KeyReleasedEvent(const KeyCode keycode)
Constructor for KeyReleasedEvent.
- Parameters:
keycode – The key code associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyReleasedEvent(const KeyCode keycode)
-
class KeyTypedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key typing.
Public Functions
-
inline KeyTypedEvent(const KeyCode keycode)
Constructor for KeyTypedEvent.
- Parameters:
keycode – The key code associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyTypedEvent(const KeyCode keycode)
-
class MouseMovedEvent : public Coffee::Event
- #include <MouseEvent.h>
Event for mouse movement.
Public Functions
-
inline MouseMovedEvent(const float x, const float y)
Constructor for MouseMovedEvent.
- Parameters:
x – The x-coordinate of the mouse.
y – The y-coordinate of the mouse.
-
inline float GetX() const
Get the x-coordinate of the mouse.
- Returns:
The x-coordinate.
-
inline float GetY() const
Get the y-coordinate of the mouse.
- Returns:
The y-coordinate.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseMovedEvent(const float x, const float y)
-
class MouseScrolledEvent : public Coffee::Event
- #include <MouseEvent.h>
Event for mouse scrolling.
Public Functions
-
inline MouseScrolledEvent(const float xOffset, const float yOffset)
Constructor for MouseScrolledEvent.
- Parameters:
xOffset – The scroll offset along the x-axis.
yOffset – The scroll offset along the y-axis.
-
inline float GetXOffset() const
Get the scroll offset along the x-axis.
- Returns:
The x-axis scroll offset.
-
inline float GetYOffset() const
Get the scroll offset along the y-axis.
- Returns:
The y-axis scroll offset.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseScrolledEvent(const float xOffset, const float yOffset)
-
class MouseButtonEvent : public Coffee::Event
- #include <MouseEvent.h>
Base class for mouse button events.
Subclassed by Coffee::MouseButtonPressedEvent, Coffee::MouseButtonReleasedEvent
Public Functions
-
inline MouseCode GetMouseButton() const
Get the mouse button associated with the event.
- Returns:
The mouse button.
-
inline MouseCode GetMouseButton() const
-
class MouseButtonPressedEvent : public Coffee::MouseButtonEvent
- #include <MouseEvent.h>
Event for mouse button press.
Public Functions
-
inline MouseButtonPressedEvent(const MouseCode button)
Constructor for MouseButtonPressedEvent.
- Parameters:
button – The mouse button associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseButtonPressedEvent(const MouseCode button)
-
class MouseButtonReleasedEvent : public Coffee::MouseButtonEvent
- #include <MouseEvent.h>
Event for mouse button release.
Public Functions
-
inline MouseButtonReleasedEvent(const MouseCode button)
Constructor for MouseButtonReleasedEvent.
- Parameters:
button – The mouse button associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseButtonReleasedEvent(const MouseCode button)
-
EVENT_CLASS_TYPE(type)