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

Method button0

src/main/java/fieldbox/boxes/plugins/Topology.java:74–119  ·  view source on GitHub ↗
(Window.Event<Window.MouseState> e)

Source from the content-addressed store, hash-verified

72 }
73
74 protected Mouse.Dragger button0(Window.Event<Window.MouseState> e) {
75 if (!e.after.keyboardState.keysDown.contains(GLFW_KEY_T)) return null;
76
77 Optional<Drawing> drawing = this.find(Drawing.drawing, both())
78 .findFirst();
79 Vec2 point = new Vec2(e.after.mx, e.after.my);
80
81 Optional<Box> hit = breadthFirst(both()).filter(b -> frame(b) != null)
82 .filter(x -> !x.properties.isTrue(Box.hidden, false))
83 .filter(b -> frame(b).intersects(point))
84 .sorted((a, b) -> Float.compare(order(frame(a)), order(frame(b))))
85 .findFirst();
86
87 if (hit.isPresent()) {
88 e.properties.put(Window.consumed, true);
89
90 Box origin = hit.get();
91
92 return (e1, termination) -> {
93
94 Vec2 point1 = new Vec2(e1.after.mx, e1.after.my);
95
96 Optional<Box> hit1 = breadthFirst(both()).filter(x -> !x.properties.isTrue(Box.hidden, false))
97 .filter(b -> frame(b) != null)
98 .filter(b -> frame(b).intersects(point1))
99 .sorted((a, b) -> Float.compare(order(frame(a)), order(frame(b))))
100 .findFirst();
101
102 if (hit1.isPresent()) {
103 showCompleteDrag(origin, hit1.get());
104 if (termination) {
105 completeDrag(origin, hit1.get());
106 }
107 } else {
108 showIncompleteDrag(origin, point1);
109 if (termination) {
110 Topology.this.properties.removeFromMap(frameDrawing, "__ongoingDrag__");
111 }
112 }
113
114
115 return !termination;
116 };
117 }
118 return null;
119 }
120
121 protected void showIncompleteDrag(Box start, Vec2 to) {
122 this.properties.putToMap(frameDrawing, "__ongoingDrag__", (box) -> {

Callers 1

onMouseDownMethod · 0.95

Calls 15

frameMethod · 0.95
orderMethod · 0.95
showCompleteDragMethod · 0.95
completeDragMethod · 0.95
showIncompleteDragMethod · 0.95
breadthFirstMethod · 0.80
isTrueMethod · 0.80
isPresentMethod · 0.80
removeFromMapMethod · 0.80
getMethod · 0.65
containsMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected