4#include "Hana/Core/Core.h"
16 WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved,
17 AppTick, AppUpdate, AppRender,
18 KeyPressed, KeyReleased, KeyTyped,
19 MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
25 EventCategoryApplication = BIT(0),
26 EventCategoryInput = BIT(1),
27 EventCategoryKeyboard = BIT(2),
28 EventCategoryMouse = BIT(3),
29 EventCategoryMouseButton = BIT(4)
32#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::type; }\
33 virtual EventType GetEventType() const override { return GetStaticType(); }\
34 virtual const char* GetName() const override { return #type; }
36#define EVENT_CLASS_CATEGORY(category) virtual int GetCategoryFlags() const override { return category; }
43 virtual EventType GetEventType()
const = 0;
44 virtual const char* GetName()
const = 0;
45 virtual int GetCategoryFlags()
const = 0;
46 virtual std::string ToString()
const {
return GetName(); }
48 inline bool IsInCategory(EventCategory category)
50 return GetCategoryFlags() & category;
57 EventDispatcher(
Event& event)
62 template<
typename T,
typename F>
63 bool Dispatch(
const F& func)
65 if (m_Event.GetEventType() == T::GetStaticType())
67 m_Event.Handled = func(
static_cast<T&
>(m_Event));
76 inline std::ostream& operator<<(std::ostream& os,
const Event& e)
78 return os << e.ToString();