(Window.Event<Window.MouseState> e)
| 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) -> { |
no test coverage detected