|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
| Scrollable & MayaFlux::Portal::Forma::Scrollable::indicator | ( | Surface & | surface, |
| Mapped< glm::vec2 > | el, | ||
| Kinesis::AABB2D | track | ||
| ) |
Attach a caller-built element as a live, draggable scroll indicator.
Scrollable draws nothing itself. Build whatever Mapped<glm::vec2> your own geometry function produces - a bar, a squiggle, a sampled texture, anything computable from (position_frac, extent_frac) - via Portal::Forma::create<glm::vec2>, register it, and hand it here. position_frac is 0 at the top of content_bounds and 1 at the fully scrolled bottom; extent_frac is the viewport/content height ratio (how much of the content is visible at once), so a geometry function can size its own drawing without asking Scrollable anything further.
On every scroll - wheel (place()'s default wiring), scroll_by(), or dragging this same element - the live fraction pair is written to el.state and el.sync() is called, the same "call sync() straight from the handler that changed the value, no polling" idiom Collapsible's own on_press already uses. track() also refreshes extent_frac (without a Layer, so el's hit region only, not bounds_hint, can lag very slightly until the next scroll - self-corrects on the first interaction after).
Also wires on_drag on el.element.id: dragging maps the cursor's NDC y absolutely onto content offset within track, the same inverse-mapping idiom Geometry::vertical_fader uses for its own handle, routed through scroll_by() so drag and wheel scrolling stay in sync through one path. No handle-size compensation is applied, unlike vertical_fader - an indicator has no fixed rendered size for Scrollable to know about.
| surface | Surface owning the same Layer/Context place() used. |
| el | Caller's Mapped<glm::vec2>, already registered on surface's Layer. |
| track | NDC region the drag is measured against; its full height maps to the full scrollable range. |
Definition at line 140 of file Scrollable.cpp.
References MayaFlux::Portal::Forma::Surface::ctx(), MayaFlux::Portal::Forma::Layer::get(), MayaFlux::Portal::Forma::Surface::layer(), MayaFlux::IO::Left, m_indicator, m_tracked, offset, MayaFlux::Portal::Forma::Context::on_drag(), scroll, and track().
Referenced by wheel_handler().
Here is the call graph for this function:
Here is the caller graph for this function: