Tunal/crates/tunal/ui/dialogs/setting-rows.slint
astar76 d1c8f69a03 keymap: one dispatch path for shortcuts, editor page, new window, tab menu
Commands with default chords, [shortcuts] overrides in settings.toml, conflict
detection; Shortcuts settings page with capture, Replace/Cancel and resets.
Ctrl+N opens a new window, tab right-click menu, closed-tab stack (10).
Probe gains key and middle-button modes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 10:51:00 -06:00

145 lines
3.5 KiB
Text

import { Theme } from "../theme.slint";
import { Chip } from "../components/chip.slint";
import { Icons } from "../components/icon.slint";
import { IconButton } from "../components/icon-button.slint";
// The rows settings pages are made of.
// One choice out of a few, as a row of chips.
export component Choices inherits HorizontalLayout {
in property <[string]> names;
in property <int> current;
callback picked(int);
spacing: Theme.space-2;
alignment: start;
for name[i] in root.names: Chip {
property <bool> sel: i == root.current;
text: name;
checked: self.sel;
changed sel => {
self.checked = self.sel;
}
clicked => {
root.picked(i);
self.checked = true;
}
}
}
// A setting: its name and a line about it, the control on the right.
export component Setting inherits HorizontalLayout {
in property <string> title;
in property <string> hint;
spacing: Theme.space-4;
height: 52px;
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: root.title;
color: Theme.on-surface;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
overflow: elide;
}
if root.hint != "": Text {
text: root.hint;
color: Theme.on-surface-variant;
font-size: Theme.body-small.size;
font-weight: Theme.body-small.weight;
overflow: elide;
}
}
VerticalLayout {
alignment: center;
@children
}
}
// A whole number with minus and plus buttons.
export component Stepper inherits HorizontalLayout {
in property <int> value;
in property <int> lo;
in property <int> hi;
in property <int> step;
in property <string> unit;
callback picked(int);
spacing: Theme.space-2;
VerticalLayout {
alignment: center;
IconButton {
icon: Icons.remove;
tonal: true;
size: 32px;
icon-size: 18px;
enabled: root.value > root.lo;
tooltip: "Less";
clicked => {
root.picked(max(root.lo, root.value - root.step));
}
}
}
Text {
text: "\{root.value} \{root.unit}";
width: 72px;
color: Theme.on-surface;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
horizontal-alignment: center;
vertical-alignment: center;
}
VerticalLayout {
alignment: center;
IconButton {
icon: Icons.add;
tonal: true;
size: 32px;
icon-size: 18px;
enabled: root.value < root.hi;
tooltip: "More";
clicked => {
root.picked(min(root.hi, root.value + root.step));
}
}
}
}
// A choice with its name above the chips.
export component ChoiceSetting inherits VerticalLayout {
in property <string> title;
in property <[string]> names;
in property <int> current;
callback picked(int);
spacing: Theme.space-2;
padding-top: Theme.space-2;
padding-bottom: Theme.space-2;
Text {
text: root.title;
color: Theme.on-surface;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
}
Choices {
names: root.names;
current: root.current;
picked(i) => {
root.picked(i);
}
}
}