Class TitleControl
java.lang.Object
dev.myriadclient.api.ui.TitleControl
A control in a window's title bar, beside its own float and close buttons: a switch (a control panel's on/off) or an
icon button (Addons' "check for updates"). Return them from
Panel.titleControls(); make them once (a field)
and return the same ones, so a switch's slide carries on between frames. Hovering shows the tooltip. In a narrow
window the controls that would crowd the title out are left off.
private final List<TitleControl> controls = List.of(
TitleControl.toggle(module::isEnabled, module::setEnabled, () -> "Turn " + module.name() + " on or off"),
TitleControl.button(() -> Icons.REFRESH, this::reload, () -> "Reload"));
@Override
public List<TitleControl> titleControls() { return controls; }
-
Method Summary
Modifier and TypeMethodDescriptionstatic TitleControlA Nerd Font icon (Icons) that runsactionwhen clicked.voidclick()Core's: a click on it.icon()Core's: a button's glyph, empty for a switch.booleanisOn()Core's: a switch's state.booleanisToggle()Core's: whether this is a switch rather than a button.booleanCore's: whether it shows this frame.knob()Core's: a switch's knob animation.static TitleControlAn on/off switch showingon; clicking it callssetwith the opposite.@Nullable Stringtooltip()Core's: the tooltip, or null.visible(BooleanSupplier visible) Shown only whilevisiblesays so (read every frame).floatwidth()Core's: its width in the title bar, in UI units.
-
Method Details
-
toggle
public static TitleControl toggle(BooleanSupplier on, Consumer<Boolean> set, Supplier<@Nullable String> tooltip) An on/off switch showingon; clicking it callssetwith the opposite. The suppliers are read every frame.tooltipmay return null for none. -
button
-
visible
Shown only whilevisiblesays so (read every frame). Returns this control. -
isToggle
@Internal public boolean isToggle()Core's: whether this is a switch rather than a button. -
isVisible
@Internal public boolean isVisible()Core's: whether it shows this frame. -
isOn
@Internal public boolean isOn()Core's: a switch's state. -
icon
Core's: a button's glyph, empty for a switch. -
tooltip
Core's: the tooltip, or null. -
width
@Internal public float width()Core's: its width in the title bar, in UI units. -
knob
Core's: a switch's knob animation. -
click
@Internal public void click()Core's: a click on it.
-