3#include "pixelbullet/core/bits.h"
10#define PB_BIND_EVENT_FN(fn) [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)
51#define EVENT_CLASS_TYPE(type) \
52 static EventType GetStaticType() \
54 return EventType::type; \
56 virtual EventType GetEventType() const override \
58 return GetStaticType(); \
60 virtual const char* GetName() const override \
65#define EVENT_CLASS_CATEGORY(category) \
66 virtual int GetCategoryFlags() const override \
74 virtual ~Event() =
default;
76 virtual EventType GetEventType()
const = 0;
77 virtual const char* GetName()
const = 0;
78 virtual int GetCategoryFlags()
const = 0;
79 virtual std::string ToString()
const
84 bool IsInCategory(EventCategory category)
const;
92 template <
typename T,
typename F>
93 EventResult Dispatch(
const F& func)
95 if (event_.GetEventType() == T::GetStaticType())
97 return func(
static_cast<T&
>(event_));
99 return EventResult::Ignored;
106std::ostream& operator<<(std::ostream& os,
const Event& e);