le2d v0.4.7
2D game engine framework
 
Loading...
Searching...
No Matches
dispatch.hpp
Go to the documentation of this file.
1#pragma once
3#include <gsl/pointers>
4#include <vector>
5
6namespace le::input {
7class Dispatch {
8 public:
9 Dispatch(Dispatch const&) = delete;
10 auto operator=(Dispatch const&) = delete;
11
12 Dispatch() = default;
13 Dispatch(Dispatch&& rhs) noexcept;
14 auto operator=(Dispatch&& rhs) noexcept -> Dispatch&;
16
17 void attach(gsl::not_null<Listener*> listener);
18 void detach(gsl::not_null<Listener*> listener);
19
20 void on_cursor_move(glm::vec2 pos);
22 void on_key(event::Key const& key);
24 void on_scroll(event::Scroll const& scroll);
25 void on_drop(event::Drop const& drop);
26
27 void handle_events(glm::ivec2 framebuffer_size, std::span<le::Event const> events);
29
31
32 private:
33 enum class Type : std::int8_t { None, Keyboard, Mouse };
34
35 void update_listeners(Dispatch* target) const;
36
37 template <typename FPtr, typename T>
38 void dispatch(FPtr fptr, T const& event, Type type) const;
39
40 std::vector<Listener*> m_listeners{};
41};
42} // namespace le::input
Definition dispatch.hpp:7
void on_drop(event::Drop const &drop)
auto operator=(Dispatch const &)=delete
void on_codepoint(event::Codepoint codepoint)
void on_scroll(event::Scroll const &scroll)
void detach(gsl::not_null< Listener * > listener)
void handle_events(glm::ivec2 framebuffer_size, std::span< le::Event const > events)
auto operator=(Dispatch &&rhs) noexcept -> Dispatch &
void on_cursor_move(glm::vec2 pos)
void attach(gsl::not_null< Listener * > listener)
void on_key(event::Key const &key)
Dispatch(Dispatch &&rhs) noexcept
bool honor_imgui_want_capture
Definition dispatch.hpp:30
Dispatch(Dispatch const &)=delete
void on_mouse_button(event::MouseButton const &button)
kvf::Codepoint Codepoint
Definition event.hpp:37
Definition action.hpp:4
Definition event.hpp:59
Definition event.hpp:39
Definition event.hpp:47
Definition event.hpp:55