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

◆ create_text_field()

MAYAFLUX_API TextField MayaFlux::Portal::Forma::create_text_field ( Surface &  surface,
Kinesis::AABB2D  bounds,
std::shared_ptr< Portal::Text::PressParams >  params = nullptr,
std::string  initial_text = {},
bool  scrollable = false 
)

Build a text-capable FormaBuffer, register a TextField, and wire text editing onto it in one call.

The one-call convenience over TextField::place(), the same split Portal::Forma::create<T> already has with a bare Form<T>. This builds the buffer (create_buffer, which TextField.cpp itself may never call; see TextField.hpp) and delegates. Build the buffer and TextField by hand instead for anything needing a non-default buffer setup (a shared texture slot alongside a background quad, for instance).

scrollable composes a second primitive in, the same way: false (the default) matches every prior call exactly, and bounds is the field's own region. True builds a plain Scrollable and places its viewport and the field text in slices of one text-capable buffer, then calls TextField::scrollable() instead of place(). This is the same composition test_text_input() (test_8.hpp) once wired by hand, now living at the TextField primitive level; this is only the one-call convenience over it. That Scrollable is local to this call and not returned, so no indicator is added and nothing else can be tracked into the same viewport. Build the Scrollable yourself and call TextField::scrollable() directly (or place() + Scrollable::track() by hand) for either of those.

Parameters
surfaceSurface whose window, layer, and context own the field.
boundsNDC region for both hit testing and the text quad, or, when scrollable, the fixed clipped viewport.
paramsShared render params. A default-constructed one is allocated if null.
initial_textStarting text. Cursor starts at its end.
scrollableWhen true, wraps the field in a Scrollable viewport.
Returns
Registered, wired TextField. Portal::Forma::destroy(surface, field.element_id) is sufficient to tear the whole thing down, scrollable viewport included when scrollable is true. No manual multi-id cleanup is needed.

Definition at line 15 of file Tend.cpp.

21{
22 if (!scrollable) {
23 return TextField {}.place(
24 make_text_buffer(surface), surface, bounds, std::move(params), std::move(initial_text));
25 }
26
27 const auto batch = make_text_buffer(surface);
28 auto viewport_target = FormaTarget::slice_of(batch, Graphics::PrimitiveTopology::TRIANGLE_STRIP);
29 auto viewport = Scrollable {}.place(std::move(viewport_target), surface, bounds);
30
31 return TextField {}.scrollable(
32 FormaTarget::slice_of(batch, Graphics::PrimitiveTopology::TRIANGLE_LIST),
33 surface, viewport, std::move(params), std::move(initial_text));
34}
MAYAFLUX_API TextField & place(FormaTarget in_buf, Surface &surface, Kinesis::AABB2D bounds, std::shared_ptr< Portal::Text::PressParams > in_params, std::string initial_text={})
Register the text field element and wire text editing onto it.
An editable text region: keyboard/text-input wiring over an Element the caller already has a buffer f...
Definition TextField.hpp:88

References create_text_field(), MayaFlux::Portal::Forma::TextField::place(), MayaFlux::Portal::Forma::Scrollable::place(), and MayaFlux::Portal::Forma::TextField::scrollable().

Referenced by create_text_field().

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