13#define BIT(x) (1 << x)
73 template<
typename T,
typename F>
76 event.ishandled |= func(*
static_cast<T*
>(&event));
86#define G_EVENT_CLASS_TYPE(type) \
87 static size_t getStaticType() { return typeid(type).hash_code(); } \
88 virtual size_t getEventType() const override { return getStaticType(); } \
89 virtual const char* getEventName() const override { return #type; }
91#define G_EVENT_CLASS_CATEGORY(category) \
92 virtual int getCategoryFlags() const override { return category; }
97#define G_BIND_FUNCTION(fn) [this](auto&&... args) -> decltype(auto) { return this->fn(std::forward<decltype(args)>(args)...); }
98#define G_BIND_GLOBAL_FUNCTION(fn) [](auto&&... args) -> decltype(auto) { return fn(std::forward<decltype(args)>(args)...); }
gEventDispatcher(gEvent &event)
Definition gEvent.h:68
bool dispatch(const F &func)
Definition gEvent.h:74
virtual int getCategoryFlags() const =0
bool isInCategory(EventCategory category)
Definition gEvent.h:42
bool ishandled
Definition gEvent.h:36
virtual ~gEvent()=default
virtual std::size_t getEventType() const =0
virtual const char * getEventName() const =0
std::function< void(gEvent &)> EventHandlerFn
Definition gEvent.h:47
EventCategory
Definition gEvent.h:14
@ EVENTCATEGORY_KEYBOARD
Definition gEvent.h:17
@ EVENTCATEGORY_CUSTOM
Definition gEvent.h:23
@ EVENTCATEGORY_JOYSTICK
Definition gEvent.h:20
@ EVENTCATEGORY_TOUCHSCREEN
Definition gEvent.h:21
@ EVENTCATEGORY_APP
Definition gEvent.h:15
@ EVENTCATEGORY_MOUSE
Definition gEvent.h:18
@ EVENTCATEGORY_RENDERER
Definition gEvent.h:22
@ EVENTCATEGORY_MOUSE_BUTTON
Definition gEvent.h:19
@ EVENTCATEGORY_INPUT
Definition gEvent.h:16
#define BIT(x)
Definition gEvent.h:13