MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ wheel_handler()

std::function< void(uint32_t, glm::vec2, double, double)> MayaFlux::Portal::Forma::Scrollable::wheel_handler ( Surface &  surface) const

A self-contained wheel-scroll handler bound to this Scrollable's own state.

place() wires exactly this behind the viewport's own on_scroll, but Context::handle_scroll dispatches to only the topmost element under the cursor (Layer::hit_test), so content drawn on top of the viewport - anything track()ed, since it registers after and so hit- tests first - never reaches the viewport's own on_scroll while the cursor sits over it. A caller in that position (TextField:: scrollable() is exactly this case) registers the returned function on its own element's on_scroll instead of duplicating the wheel- delta-to-content-delta conversion by hand.

Captures only this Scrollable's own shared state (scroll, offset, the tracked list, the indicator), the same shared_ptrs place()'s own wiring captures - safe to keep registered after this Scrollable value itself is destroyed, same as every other Context callback this struct wires.

Parameters
surfaceSurface owning the same Layer/Context place() used.
Returns
A Context::ScrollFn-shaped callable, ready for on_scroll.

Definition at line 87 of file Scrollable.cpp.

88{
89 return [scroll_state = scroll, scroll_offset = offset, tracked = m_tracked,
91 uint32_t, glm::vec2, double dx, double dy) mutable {
92 Kinesis::apply_scroll(*scroll_state,
93 glm::vec2(static_cast<float>(dx), static_cast<float>(dy)) * speed);
94 reflow(*scroll_state, *scroll_offset, *tracked, surface.layer(), indicator.get());
95 };
96}
void apply_scroll(NavigationState &st, float ticks)
Dolly eye along the current forward vector.
double speed(const Memory::HistoryBuffer< double > &history, double dt) noexcept
Absolute value of a scalar first difference.
std::shared_ptr< MappedState< glm::vec2 > > offset
Reactive mirror of scroll->offset, bound into cursor_out. Valid after place().
std::shared_ptr< Mapped< glm::vec2 > > m_indicator
MAYAFLUX_API Scrollable & indicator(Surface &surface, Mapped< glm::vec2 > el, Kinesis::AABB2D track)
Attach a caller-built element as a live, draggable scroll indicator.
std::shared_ptr< std::vector< Tracked > > m_tracked
float m_wheel_speed
Content-space units scrolled per wheel tick. Default: 0.05F.
std::shared_ptr< Kinesis::ScrollState > scroll
Clamped scroll offset and content/viewport extents. Valid after place().

References MayaFlux::Kinesis::apply_scroll(), indicator(), MayaFlux::Portal::Forma::Surface::layer(), m_indicator, m_tracked, m_wheel_speed, offset, and scroll.

Referenced by place(), and MayaFlux::Portal::Forma::TextField::scrollable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: