3#include "PixelBullet/Math/Bitwise.hpp"
9#define PB_BIND_EVENT_FN(fn) \
10 [this](auto&&... args) -> decltype(auto) { return this->fn(std::forward<decltype(args)>(args)...); }
37 EventCategoryApplication = BIT(0),
38 EventCategoryInput = BIT(1),
39 EventCategoryKeyboard = BIT(2),
40 EventCategoryMouse = BIT(3),
41 EventCategoryMouseButton = BIT(4)
44#define EVENT_CLASS_TYPE(type) \
45 static EventType GetStaticType() \
47 return EventType::type; \
49 virtual EventType GetEventType() const override \
51 return GetStaticType(); \
53 virtual const char* GetName() const override \
58#define EVENT_CLASS_CATEGORY(category) \
59 virtual int GetCategoryFlags() const override \
67 virtual ~Event() =
default;
71 virtual EventType GetEventType()
const = 0;
72 virtual const char* GetName()
const = 0;
73 virtual int GetCategoryFlags()
const = 0;
74 virtual std::string ToString()
const
79 bool IsInCategory(EventCategory category)
const;
87 template <
typename T,
typename F>
88 bool Dispatch(
const F& func)
90 if (m_Event.GetEventType() == T::GetStaticType())
92 m_Event.Handled |= func(
static_cast<T&
>(m_Event));
102 std::ostream& operator<<(std::ostream& os,
const Event& e);