import { Nine, Label, Theme } from "base.slint";
import { Pieces } from "pieces.slint";
// `tooltip_frame` (style.lua): 8 px corners, 0.88 opaque base plus a half-scale black outer shadow; text is the
// default 14 px label. Measured against docs/reference/game-dependency-tooltip.png: 28 px high, text 8 px in.
export component GameTooltip {
in property <string> text;
// 0: lines break only at explicit line breaks (Manage). Above 0: word-wrap inside this overall width (filter descriptions).
in property <length> wrap-width: 0px;
property <length> text-width: root.wrap-width > 0px ? min(label.preferred-width, root.wrap-width - 16px) : label.preferred-width;
width: root.text-width + 16px;
height: max(28px, label.preferred-height + 7px);
Nine { x: -4px; y: -4px; width: root.width + 8px; height: root.height + 8px; source: Pieces.tooltip-frame-default-shadow; }
Nine { width: root.width; height: root.height; source: Pieces.tooltip-frame-default-base; }
label := Label { x: 8px; y: 0px; width: root.text-width; height: root.height; vertical-alignment: center; text: root.text; wrap: root.wrap-width > 0px ? word-wrap : no-wrap; }
}
// core.cfg [gui] search-with-focus = "Search (__1__)", the key text from [control-keys] control = "Control" + " + F".
export global Strings {
out property <string> search-before: "Search (";
out property <string> search-key: "Control + F";
out property <string> search-after: ")";
}
// Same frame as GameTooltip; the key is drawn in the game's blue (gui_color.blue, #80cef0).
export component SearchTooltip {
width: before.preferred-width + key.preferred-width + after.preferred-width + 16px;
height: 28px;
Nine { x: -4px; y: -4px; width: root.width + 8px; height: root.height + 8px; source: Pieces.tooltip-frame-default-shadow; }
Nine { width: root.width; height: root.height; source: Pieces.tooltip-frame-default-base; }
before := Label { x: 8px; y: 0px; height: root.height; vertical-alignment: center; text: Strings.search-before; }
key := Label { x: before.x + before.preferred-width; y: 0px; height: root.height; vertical-alignment: center; text: Strings.search-key; color: Theme.link; }
after := Label { x: key.x + key.preferred-width; y: 0px; height: root.height; vertical-alignment: center; text: Strings.search-after; }
}