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

Method button0

src/main/java/fieldcef/plugins/Pads.java:97–144  ·  view source on GitHub ↗
(Window.Event<Window.MouseState> e)

Source from the content-addressed store, hash-verified

95 protected Mouse.Dragger button0(Window.Event<Window.MouseState> e) {
96 if (!e.after.keyboardState.keysDown.contains(GLFW_KEY_P)) return null;
97
98 Optional<Drawing> drawing = this.find(Drawing.drawing, both())
99 .findFirst();
100 Vec2 point = new Vec2(e.after.mx, e.after.my);
101
102 Optional<Box> hit = breadthFirst(both()).filter(b -> frame(b) != null)
103 .filter(x -> !x.properties.isTrue(Box.hidden, false))
104 .filter(b -> frame(b).intersects(point))
105 .filter(b -> b.properties.isTrue(Pads.isPad, false))
106 .sorted((a, b) -> Float.compare(order(frame(a)), order(frame(b))))
107 .findFirst();
108
109 if (hit.isPresent()) {
110 e.properties.put(Window.consumed, true);
111
112 Box origin = hit.get();
113
114 return (e1, termination) -> {
115
116 Vec2 point1 = new Vec2(e1.after.mx, e1.after.my);
117
118 Optional<Box> hit1 = breadthFirst(both()).filter(x -> !x.properties.isTrue(Box.hidden, false))
119 .filter(b -> frame(b) != null)
120 .filter(b -> frame(b).intersects(point1))
121 .filter(b -> b.properties.isTrue(Pads.isPad, false))
122 .sorted((a, b) -> Float.compare(order(frame(a)), order(frame(b))))
123 .findFirst();
124
125 if (hit1.isPresent()) {
126 showCompleteDrag(origin, hit1.get());
127 if (termination) {
128 completeDrag(origin, hit1.get());
129 }
130 } else {
131 showIncompleteDrag(origin, point1);
132 if (termination) {
133 Pads.this.properties.removeFromMap(frameDrawing, "__ongoingDrag__");
134 }
135 }
136
137
138 return !termination;
139 };
140 }
141 return null;
142 }
143
144 protected void showIncompleteDrag(Box start, Vec2 to) {
145 this.properties.putToMap(frameDrawing, "__ongoingDrag__", (box) -> {
146
147 Rect f1 = frame(start);

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