11#include "sml/events/event.h"
12#include "sml/events/system_events.h"
13#include "sml/sml_log.h"
19 MOUSE_ENTERED = Sml::SML_EVENT_TYPE_FIRST_UNSPECIFIED,
34 EVENT_CATEGORY_GUI = Sml::SML_EVENT_CATEGORY_FIRST_UNSPECIFIED,
35 EVENT_CATEGORY_DRAG_AND_DROP
48 C* getComponent() {
return m_Component; }
49 void setComponent(C* component) { m_Component = component; }
52 C* m_Component =
nullptr;
58 MouseEnteredEvent(int32_t x = 0, int32_t y = 0, Sml::EventTarget* target =
nullptr)
59 : Sml::MouseEvent(x, y, target)
61 m_Type = getStaticType();
62 m_Category = getStaticCategory();
65 DEFINE_STATIC_EVENT_TYPE(MOUSE_ENTERED)
66 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI | Sml::MouseEvent::getStaticCategory())
72 MouseExitedEvent(int32_t x = 0, int32_t y = 0, Sml::EventTarget* target =
nullptr)
73 : Sml::MouseEvent(x, y, target)
75 m_Type = getStaticType();
76 m_Category = getStaticCategory();
79 DEFINE_STATIC_EVENT_TYPE(MOUSE_EXITED)
80 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI | Sml::MouseEvent::getStaticCategory())
87 DEFINE_STATIC_LISTENED_EVENT_TYPES(MouseEnteredEvent::getStaticType(),
88 MouseExitedEvent::getStaticType())
92 virtual void onEvent(Sml::Event* event)
override final
94 switch (event->getType())
96 case MouseEnteredEvent::getStaticType():
102 case MouseExitedEvent::getStaticType():
110 LOG_LIB_ERROR(
"HoverListener got invalid Event with type %" PRIu32, event->getType());
128 : Sml::Event(getStaticType(), getStaticCategory(), target), m_PreviousFocus(prevFocus) {}
130 Component* getPreviousFocus() {
return m_PreviousFocus; }
133 DEFINE_STATIC_EVENT_TYPE(FOCUS_RECEIVED)
134 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI)
144 : Sml::Event(getStaticType(), getStaticCategory(), target), m_NewFocus(newFocus) {}
147 Component* getNewFocus() {
return m_NewFocus; }
149 DEFINE_STATIC_EVENT_TYPE(FOCUS_LOST)
150 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI)
160 DEFINE_STATIC_LISTENED_EVENT_TYPES(FocusReceivedEvent::getStaticType(), FocusLostEvent::getStaticType())
165 virtual void onEvent(Sml::Event* event)
override final
167 switch (event->getType())
169 case FocusReceivedEvent::getStaticType():
175 case FocusLostEvent::getStaticType():
183 LOG_LIB_ERROR(
"FocusListener received invalid event of type %d!", event->getType());
198 : Sml::Event(getStaticType(), getStaticCategory(), target) {}
200 DEFINE_STATIC_EVENT_TYPE(ACTION_PERFORMED)
201 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI)
208 DEFINE_STATIC_LISTENED_EVENT_TYPES(ActionEvent::getStaticType())
213 virtual void onEvent(Sml::Event* event)
override final
228 DragEvent(int32_t x, int32_t y, Sml::EventTarget* target =
nullptr)
229 : Sml::Event(getStaticType(), getStaticCategory(), target), m_X(x), m_Y(y) {}
231 DEFINE_STATIC_EVENT_TYPE(Sml::INVALID_EVENT_TYPE)
232 DEFINE_STATIC_EVENT_CATEGORY(EVENT_CATEGORY_GUI | EVENT_CATEGORY_DRAG_AND_DROP)
234 int32_t getX()
const {
return m_X; }
235 void setX(int32_t x) { m_X = x; }
237 int32_t getY()
const {
return m_Y; }
238 void setY(int32_t y) { m_Y = y; }
250 m_Type = getStaticType();
251 m_Category = getStaticCategory();
254 DEFINE_STATIC_EVENT_TYPE(DRAG_START)
255 DEFINE_STATIC_EVENT_CATEGORY(DragEvent::getStaticCategory())
263 m_Type = getStaticType();
264 m_Category = getStaticCategory();
267 DEFINE_STATIC_EVENT_TYPE(DRAG_END)
268 DEFINE_STATIC_EVENT_CATEGORY(DragEvent::getStaticCategory())
274 DragMoveEvent(int32_t x, int32_t y, int32_t deltaX, int32_t deltaY, Sml::EventTarget* target =
nullptr)
275 :
DragEvent(x, y, target), m_DeltaX(deltaX), m_DeltaY(deltaY)
277 m_Type = getStaticType();
278 m_Category = getStaticCategory();
281 int32_t getDeltaX()
const {
return m_DeltaX; }
282 int32_t getDeltaY()
const {
return m_DeltaY; }
284 DEFINE_STATIC_EVENT_TYPE(DRAG_MOVE)
285 DEFINE_STATIC_EVENT_CATEGORY(DragEvent::getStaticCategory())
288 int32_t m_DeltaX = 0;
289 int32_t m_DeltaY = 0;
296 DEFINE_STATIC_LISTENED_EVENT_TYPES(DragStartEvent::getStaticType(),
297 DragEndEvent::getStaticType(),
298 DragMoveEvent::getStaticType())
303 virtual void onEvent(Sml::Event* event)
override final
305 switch (event->getType())
307 case DragStartEvent::getStaticType():
313 case DragEndEvent::getStaticType():
319 case DragMoveEvent::getStaticType():