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

◆ make_value_row() [2/2]

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 const Kinesis::AABB2D row_rect { .min = { x_min, bot }, .max = { x_max, top } };
88
89 const uint32_t stride = Kakshya::VertexLayout::for_meshes().stride_bytes;
90 std::vector<uint8_t> bytes(static_cast<size_t>(12) * stride, 0);
91 write_row_quad(bytes, x_min, x_max, bot, top, bg);
92 row_buf.buf->submit(bytes);
93
94 auto staging = Buffers::create_image_staging_buffer(
95 row_buf.text_image->get_size_bytes());
96
97 Portal::Text::PressParams params {
98 .color = { 1.F, 1.F, 1.F, 1.F },
99 };
100
101 Element el;
102 el.buffer = row_buf.buf;
103 el.bounds_hint = row_rect;
104 el.interactive = false;
105 el.name = spec.label;
106 const uint32_t id = surface.layer().add(el);
107
108 Link link(
109 [] { },
110 [reader = spec.reader,
111 label = spec.label,
112 text_image = row_buf.text_image,
113 buf = row_buf.buf,
114 staging,
115 params]() mutable {
116 if (!buf || !reader)
117 return;
118
119 Portal::Text::repress(text_image,
120 label + ": " + reader(),
121 params, staging);
122 buf->bind_texture(0, text_image);
123 });
124
125 return ValueRow {
126 .element_id = id,
127 .buf = std::move(row_buf.buf),
128 .text = std::move(row_buf.text_image),
129 .link = std::move(link),
130 .row_bounds = row_rect,
131 };
132}
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

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(), and make_value_row().

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