Extends FLineInteraction to include, essentially, a node editor. Unlike Field1 this is going to be much more pluggable
| 22 | |
| 23 | static public final Dict.Prop<Boolean> editable = new Dict.Prop<Boolean>("editable").type() |
| 24 | .toCanon() |
| 25 | .doc("Set this to true on an FLine to have it be editable by the handles system"); |
| 26 | static public final Dict.Prop<Handles> handles = new Dict.Prop<Handles>("handles").type() |
| 27 | .toCanon() |
| 28 | .doc("Provides customizeable node editing for FLines"); |
| 29 | |
| 30 | static public final Dict.Prop<IdempotencyMap<Draggable>> draggables = new Dict.Prop<>("draggables").type() |
| 31 | .toCanon() |
| 32 | .doc("Collection of Draggable instances that offer interactive elements on the canvas. Can be inserted on FLine nodes") |
| 33 | .autoConstructs(() -> new IdempotencyMap<Draggable>(Draggable.class)); |
| 34 | static public final Dict.Prop<Boolean> hasDraggables = new Dict.Prop<>("hasDraggables").type() |
| 35 | .toCanon() |
| 36 | .doc("set to mark that an FLine contains Draggables inside it, and that it should be searched for draggable Nodes"); |
| 37 | |
| 38 | static public final Dict.Prop<Viewport> inside = new Dict.Prop<>("inside").type().toCanon().set(Dict.domain, "flines"); |
| 39 | |
| 40 | |
| 41 | public interface SetAndConstrain { |
| 42 | Vec3 apply(Vec3 next, Vec3 previous, Vec3 initial); |
| 43 | } |
| 44 | |
| 45 | static public class Draggable { |
| 46 | public Vec3 cachePosition = null; |
| 47 | public Vec3 initialPosition = null; |
| 48 | public Vec3 sourcePosition = null; |
| 49 | |
| 50 | public String name; |
| 51 | |
| 52 | public boolean selected = false; |
| 53 | |
| 54 | public Supplier<Vec3> get; |
| 55 | public SetAndConstrain setAndConstrain; |
| 56 | public Function<Boolean, Boolean> select; |
| 57 | public Supplier<Collection<FLine>> appearance; |
| 58 | public Function<Vec3, Vec3> finisher; |
| 59 | public Runnable commit; |
| 60 | |
| 61 | protected FLine source; |
| 62 | |
| 63 | public Draggable(Supplier<Vec3> get, SetAndConstrain setAndConstrain, Function<Boolean, Boolean> select, Supplier<Collection<FLine>> appearance, Function<Vec3, Vec3> finisher, |
| 64 | Runnable commit) { |
| 65 | this.get = get; |
| 66 | this.setAndConstrain = setAndConstrain; |
| 67 | this.select = select; |
| 68 | this.appearance = appearance; |
| 69 | this.finisher = finisher; |
| 70 | this.commit = commit; |
| 71 | init(); |
| 72 | } |
| 73 | |
| 74 | public Draggable(FLine.Node on, SetAndConstrain setAndConstrain, Function<Boolean, Boolean> select, Supplier<Collection<FLine>> appearance, Function<Vec3, Vec3> finisher, Runnable |
| 75 | commit) { |
| 76 | this.get = () -> on.to; |
| 77 | this.setAndConstrain = (next, previous, initial) -> { |
| 78 | Vec3 v = setAndConstrain.apply(next, previous, initial); |
| 79 | on.to.set(v); |
| 80 | return v; |
| 81 | }; |
nothing calls this directly
no test coverage detected