import { UiCue } from "audio.slint";
import { Button } from "button.slint";
import { Icons } from "icons.slint";
import { Theme } from "base.slint";
export component ToolButton {
in property <string> icon: "search";
in property <string> kind: "grey";
in property <string> state: "auto";
in property <bool> enabled: true;
in property <bool> transparent-background;
callback clicked();
// Pointer over the button: the view draws its tooltip (it must paint over the neighbouring panes).
callback hover-changed(bool);
out property <bool> hovered: face.hovered;
changed hovered => { root.hover-changed(root.hovered); }
preferred-width: 28px; preferred-height: 28px;
face := Button { sound: UiCue.tool; width: root.width; height: root.height; kind: root.kind; state: root.state; enabled: root.enabled; transparent-background: root.transparent-background; clicked => { root.clicked(); } }
Image {
width: 16px; height: 16px;
x: (root.width - self.width) / 2; y: (root.height - self.height) / 2 + (root.state == "clicked" ? 1px : 0px);
source: root.icon == "save" ? @image-url("../../../assets/ui/save.svg") : root.icon == "refresh" ? Icons.refresh : root.icon == "trash" ? Icons.trash : root.icon == "close" ? Icons.close : root.icon == "download" ? Icons.download : Icons.search;
colorize: root.icon == "close" ? Theme.black : transparent;
opacity: root.enabled ? 1 : 0.5; image-rendering: pixelated;
}
}