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

Method startAt

src/main/java/fieldbox/boxes/Intersects.java:16–35  ·  view source on GitHub ↗
(Window.MouseState e, Box root)

Source from the content-addressed store, hash-verified

14public 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) {

Callers 6

MarkingMenusMethod · 0.95
dispatchMethod · 0.95
dispatchMethod · 0.95
KeyboardShortcutsMethod · 0.95
DoubleClickToRenameMethod · 0.95
button0Method · 0.80

Calls 9

frameMethod · 0.95
onMethod · 0.95
orderMethod · 0.95
emptyMethod · 0.80
breadthFirstMethod · 0.80
isTrueMethod · 0.80
bothMethod · 0.45
intersectsMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected