45 using Underlying = std::underlying_type_t<EventCategory>;
46 return static_cast<EventCategory>(
static_cast<Underlying
>(left) |
static_cast<Underlying
>(right));
52 using Underlying = std::underlying_type_t<EventCategory>;
53 return static_cast<EventCategory>(
static_cast<Underlying
>(left) &
static_cast<Underlying
>(right));
64 return "WindowResize";
68 return "WindowMinimize";
76 return "MouseButtonPressed";
78 return "MouseButtonReleased";
82 return "MouseScrolled";
97 virtual ~Event() =
default;
138 bool m_Handled =
false;
146 template <EventType Type, EventCategory Categories>
163 return event.ToString();
Contains the base definitions and utilities for the Quasar engine.
Base class of each event class, which gives the event its type and its categories.
Definition Event.h:148
static constexpr EventType GetStaticType()
Returns the type of this event class.
Definition Event.h:151
EventType GetType() const override
Returns the type of the event.
Definition Event.h:154
EventCategory GetCategories() const override
Returns all the categories of the event.
Definition Event.h:157
Base class of all events.
Definition Event.h:95
virtual EventType GetType() const =0
Returns the type of the event.
void SetHandled(bool handled)
Marks the event as handled, or not handled.
Definition Event.h:121
virtual std::string ToString() const
Returns a readable description of the event, for debugging.
Definition Event.h:109
const char * GetName() const
Returns the name of the type of the event, for example "KeyPressed".
Definition Event.h:112
virtual EventCategory GetCategories() const =0
Returns all the categories of the event.
bool IsInCategory(EventCategory category) const
Returns true if the event belongs to the given category.
Definition Event.h:115
bool IsHandled() const
Returns true if the event was handled.
Definition Event.h:118
Event()=default
Creates an event that is not handled.
Application window.
Definition Window.h:42
Contains all the engine code.
constexpr std::uint32_t Bit(std::uint32_t index)
Returns a value where only the bit at the given index is set, for example Bit(3) is 8.
Definition Base.h:100
constexpr EventCategory operator|(EventCategory left, EventCategory right)
Combines two sets of categories.
Definition Event.h:43
std::string format_as(UUID uuid)
Lets the log macros print a UUID with {}, using UUID::ToString().
Definition UUID.h:66
EventCategory
Categories of an event. An event can belong to several categories, combined with the | operator.
Definition Event.h:34
@ None
No category.
Definition Event.h:35
@ Keyboard
Events from the keyboard.
Definition Event.h:38
@ Mouse
Events from the mouse.
Definition Event.h:39
constexpr const char * GetEventTypeName(EventType type)
Returns the name of an event type, for example "KeyPressed".
Definition Event.h:57
constexpr EventCategory operator&(EventCategory left, EventCategory right)
Keeps only the categories found in both sets.
Definition Event.h:50
EventType
Type of an event. Each event class has exactly one type.
Definition Event.h:18
@ WindowFocus
The window gained or lost the focus.
Definition Event.h:21
@ KeyReleased
A key was released.
Definition Event.h:24
@ MouseScrolled
The mouse wheel or the touchpad scrolled.
Definition Event.h:29
@ MouseButtonPressed
A mouse button was pressed.
Definition Event.h:26
@ MouseButtonReleased
A mouse button was released.
Definition Event.h:27
@ KeyTyped
A character was typed, for text input.
Definition Event.h:25
@ WindowResize
The size of the window changed.
Definition Event.h:20
@ KeyPressed
A key was pressed, or is repeating while held down.
Definition Event.h:23
@ MouseMoved
The cursor moved.
Definition Event.h:28
@ WindowClose
The user asked to close the window.
Definition Event.h:19
@ WindowMinimize
The window was minimized or restored.
Definition Event.h:22