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

◆ place()

TextField & MayaFlux::Portal::Forma::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.

Parameters
in_bufPre-created target for the text - must have an additional_textures slot at index 0 (Element::with_text's requirement).
surfaceSurface to register the element on.
boundsNDC region: hit-test bounds and the text.
in_paramsShared render params. A default-constructed one is allocated if null.
initial_textStarting text. Cursor starts at its end.
Returns
*this, with results populated.

Definition at line 134 of file TextField.cpp.

140{
141 buf = std::move(in_buf);
143 m_live_bounds = std::make_shared<Kinesis::AABB2D>(bounds);
144
145 params = std::move(in_params);
146 if (!params)
147 params = std::make_shared<Portal::Text::PressParams>();
148
149 m_element = Element {}
150 .with_name("text_field")
153 .with_text(initial_text, *params, bounds);
155
156 element_id = surface.layer().add(m_element);
158
159 state = std::make_shared<MappedState<Portal::Text::EditableText>>();
160 state->value.cursor = initial_text.size();
161 state->value.text = std::move(initial_text);
162
163 render_caret(*slice, state->value, *params);
164
165 wire(surface.ctx());
166
167 return *this;
168}
Element & with_bounds(Kinesis::AABB2D b)
Set the fast-reject AABB.
Definition Element.hpp:109
Element & with_buffer(FormaTarget target)
Attach a FormaBuffer, or a slice of one, as the rendered output for this region.
Definition Element.hpp:195
Element & with_text(std::string_view text, std::optional< Portal::Text::PressParams > params, Kinesis::AABB2D region={ .min=glm::vec2(-1.F),.max=glm::vec2(1.F) })
Draw text as glyph quads into the attached buffer.
Definition Element.cpp:41
std::shared_ptr< internal::TextSlice > text_slice
Text drawn into the attached buffer by with_text().
Definition Element.hpp:89
uint32_t id
Stable id assigned by Layer::add. Never zero.
Definition Element.hpp:63
Element & with_name(std::string n)
Set the human-readable name used in Lila introspection and debug output.
Definition Element.hpp:304
std::shared_ptr< MappedState< Portal::Text::EditableText > > state
Live editable text and cursor. Valid after place().
Definition TextField.hpp:97
uint32_t element_id
Element id of the text field. Valid after place().
Definition TextField.hpp:94
std::shared_ptr< Portal::Text::PressParams > params
Shared, mutable render params - every re-render reads this fresh, so a caller can change it once and ...
Kinesis::AABB2D bounds() const noexcept
Field region, satisfying Kinesis::HasBounds.
std::shared_ptr< internal::TextSlice > slice
The text and caret drawn into buf. Valid after place().
FormaTarget buf
Target the text and caret draw into.
std::shared_ptr< Kinesis::AABB2D > m_live_bounds
Same value as field_bounds, behind a shared_ptr so wire()'s already-captured Context closures see a r...
Kinesis::AABB2D field_bounds
NDC region occupied by the field. Valid after place().

References MayaFlux::Portal::Forma::Layer::add(), bounds(), buf, MayaFlux::Portal::Forma::Surface::ctx(), element_id, field_bounds, MayaFlux::Portal::Forma::Element::id, MayaFlux::Portal::Forma::Surface::layer(), m_element, m_live_bounds, params, slice, state, MayaFlux::Portal::Forma::Element::text_slice, wire(), MayaFlux::Portal::Forma::Element::with_bounds(), MayaFlux::Portal::Forma::Element::with_buffer(), MayaFlux::Portal::Forma::Element::with_name(), and MayaFlux::Portal::Forma::Element::with_text().

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

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