| 4 | import fieldbox.boxes.Box; |
| 5 | |
| 6 | public class SimpleTweaks extends Box { |
| 7 | |
| 8 | static public final Dict.Prop<FunctionOfBox<Boolean>> applyTweaks = new Dict.Prop<>("applyTweaks").type().toCanon().doc("call `_.applyTweaks()` to make `FLine`s in this box that have been " + |
| 9 | "marked as `line.tweaky = true` hand editable, and to apply their edits"); |
| 10 | static public final Dict.Prop<FunctionOfBox<Boolean>> clearTweaks = new Dict.Prop<>("clearTweaks").type().toCanon().doc("call `_.clearTweaks()` to clear any tweaks applied to lines in this" + |
| 11 | " box"); |
| 12 | |
| 13 | static public final Dict.Prop<String> _simpleTweaks = new Dict.Prop<>("_simpleTweaks").type().toCanon().autoConstructs(() -> ""); |
| 14 | static public final Dict.Prop<Boolean> tweaky = new Dict.Prop<>("tweaky").type().toCanon(); |
| 15 | |
| 16 | String tweakNow = BoxDefaultCode.findSource(this.getClass(), "tweakNow"); |
| 17 | |
| 18 | public SimpleTweaks(Box root) { |
| 19 | |
| 20 | this.properties.put(applyTweaks, (box) -> { |
| 21 | box.find(Exec.exec, box.upwards()).findFirst().ifPresent(x -> x.apply(box, tweakNow)); |
| 22 | return true; |
| 23 | }); |
| 24 | this.properties.put(clearTweaks, (box) -> { |
| 25 | box.properties.put(_simpleTweaks, ""); |
| 26 | return true; |
| 27 | }); |
| 28 | } |
| 29 | } |
nothing calls this directly
no test coverage detected