31 std::function<T(glm::vec2)> project,
34 if (!state || !project)
39 [state = std::move(state), project = std::move(project)](glm::vec2 ndc) {
40 state->write(project(ndc));
62 const std::shared_ptr<
MappedState<std::vector<float>>>& state,
74 std::function<T(glm::vec2)> project,
77 return [project = std::move(project), btn](
78 Context& ctx, uint32_t id, std::shared_ptr<MappedState<T>> state) {
79 wire_drag<T>(ctx,
id, std::move(state), project, btn);
88 return [btn](
Context& ctx, uint32_t id, std::shared_ptr<MappedState<bool>> state) {
89 ctx.
on_press(
id, btn, [state = std::move(state)](uint32_t, glm::vec2) {
90 state->write(!state->value);
100 return [bounds](
Context& ctx, uint32_t id,
101 const std::shared_ptr<MappedState<std::vector<float>>>& state) {
114 return [](
Context& ctx, uint32_t id, std::shared_ptr<MappedState<glm::vec2>> state) {
115 ctx.
on_move(
id, [state = std::move(state)](uint32_t, glm::vec2 ndc) {
147 glm::vec3 track_color = glm::vec3(0.3F),
148 glm::vec3 handle_color = glm::vec3(0.9F),
149 const std::function<glm::vec2()>& live_offset = {});
175 glm::vec3 track_color = glm::vec3(0.3F),
176 glm::vec3 handle_color = glm::vec3(0.9F),
177 const std::function<glm::vec2()>& live_offset = {});
199[[nodiscard]] MAYAFLUX_API Form<float>
radial(
203 glm::vec3
color = glm::vec3(0.9F),
204 const std::function<glm::vec2()>& live_offset = {});
225[[nodiscard]] MAYAFLUX_API Form<glm::vec2>
point(
226 glm::vec3
color = glm::vec3(1.0F),
228 float hit_radius = 0.04F);
245 Kinesis::AABB2D bounds,
246 glm::vec3
color = glm::vec3(0.9F),
248 const std::function<glm::vec2()>& live_offset = {});
289 std::span<const glm::vec2> path,
290 FormaTarget handle_buf,
291 float half_thickness = 0.02F,
292 glm::vec3 track_color = glm::vec3(0.3F),
293 glm::vec3 fill_color = glm::vec3(0.2F, 0.6F, 1.0F),
294 glm::vec3 handle_color = glm::vec3(0.95F),
295 float handle_size = 10.0F,
296 const std::function<glm::vec2()>& live_offset = {});
326[[nodiscard]] MAYAFLUX_API Form<bool>
toggle(
327 Kinesis::AABB2D region,
328 glm::vec3 color_off = glm::vec3(0.25F),
329 glm::vec3 color_on = glm::vec3(0.2F, 0.7F, 0.4F),
330 const std::function<glm::vec2()>& live_offset = {});
358 Kinesis::AABB2D bounds,
359 bool horizontal =
true,
360 glm::vec3 fill_color = glm::vec3(0.2F, 0.7F, 0.3F),
361 glm::vec3 track_color = glm::vec3(0.15F),
362 const std::function<glm::vec2()>& live_offset = {});
383[[nodiscard]] MAYAFLUX_API Form<glm::vec2>
crosshair(
384 float arm_len = 0.04F,
385 glm::vec3
color = glm::vec3(0.9F),
386 float thickness = 1.F,
387 float hit_radius = 0.05F);
432 Kinesis::AABB2D bounds,
433 glm::vec3
color = glm::vec3(0.8F),
434 float thickness = 1.5F,
435 const std::function<glm::vec2()>& live_offset = {},
468 Kinesis::AABB2D track,
469 glm::vec3
color = glm::vec3(0.5F, 0.5F, 0.55F));
Illustrative geometry functions for common Mapped use cases.
NDC-to-value mappings, inverse to the forward placement performed by geometry functions.
Context & wire_drag(uint32_t id, std::function< void(glm::vec2)> sink, IO::MouseButtons btn=IO::MouseButtons::Left)
Register a drag handler receiving only the cursor position.
void on_move(uint32_t id, MoveFn fn)
Called each move event while the cursor is over an element.
void on_press(uint32_t id, IO::MouseButtons btn, PressFn fn)
Called when a mouse button is pressed over an element.
Event wiring between a Layer and a window surface.
MouseButtons
Enumeration for mouse buttons.
Axis-aligned bounding rectangle in a 2D coordinate space.