11 std::shared_ptr<Core::Window> window,
13 std::function<
void()> callback)
16 auto& source = window->get_event_source();
23 if (promise.should_terminate) {
33 std::shared_ptr<Core::Window> window,
35 std::function<
void()> callback)
38 auto& source = window->get_event_source();
45 if (promise.should_terminate) {
55 std::shared_ptr<Core::Window> window,
56 std::function<
void(
IO::Keys)> callback)
59 auto& source = window->get_event_source();
65 if (promise.should_terminate) {
71 if (
auto* key_data = std::get_if<Core::WindowEvent::KeyData>(&event.data)) {
72 callback(
static_cast<IO::Keys>(key_data->key));
78 std::shared_ptr<Core::Window> window,
80 std::function<
void(
double,
double)> callback)
83 auto& source = window->get_event_source();
90 if (promise.should_terminate) {
96 auto [x, y] = source.get_mouse_position();
102 std::shared_ptr<Core::Window> window,
104 std::function<
void(
double,
double)> callback)
107 auto& source = window->get_event_source();
114 if (promise.should_terminate) {
120 auto [x, y] = source.get_mouse_position();
126 std::shared_ptr<Core::Window> window,
127 std::function<
void(
double,
double)> callback)
130 auto& source = window->get_event_source();
136 if (promise.should_terminate) {
142 if (
auto* pos_data = std::get_if<Core::WindowEvent::MousePosData>(&event.data)) {
143 callback(pos_data->x, pos_data->y);
149 std::shared_ptr<Core::Window> window,
150 std::function<
void(
double,
double)> callback)
153 auto& source = window->get_event_source();
159 if (promise.should_terminate) {
165 if (
auto* scroll_data = std::get_if<Core::WindowEvent::ScrollData>(&event.data)) {
166 callback(scroll_data->x_offset, scroll_data->y_offset);
Awaiter for suspending on window events with optional filtering.
Coroutine type for event-driven suspension.
MouseButtons
Enumeration for mouse buttons.
Vruta::Event key_released(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key release.
Vruta::Event any_key(std::shared_ptr< Core::Window > window, std::function< void(IO::Keys)> callback)
Creates an Event coroutine that triggers on any key press.
Vruta::Event key_pressed(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key press.
Vruta::Event mouse_moved(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse movement.
Vruta::Event mouse_scrolled(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse scroll.
Vruta::Event mouse_released(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button release.
Vruta::Event mouse_pressed(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button press.
Templated awaitable for accessing a coroutine's promise object.
std::optional< IO::Keys > key_code
std::optional< IO::MouseButtons > button
std::optional< Core::WindowEventType > event_type
Filter criteria for window events.