|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
| TextField & MayaFlux::Portal::Forma::TextField::scrollable | ( | FormaTarget | in_buf, |
| Surface & | surface, | ||
| Scrollable & | scroller, | ||
| std::shared_ptr< Portal::Text::PressParams > | in_params, | ||
| std::string | initial_text = {}, |
||
| float | content_multiplier = 3.F |
||
| ) |
Fluent creator: place this field inside an already-placed Scrollable, growing itself taller than its viewport and track()ing itself in, wired to scroll past a fixed clip.
scroller is entirely the caller's: build and configure it first - Scrollable::place(), and optionally indicator()/background_color()/ wheel_speed(), all fluent - then pass it here by reference. This method reads scroller.bounds() for the viewport region, places this field at a content region content_multiplier times that viewport's height (top-aligned, same width), and calls scroller.track() with this field's own buf as clip_buf and reposition() as the reflow callback. The same three-call composition shown in the class doc, done once here so callers building the common single-field case do not have to repeat it - nothing about the viewport, its buffer, or any indicator passes through this call, because Scrollable already owns all of that.
Also wires scroller.wheel_handler() onto this field's own element: the field sits on top of the viewport and is added to the Layer after it, so it hit-tests first, and Context::handle_scroll only ever dispatches to the topmost element under the cursor - without this, the wheel would do nothing while the cursor sits directly over the field's own text instead of the viewport's empty margin.
Also relate()s element_id under scroller.viewport_id, so Portal::Forma::destroy(surface, element_id) tears down the scroller's viewport too, even though scroller itself is never owned or stored here - only its Layer-side element needs freeing this way.
| in_buf | Pre-created target for the field's text. |
| surface | Surface to register the field's element on - must be the same Surface scroller was placed on. |
| scroller | Already-placed Scrollable to grow and track into. |
| in_params | Shared render params. A default-constructed one is allocated if null. |
| initial_text | Starting text. Cursor starts at its end. |
| content_multiplier | Content height as a multiple of scroller's viewport height. Default 3x: enough headroom to type past the viewport before hitting the limit, not so much that most content sits unreachable below a near-empty field. |
Definition at line 249 of file TextField.cpp.
References MayaFlux::Portal::Forma::Scrollable::bounds(), buf, MayaFlux::Portal::Forma::Surface::ctx(), element_id, MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Portal::Forma::Surface::layer(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Portal::Forma::Context::on_scroll(), place(), MayaFlux::Portal::Forma::Layer::relate(), MayaFlux::Portal::Forma::Scrollable::track(), MayaFlux::Portal::Forma::Scrollable::viewport_id, and MayaFlux::Portal::Forma::Scrollable::wheel_handler().
Referenced by MayaFlux::Portal::Forma::create_text_field().
Here is the call graph for this function:
Here is the caller graph for this function: