14 [[nodiscard]] GeometryFn<bool> collapsible_header_geom(
19 glm::vec3 color_closed,
22 return [y_top, x_min, x_max, row_h, color_closed, color_open](
23 bool open, std::vector<uint8_t>&
out, Element& el) {
24 const float bot = y_top - row_h;
25 const glm::vec3 col =
open ? color_open : color_closed;
28 out.assign(
static_cast<size_t>(6) * stride, 0);
30 const glm::vec3 bl { x_min, bot, 0.F };
31 const glm::vec3 br { x_max, bot, 0.F };
32 const glm::vec3 tl { x_min, y_top, 0.F };
33 const glm::vec3 tr { x_max, y_top, 0.F };
35 auto write = [&](
size_t idx, glm::vec3 pos) {
36 auto* v =
out.data() + idx * stride;
37 std::memcpy(v, &pos, 12);
38 std::memcpy(v + 12, &col, 12);
48 el.bounds_hint = Kinesis::AABB2D {
49 .min = { x_min, bot },
50 .max = { x_max, y_top },
65 float x_min,
float x_max,
float row_h)
67 buf = std::move(in_buf);
70 const float y_top = advanced.
max.y;
73 auto open_state = std::make_shared<MappedState<bool>>();
80 mapped.
state = open_state;
91 [m = std::move(mapped),
open = open_state, surface, hid](uint32_t, glm::vec2)
mutable {
92 const bool next = !
open->value;
104 .render_bounds = dims,
109 el.bounds_hint = row_rect;
113 open_state->
id = hid;
115 auto repress = [el, surface, params, label_text =
m_label_text,
117 color_open =
m_color_open, x_min, x_max, row_h]()
mutable {
118 params->render_bounds =
row_pixel_dims(surface.window(), x_min, x_max, row_h);
119 params->background = {
open->value ? color_open : color_closed, 1.F };
120 el.set_text(label_text, *params);
124 [
open = open_state, surface, hid, repress](uint32_t, glm::vec2)
mutable {
125 const bool next = !
open->value;
127 for (
auto rel_id : surface.layer().related_ids(hid))
128 surface.layer().set_visible(rel_id, next);
132 surface.ctx().on_resize(hid,
133 [repress](uint32_t, uint32_t)
mutable { repress(); });
149 return place(std::move(in_buf), surface, cursor,
174 glm::vec3 color_closed,
175 glm::vec3 color_open,
183 .
place(std::move(buf), surface, cursor, x_min, x_max, row_h);
std::vector< float > * out
void on_press(uint32_t id, IO::MouseButtons btn, PressFn fn)
Called when a mouse button is pressed over an element.
void open(std::span< const float > mask, std::span< float > tmp, std::span< float > dst, uint32_t w, uint32_t h, uint32_t radius)
Morphological opening writing into dst.
uint32_t stride_bytes
Total bytes per vertex (stride in Vulkan terms) e.g., 3 floats (position) + 3 floats (normal) = 24 by...
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)
Axis-aligned bounding rectangle in a 2D coordinate space.
glm::vec4 color
RGBA color applied to all glyphs not covered by a span in spans.
Construction parameters for press().