30 std::function<T(glm::vec2)> project,
33 if (!state || !project)
38 [state = std::move(state), project = std::move(project)](glm::vec2 ndc) {
39 state->write(project(ndc));
61 std::shared_ptr<
MappedState<std::vector<float>>> state,
73 std::function<T(glm::vec2)> project,
76 return [project = std::move(project), btn](
77 Context& ctx, uint32_t id, std::shared_ptr<MappedState<T>> state) {
78 wire_drag<T>(ctx,
id, std::move(state), project, btn);
87 return [btn](
Context& ctx, uint32_t id, std::shared_ptr<MappedState<bool>> state) {
88 ctx.
on_press(
id, btn, [state = std::move(state)](uint32_t, glm::vec2) {
89 state->write(!state->value);
99 return [bounds](
Context& ctx, uint32_t id,
100 std::shared_ptr<MappedState<std::vector<float>>> state) {
113 return [](
Context& ctx, uint32_t id, std::shared_ptr<MappedState<glm::vec2>> state) {
114 ctx.
on_move(
id, [state = std::move(state)](uint32_t, glm::vec2 ndc) {
143 glm::vec3 track_color = glm::vec3(0.3F),
144 glm::vec3 handle_color = glm::vec3(0.9F));
169 glm::vec3 track_color = glm::vec3(0.3F),
170 glm::vec3 handle_color = glm::vec3(0.9F));
191[[nodiscard]] MAYAFLUX_API Form<float>
radial(
195 glm::vec3 color = glm::vec3(0.9F));
216[[nodiscard]] MAYAFLUX_API Form<glm::vec2>
point(
217 glm::vec3 color = glm::vec3(1.0F),
219 float hit_radius = 0.04F);
236 glm::vec3 color = glm::vec3(0.9F),
277 std::span<const glm::vec2> path,
278 std::shared_ptr<Buffers::FormaBuffer> handle_buf,
279 float half_thickness = 0.02F,
280 glm::vec3 track_color = glm::vec3(0.3F),
281 glm::vec3 fill_color = glm::vec3(0.2F, 0.6F, 1.0F),
282 glm::vec3 handle_color = glm::vec3(0.95F),
283 float handle_size = 10.0F);
310[[nodiscard]] MAYAFLUX_API Form<bool>
toggle(
312 glm::vec3 color_off = glm::vec3(0.25F),
313 glm::vec3 color_on = glm::vec3(0.2F, 0.7F, 0.4F));
341 bool horizontal =
true,
342 glm::vec3 fill_color = glm::vec3(0.2F, 0.7F, 0.3F),
343 glm::vec3 track_color = glm::vec3(0.15F));
364[[nodiscard]] MAYAFLUX_API Form<glm::vec2>
crosshair(
365 float arm_len = 0.04F,
366 glm::vec3 color = glm::vec3(0.9F),
367 float thickness = 1.F,
368 float hit_radius = 0.05F);
407 glm::vec3 color = glm::vec3(0.8F),
408 float thickness = 1.5F);
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.