|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
Event wiring between a Layer and a window surface. More...
#include <Context.hpp>
Collaboration diagram for MayaFlux::Portal::Forma::Context:Classes | |
| struct | ElementCallbacks |
| struct | KeyHandlerState |
Public Types | |
| using | EnterFn = std::function< void(uint32_t id)> |
| using | KeyFn = std::function< void(uint32_t id)> |
| using | LeaveFn = std::function< void(uint32_t id)> |
| using | MoveFn = std::function< void(uint32_t id, glm::vec2 ndc)> |
| using | PressFn = std::function< void(uint32_t id, glm::vec2 ndc)> |
| using | ScrollFn = std::function< void(uint32_t id, glm::vec2 ndc, double dx, double dy)> |
Public Member Functions | |
| void | clear_focus () |
| Clear keyboard focus (no element focused). | |
| Context (const Context &)=delete | |
| Context (Context &&)=delete | |
| Context (std::shared_ptr< Layer > layer, std::shared_ptr< Core::Window > window, Vruta::EventManager &event_manager, std::string name) | |
| Construct and immediately register event coroutines. | |
| const Vruta::WindowEventSource & | event_source () const |
| std::optional< uint32_t > | focused () const |
| Get currently focused element, if any. | |
| std::optional< uint32_t > | hovered () const |
| Context & | key_step (uint32_t id, std::shared_ptr< MappedState< float > > state, IO::Keys decrease, IO::Keys increase, float delta, float clamp_min=0.0F, float clamp_max=1.0F) |
| Attach key-delta handlers to a Mapped<float> element. | |
| void | on_drag (uint32_t id, IO::MouseButtons btn, MoveFn fn) |
Called on each mouse-move event while btn is held, tracking the element where the drag began even when the cursor leaves its bounds. | |
| void | on_enter (uint32_t id, EnterFn fn) |
| Called once when the cursor enters an element's region. | |
| void | on_focus_gained (uint32_t id, EnterFn fn) |
| Called once when an element gains keyboard focus (via click). | |
| void | on_focus_lost (uint32_t id, LeaveFn fn) |
| Called once when an element loses keyboard focus. | |
| void | on_held (uint32_t id, IO::Keys key, KeyFn fn) |
| Called repeatedly while a key is held and the element has focus. | |
| void | on_leave (uint32_t id, LeaveFn fn) |
| Called once when the cursor leaves an element's region. | |
| void | on_move (uint32_t id, MoveFn fn) |
| Called each move event while the cursor is over an element. | |
| void | on_press (uint32_t id, IO::Keys key, KeyFn fn) |
| Called when a key is pressed while the element has focus. | |
| void | on_press (uint32_t id, IO::MouseButtons btn, PressFn fn) |
| Called when a mouse button is pressed over an element. | |
| void | on_release (uint32_t id, IO::Keys key, KeyFn fn) |
| Called when a key is released while the element has focus. | |
| void | on_release (uint32_t id, IO::MouseButtons btn, PressFn fn) |
| Called when a mouse button is released over an element. | |
| void | on_scroll (uint32_t id, ScrollFn fn) |
| Called on scroll while the cursor is over an element. | |
| Context & | operator= (const Context &)=delete |
| Context & | operator= (Context &&)=delete |
| void | unbind (uint32_t id) |
| Remove all callbacks registered for an element id. | |
| ~Context () | |
| Cancel all registered event coroutines. | |
Private Member Functions | |
| void | cancel_handlers () |
| void | handle_drag (double px, double py, IO::MouseButtons btn) |
| void | handle_key_held (IO::Keys key) |
| void | handle_key_press (IO::Keys key) |
| void | handle_key_release (IO::Keys key) |
| void | handle_move (double px, double py) |
| void | handle_press (double px, double py, IO::MouseButtons btn) |
| void | handle_release (double px, double py, IO::MouseButtons btn) |
| void | handle_scroll (double dx, double dy) |
| void | register_handlers () |
| glm::vec2 | to_ndc (double px, double py) const noexcept |
Private Attributes | |
| std::unordered_map< uint32_t, ElementCallbacks > | m_callbacks |
| std::optional< uint32_t > | m_dragging [3] |
| Vruta::EventManager & | m_event_manager |
| std::optional< uint32_t > | m_focused |
| std::optional< uint32_t > | m_hovered |
| std::shared_ptr< Layer > | m_layer |
| std::string | m_name |
| std::unordered_map< int, KeyHandlerState > | m_registered_keys |
| std::shared_ptr< Core::Window > | m_window |
Event wiring between a Layer and a window surface.
Subscribes to mouse events on a window by constructing Kriya input coroutines and registering them with a Vruta::EventManager, following the same pattern as Nexus::Fabric. The EventManager and Window are injected; Context holds no engine-level singletons.
Callbacks fire on the scheduler tick. They must not touch GPU resources directly. State intended for the graphics tick should be written through shared_ptr captures and read on the next graphics cycle.
All registered events are cancelled on destruction via EventManager::cancel_event, keyed by names scoped to this Context.
Window dimensions are read from window->get_state() at event time, so resize is handled automatically.
Definition at line 40 of file Context.hpp.