Drawing over buttons
One picture across several keys, or the entire deck.
With the overlay permission, plugin.overlays draws one picture over several slots, or the entire
deck, on top of the user's buttons (which keep working):
const alarm = plugin.action({
id: "alarm",
name: "Alarm",
permissions: [Permissions.overlay],
settings: { slots: setting.slots("Where") },
run: ({ settings, plugin }) => {
plugin.overlays.show("alarm", {
slots: settings.slots, // ["key:0", "key:1", "window"]; empty or left out: the entire deck
gaps: "close",
content: ({ width, rows }) => {
const { size, lines } = layoutText("Time to go", { width, rows });
return (
<div style={{ display: "flex", width: "100%", height: "100%", background: "#b91c1c" }}>
{lines.map(({ text, start, ...place }) => (
<div
key={start}
style={{ display: "flex", position: "absolute", fontSize: size, ...place }}
>
{text}
</div>
))}
</div>
);
},
});
return { undo: () => plugin.overlays.hide("alarm") };
},
});contentgets the size of the whole overlay. Every slot draws all of it and shows its own part, so it has to look the same in each: keep state outside, or read it withuseHostStateand the other hooks above.gaps: "keep"(the default) lets the picture run on behind the space between keys, as through a window."close"draws the slots as if they touched, so no letters are lost.rowsare the rows of keys and the window.layoutTextbreaks text into lines, picks the largest size that fits, and keeps every line within one row.fitTextonly gives the size, for one box.pagelimits it to one page. Returnnullfromcontentwhile there is nothing to show.- Showing another under the same id replaces it. All of them go when the plugin stops; show them
again in
activateif they should survive a restart.