(Box root)
| 60 | |
| 61 | static public final Dict.Prop<Boolean> nox = new Dict.Prop<>("_nox").type() |
| 62 | .toCanon() |
| 63 | .doc("'NO eXecution. Set to prevent option-clicking from running this box"); |
| 64 | |
| 65 | |
| 66 | public Chorder(Box root_unused) { |
| 67 | |
| 68 | properties.put(Planes.plane, "__always__"); |
| 69 | |
| 70 | properties.putToMap(Mouse.onMouseDown, "__chorder__", (e, button) -> { |
| 71 | if (button != 0) return null; |
| 72 | if (!e.after.keyboardState.isAltDown()) return null; |
| 73 | if (e.after.keyboardState.isShiftDown()) return null; |
| 74 | if (e.after.keyboardState.isSuperDown()) return null; |
| 75 | if (e.after.keyboardState.isControlDown()) 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 | Stream<Pair<Box, Rect>> fr = breadthFirst(both()).map(b -> new Pair<>(b, frame(b))) |
| 82 | .filter(b -> !b.first.properties.isTrue(nox, false)) |
| 83 | .filter(b -> b.second != null); |
| 84 | |
| 85 | List<Pair<Box, Rect>> frames = fr.collect(Collectors.toList()); |
| 86 | |
| 87 | Optional<Pair<Box, Rect>> hit = frames.stream() |
| 88 | .filter(b -> !b.first.properties.isTrue(Box.hidden, false)) |
| 89 | .filter(b -> b.second.intersects(point)) |
| 90 | .filter(b -> !b.first.properties.isTrue(nox, false)) |
| 91 | .sorted((a, b) -> Float.compare(order(a.second), order(b.second))) |
| 92 | .findFirst(); |
| 93 | |
| 94 | if (hit.isPresent()) { |
| 95 | return executeNowAt(e, point, hit.get().first); |
| 96 | } |
| 97 | |
| 98 | // we have an execution chord |
| 99 | |
| 100 | return chordAt(frames, point, e); |
| 101 | }); |
| 102 | |
| 103 | this.properties.put(begin, box -> { |
| 104 | try { |
| 105 | return ThreadSync2.callInMainThreadAndWait(() -> { |
| 106 | |
| 107 | Execution ex = getExecution(box, Execution.code); |
| 108 | if (ex != null) |
| 109 | ex.support(box, Execution.code).begin(box, getInitiator(box)); |
| 110 | |
| 111 | return () -> box.properties.computeIfAbsent(IsExecuting.executionCount, (k) -> 0) > 0; |
| 112 | }); |
| 113 | } catch (Exception e) { |
| 114 | return () -> false; |
| 115 | } |
| 116 | |
| 117 | }); |
| 118 | this.properties.put(beginAgain, box -> |
| 119 | { |
nothing calls this directly
no test coverage detected