5#include <unordered_map>
16#define APPEND_EVENT_INFO(name, cat) \
17 inline static const std::string_view debug_name = name; \
18 inline static const Category category = cat;
80 void on(std::function<
void(
const T &t)> cb);
83 std::unordered_map<size_t, std::vector<std::function<void(
void *)>>>
87template <
typename Type>
90 const auto id =
typeid(Type{}).hash_code();
98template <
typename Type>
100 const auto id =
typeid(Type{}).hash_code();
101 handlers_[id].push_back([func = std::move(func)](
void *value) {
102 func(*
static_cast<Type *
>(value));
void dispatch(T &&value) const
std::unordered_map< size_t, std::vector< std::function< void(void *)> > handlers_)
Definition event.hpp:84
void on(std::function< void(const T &t)> cb)
#define DESCRIBED_ENUM(E,...)
Definition enums.hpp:7
#define APPEND_EVENT_INFO(name, cat)
Definition event.hpp:16
MouseCode
Definition keycode.hpp:5
KeyCode
Definition keycode.hpp:7
KeyCode key
Definition event.hpp:61
std::string_view text
Definition event.hpp:71
APPEND_EVENT_INFO("KeyTyped", Category::KEYBOARD)
KeyCode key
Definition event.hpp:66
float x
Definition event.hpp:36
bool relative
Definition event.hpp:38
float y
Definition event.hpp:37
float y
Definition event.hpp:45
float x
Definition event.hpp:44
APPEND_EVENT_INFO("WindowClose", Category::WINDOW)
float height
Definition event.hpp:30
WindowResized(const std::pair< float, float > &size)
Definition event.hpp:26
float width
Definition event.hpp:29