MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Forma::Scrollable Struct Reference

A clipped, scroll-offset viewport over content taller than it. More...

#include <Scrollable.hpp>

+ Collaboration diagram for MayaFlux::Portal::Forma::Scrollable:

Public Member Functions

Scrollable & background_color (glm::vec3 c)
 
Kinesis::AABB2D bounds () const noexcept
 Viewport region, satisfying Kinesis::HasBounds.
 
MAYAFLUX_API Scrollable & indicator (Surface &surface, Mapped< glm::vec2 > el, Kinesis::AABB2D track)
 Attach a caller-built element as a live, draggable scroll indicator.
 
MAYAFLUX_API Scrollable & place (FormaTarget in_buf, Surface &surface, Kinesis::AABB2D viewport)
 Register the viewport element, wire wheel scrolling, and populate scroll, offset, buf, and cursor_out.
 
MAYAFLUX_API void scroll_by (Layer &layer, glm::vec2 delta)
 Apply a scroll delta and reflow every tracked element.
 
MAYAFLUX_API Scrollable & track (Layer &layer, uint32_t id, Kinesis::AABB2D base_bounds, std::function< void(Kinesis::AABB2D)> reposition, const FormaTarget &clip_buf={})
 Register an element for scroll reflow.
 
MAYAFLUX_API std::function< void(uint32_t, glm::vec2, double, double)> wheel_handler (Surface &surface) const
 A self-contained wheel-scroll handler bound to this Scrollable's own state.
 
Scrollable & wheel_speed (float s)
 

Public Attributes

FormaTarget buf
 FormaBuffer backing the viewport background. Valid after place().
 
LayoutCursor cursor_out
 Cursor scoped to the viewport, bound to offset. Valid after place().
 
glm::vec3 m_background { 0.08F, 0.08F, 0.1F }
 Background fill color. Default: glm::vec3(0.08F, 0.08F, 0.1F).
 
float m_wheel_speed { 0.05F }
 Content-space units scrolled per wheel tick. Default: 0.05F.
 
std::shared_ptr< MappedState< glm::vec2 > > offset
 Reactive mirror of scroll->offset, bound into cursor_out. Valid after place().
 
std::shared_ptr< Kinesis::ScrollState > scroll
 Clamped scroll offset and content/viewport extents. Valid after place().
 
Kinesis::AABB2D viewport_bounds {}
 NDC region occupied by the viewport. Valid after place().
 
uint32_t viewport_id {}
 Element id of the viewport background. Valid after place().
 

Private Attributes

std::shared_ptr< Mapped< glm::vec2 > > m_indicator
 
std::shared_ptr< std::vector< Tracked > > m_tracked
 

Detailed Description

A clipped, scroll-offset viewport over content taller than it.

Before place() is called, the struct carries only configuration. After place(), viewport_id, scroll, offset, buf, and cursor_out are populated. This mirrors the Element/Collapsible pattern: configure with setters, register with a single explicit call.

Scrollable owns a background/hit-test element sized to the viewport and a LayoutCursor (cursor_out) scoped to that viewport, already bound to the live scroll offset via LayoutCursor::bind_scroll, so content placed through it lands at the correct on-screen position immediately, scrolled or not. It does not own or know what kind of content is placed inside it: track() registers an element id plus the caller's own reposition callback, invoked with that element's scrolled bounds on every scroll. This is the same shape as Collapsible::attach(): Scrollable moves bounds and asks the caller's callback to keep visuals in sync, it does not reach into arbitrary geometry functions to do that itself. indicator() follows the same principle for a scroll readout: Scrollable computes the two numbers (position, extent) and drives sync() on the caller's own element, but draws nothing itself.

Wheel input over the viewport is wired by place() as the default trigger, but scroll_by() is a plain method: any other input source (a dragged indicator, a key, MIDI, anything) can drive scrolling by calling it directly, with no dependency on Context::on_scroll at all.

auto panel = Scrollable {}
.background_color({ 0.08F, 0.08F, 0.1F })
.place(buf, surface, viewport);
const Kinesis::AABB2D bounds = panel.cursor_out.advance(row_h);
auto row_buf = FormaTarget::slice_of(
Portal::Forma::create_buffer(surface.render_config()),
row_buf.submit(Kinesis::filled_rect(bounds, color));
const uint32_t id = surface.layer().add(
Element {}.with_bounds(bounds).with_buffer(row_buf).non_interactive());
panel.track(surface.layer(), id, bounds,
[row_buf, color](Kinesis::AABB2D shifted) {
row_buf.submit(Kinesis::filled_rect(shifted, color));
},
row_buf);
glm::vec3 color
Definition Decoder.cpp:97
static FormaTarget slice_of(const std::shared_ptr< Buffers::FormaBuffer > &buffer, std::optional< Graphics::PrimitiveTopology > topology=std::nullopt)
A new empty slice of buffer, drawn after the others.
Definition Target.cpp:19
std::array< Kakshya::Vertex, 4 > filled_rect(Kinesis::AABB2D region, glm::vec3 color)
Generate a filled TRIANGLE_STRIP quad from an AABB2D.
std::shared_ptr< Buffers::FormaBuffer > create_buffer(Graphics::RenderConfig render)
Construct and register a FormaBuffer without creating a Mapped<T>.
Definition Forma.cpp:103
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
FormaTarget buf
FormaBuffer backing the viewport background. Valid after place().
MAYAFLUX_API Scrollable & place(FormaTarget in_buf, Surface &surface, Kinesis::AABB2D viewport)
Register the viewport element, wire wheel scrolling, and populate scroll, offset, buf,...
Kinesis::AABB2D bounds() const noexcept
Viewport region, satisfying Kinesis::HasBounds.
Scrollable & background_color(glm::vec3 c)
A clipped, scroll-offset viewport over content taller than it.

Definition at line 75 of file Scrollable.hpp.


The documentation for this struct was generated from the following files: