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

◆ handle_path_form()

MAYAFLUX_API std::optional< Geometry::Form< std::vector< glm::vec2 > > > MayaFlux::Portal::Forma::handle_path_form ( const HandlePathInputs & input,
const RectPlacementInputs & placement,
std::string & error )
nodiscard

A Form of unit square points that a press grabs and a drag moves.

The state is the list of points, initially the input's. The hit region is the placement's rect. See Geometry::handle_path.

Definition at line 54 of file DragGeometry.cpp.

56{
57 if (input.points.size() < 2) {
58 error = "points needs at least two x y pairs";
59 return std::nullopt;
60 }
61 for (const glm::vec2 point : input.points) {
62 if (point.x < 0.F || point.x > 1.F || point.y < 0.F || point.y > 1.F) {
63 error = "points must lie in the unit square";
64 return std::nullopt;
65 }
66 }
67 if (!(input.thickness >= 0.F) || !(input.handle_size >= 0.F)) {
68 error = "thickness and handle_size may not be negative";
69 return std::nullopt;
70 }
71 if (!(input.grab_radius > 0.F)) {
72 error = "grab_radius needs to be positive";
73 return std::nullopt;
74 }
75 const auto region = region_of(placement, error);
76 if (!region)
77 return std::nullopt;
78
79 return Geometry::handle_path(*region, input.points.size(), input.path_color,
80 input.handle_color, input.thickness, input.handle_size, input.grab_radius);
81}
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
Form< std::vector< glm::vec2 > > handle_path(Kinesis::AABB2D bounds, size_t handles, glm::vec3 path_color, glm::vec3 handle_color, float thickness, float handle_size, float grab_radius, const std::function< glm::vec2()> &live_offset)
Geometry function for a path of draggable points in NDC space.
std::optional< Kinesis::AABB2D > region_of(const RectPlacementInputs &placement, std::string &error)
The surface region a rect placement covers.

References MayaFlux::Portal::Forma::HandlePathInputs::grab_radius, MayaFlux::Portal::Forma::HandlePathInputs::handle_color, MayaFlux::Portal::Forma::Geometry::handle_path(), handle_path_form(), MayaFlux::Portal::Forma::HandlePathInputs::handle_size, MayaFlux::Portal::Forma::HandlePathInputs::path_color, MayaFlux::Portal::Forma::HandlePathInputs::points, region_of(), and MayaFlux::Portal::Forma::HandlePathInputs::thickness.

Referenced by expose_handle_path(), and handle_path_form().

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