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

◆ make_value_row()

ValueRow MayaFlux::Portal::Forma::make_value_row ( const ValueSpec spec,
RowBuffer  row_buf,
Surface surface,
LayoutCursor cursor,
float  x_min,
float  x_max,
float  row_h,
glm::vec3  bg = glm::vec3(0.15F) 
)

Construct one labeled value row, advance the cursor, and return it.

The returned row's link reads spec.reader each tick, represses "label: value" into the text image, and binds the image to the row's FormaBuffer. The buffer and text image are pre-created by the caller and travel together as row_buf.

Parameters
specLabel and reader for the row.
row_bufPre-created buffer and bound text image.
surfaceSurface to register the row on.
cursorLayout cursor. Advanced by row_h on return.
x_minLeft edge in NDC.
x_maxRight edge in NDC.
row_hRow height in NDC units.
bgBackground color for the row quad.

Definition at line 76 of file QueryUtils.cpp.

83{
84 const float top = cursor.y();
85 const float bot = top - row_h;
86 cursor.advance(row_h);
87
88 const uint32_t stride = Kakshya::VertexLayout::for_meshes().stride_bytes;
89 std::vector<uint8_t> bytes(static_cast<size_t>(12) * stride, 0);
90 write_row_quad(bytes, x_min, x_max, bot, top, bg);
91 row_buf.buf->submit(bytes);
92
93 auto staging = Buffers::create_image_staging_buffer(
94 row_buf.text_image->get_size_bytes());
95
97 .color = { 1.F, 1.F, 1.F, 1.F },
98 };
99
100 Element el;
101 el.buffer = row_buf.buf;
102 el.bounds_hint = Kinesis::AABB2D { .min = { x_min, bot }, .max = { x_max, top } };
103 el.interactive = false;
104 el.name = spec.label;
105 const uint32_t id = surface.layer().add(el);
106
107 Link link(
108 [] { },
109 [reader = spec.reader,
110 label = spec.label,
111 text_image = row_buf.text_image,
112 buf = row_buf.buf,
113 staging,
114 params]() mutable {
115 if (!buf || !reader)
116 return;
117
118 Portal::Text::repress(text_image,
119 label + ": " + reader(),
120 params, staging);
121 buf->bind_texture(0, text_image);
122 });
123
124 return ValueRow {
125 .element_id = id,
126 .buf = std::move(row_buf.buf),
127 .text = std::move(row_buf.text_image),
128 .link = std::move(link),
129 };
130}
Slot add(Element element)
Add an element to the layer.
Definition Layer.cpp:9
Kinesis::AABB2D advance(float height)
Advance the cursor downward by height and return the NDC AABB occupied by the primitive just placed.
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:21
std::shared_ptr< Buffers::FormaBuffer > buf
std::shared_ptr< Core::VKImage > text_image
std::function< std::string()> reader
glm::vec4 color
RGBA color applied to all glyphs.
Definition InkPress.hpp:53
Construction parameters for press().
Definition InkPress.hpp:48

References MayaFlux::Portal::Forma::Layer::add(), MayaFlux::Portal::Forma::LayoutCursor::advance(), MayaFlux::Portal::Forma::Element::bounds_hint, MayaFlux::Portal::Forma::RowBuffer::buf, MayaFlux::Portal::Forma::Element::buffer, MayaFlux::Portal::Text::PressParams::color, MayaFlux::Buffers::create_image_staging_buffer(), MayaFlux::Portal::Forma::ValueRow::element_id, MayaFlux::Kakshya::VertexLayout::for_meshes(), MayaFlux::Portal::Forma::Element::interactive, MayaFlux::Portal::Forma::ValueSpec::label, MayaFlux::Portal::Forma::Surface::layer(), MayaFlux::Kinesis::AABB2D::min, MayaFlux::Portal::Forma::Element::name, MayaFlux::Portal::Forma::ValueSpec::reader, MayaFlux::Portal::Text::repress(), MayaFlux::Kakshya::VertexLayout::stride_bytes, MayaFlux::Portal::Forma::RowBuffer::text_image, and MayaFlux::Portal::Forma::LayoutCursor::y().

Referenced by make_value_group().

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