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

◆ place_label()

MAYAFLUX_API uint32_t MayaFlux::Portal::Forma::Plot::place_label ( Surface surface,
std::shared_ptr< Buffers::FormaBuffer buf,
const LabelSpec spec,
uint32_t  relate_to = 0 
)

Place a text label element onto surface using a pre-built buffer.

buf must have been created with an additional_textures slot named "text" (or equivalent). Buffer construction is the caller's responsibility; Portal::Forma::plot() handles this automatically.

Parameters
surfaceTarget surface.
bufFormaBuffer with a texture slot. One buffer per label.
specLabel geometry and style.
relate_toIf non-zero, the produced element is related to this id.
Returns
Element id of the produced label element.

Definition at line 15 of file Plot.cpp.

20{
21 const auto render_bounds = spec.render_bounds.x > 0 && spec.render_bounds.y > 0
22 ? spec.render_bounds
23 : Kinesis::ndc_size_to_pixels(
24 { spec.bounds.width(), spec.bounds.height() },
25 surface.window()->get_state().current_width,
26 surface.window()->get_state().current_height);
27
28 Element el;
29 el.with_buffer(std::move(buf))
30 .with_bounds(spec.bounds)
31 .with_name(spec.name)
32 .with_text(spec.text,
34 .color = spec.color,
35 .render_bounds = render_bounds,
36 },
37 spec.bounds);
38
39 if (!spec.interactive)
40 el.non_interactive();
41
42 const uint32_t id = surface.layer().add(std::move(el));
43 if (relate_to != 0)
44 surface.layer().relate(relate_to, id);
45
46 return id;
47}
bool relate(uint32_t primary_id, uint32_t related_id)
Record that related_id belongs with primary_id.
Definition Layer.cpp:152
Slot add(Element element)
Add an element to the layer.
Definition Layer.cpp:9
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:126
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
float height() const noexcept
Definition Bounds.hpp:38
float width() const noexcept
Definition Bounds.hpp:37
Element & with_buffer(std::shared_ptr< Buffers::FormaBuffer > buf)
Attach a FormaBuffer as the rendered output for this region.
Definition Element.hpp:180
Element & with_bounds(Kinesis::AABB2D b)
Set the fast-reject AABB.
Definition Element.hpp:95
Element & non_interactive()
Exclude from hit testing.
Definition Element.hpp:253
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) })
Press text into a new GPU texture and bind it to the attached FormaBuffer.
Definition Element.cpp:51
Element & with_name(std::string n)
Set the human-readable name used in Lila introspection and debug output.
Definition Element.hpp:278
A bounded, renderable region on a window surface.
Definition Element.hpp:58
std::string name
Optional logical name for the eventual Element.
Definition PlotSpec.hpp:43
glm::uvec2 render_bounds
Optional text pixel/render size override.
Definition PlotSpec.hpp:56
bool interactive
Whether the eventual Element should participate in hit testing.
Definition PlotSpec.hpp:49
Construction parameters for press().
Definition InkPress.hpp:48

References MayaFlux::Portal::Forma::Layer::add(), MayaFlux::Portal::Forma::Plot::LabelSpec::bounds, MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Portal::Forma::Plot::LabelSpec::interactive, MayaFlux::Portal::Forma::Surface::layer(), MayaFlux::Portal::Forma::Plot::LabelSpec::name, MayaFlux::Kinesis::ndc_size_to_pixels(), MayaFlux::Portal::Forma::Element::non_interactive(), MayaFlux::Portal::Forma::Layer::relate(), MayaFlux::Portal::Forma::Plot::LabelSpec::render_bounds, MayaFlux::Portal::Forma::Plot::LabelSpec::text, MayaFlux::Kinesis::AABB2D::width(), MayaFlux::Portal::Forma::Surface::window(), 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().

+ Here is the call graph for this function: