MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / FrameManipulation

Class FrameManipulation

src/main/java/fieldbox/boxes/FrameManipulation.java:31–650  ·  view source on GitHub ↗

Plugin: Adds the ability to drag boxes around with the mouse and change their sizes with their edges. Provides textual feedback when this happens. Also addes the ability to translate the canvas around with the middle mouse button (button 2).

Source from the content-addressed store, hash-verified

29import static org.lwjgl.glfw.GLFW.GLFW_KEY_TAB;
30
31/**
32 * Plugin: Adds the ability to drag boxes around with the mouse and change their sizes with their edges. Provides textual feedback when this happens.
33 * <p>
34 * Also addes the ability to translate the canvas around with the middle mouse button (button 2).
35 */
36public class FrameManipulation extends Box {
37
38 static public boolean noDraggingUnlessShift = false;
39
40 static public final Dict.Prop<Boolean> lockWidth = new Dict.Prop<>("lockWidth").type()
41 .toCanon()
42 .doc("set to true to disable changes to the width of this box via the mouse");
43 static public final Dict.Prop<Boolean> lockHeight = new Dict.Prop<>("lockHeight").type()
44 .toCanon()
45 .doc("set to true to disable changes to the height of this box via the mouse");
46 static public final Dict.Prop<Boolean> lockX = new Dict.Prop<>("lockX").type()
47 .toCanon()
48 .doc("set to true to disable changes to the x-position of this box via the mouse");
49 static public final Dict.Prop<Boolean> lockY = new Dict.Prop<>("lockY").type()
50 .toCanon()
51 .doc("set to true to disable changes to the y-position of this box via the mouse");
52
53 static public final Dict.Prop<Number> maxWidth = new Dict.Prop<>("maxWidth").type()
54 .toCanon()
55 .doc("set to this value to constrain the width of this box");
56 static public final Dict.Prop<Number> maxHeight = new Dict.Prop<>("maxHeight").type()
57 .toCanon()
58 .doc("set to this value to constrain the height of this box");
59 static public final Dict.Prop<Number> minWidth = new Dict.Prop<>("minWidth").type()
60 .toCanon()
61 .doc("set to this value to constrain the width of this box");
62 static public final Dict.Prop<Number> minHeight = new Dict.Prop<>("minHeight").type()
63 .toCanon()
64 .doc("set to this value to constrain the height of this box");
65
66 static public final Dict.Prop<Number> movesWithParent = new Dict.Prop<>("movesWithParent").type()
67 .toCanon()
68 .doc("set this to true to make this box move whenever its parent moves");
69
70
71 static public final Dict.Prop<FunctionOfBoxValued<List<Box>>> selection = new Dict.Prop<>("selection").toCanon()
72 .type()
73 .doc("the list of boxes that are selected");
74
75 private final Box root;
76
77 SimpleSnapHelper helper;
78 List<FLine> extraAnnotations = Collections.emptyList();
79
80 public FrameManipulation(Box root) {
81 this.root = root;
82 this.helper = new SimpleSnapHelper(root, 10);
83 this.properties.put(plane, "__always__");
84 this.properties.put(selection, x -> breadthFirst(both()).filter(q -> (q.properties.isTrue(Mouse.isSelected, false) && !q.properties.isTrue(Mouse.isSticky, false)))
85 .collect(Collectors.toList()));
86 this.properties.putToMap(Mouse.onMouseDown, "__frameManipulation__", this::onMouseDown);
87 this.properties.putToMap(Mouse.onMouseMove, "__frameManipulation__", e -> {
88

Callers

nothing calls this directly

Calls 3

docMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected