(Window.MouseState e, Box root)
| 14 | public class Intersects { |
| 15 | |
| 16 | static public Box startAt(Window.MouseState e, Box root) { |
| 17 | Vec2 point = e == null ? null : new Vec2(e.mx, e.my); |
| 18 | |
| 19 | Optional<Box> hit = point == null ? Optional.empty() : root.breadthFirst(root.both()) |
| 20 | .filter(b -> frame(b) != null) |
| 21 | .filter(b -> !b.properties.isTrue(Box.hidden, false)) |
| 22 | .filter(b -> point == null || frame(b).intersects(point)) |
| 23 | .filter(x -> !x.properties.isTrue(Mouse.isSticky, false)) |
| 24 | .filter(x -> Planes.on(root, x)>=1) |
| 25 | .sorted((a, b) -> Float.compare(order(frame(a), a instanceof TextEditor), order(frame(b), b instanceof TextEditor))) |
| 26 | .findFirst(); |
| 27 | |
| 28 | Box startAt = hit.orElseGet(() -> root.breadthFirst(root.both()) |
| 29 | .filter(x -> x.properties.isTrue(Mouse.isSelected, false) && !x.properties.isTrue(Mouse.isSticky, false)) |
| 30 | .findFirst() |
| 31 | .orElseGet(() -> root)); |
| 32 | |
| 33 | return startAt; |
| 34 | |
| 35 | } |
| 36 | |
| 37 | |
| 38 | static protected Rect frame(Box hitBox) { |
no test coverage detected