The single 1700-line app.slint becomes a design system and screens that later waves can compose: - theme.slint: colour, radius, spacing and type tokens (dark and light, a runtime font scale); icons.slint: Lucide icons as tintable images. - components/: Button, IconButton, TextField, SearchBox, Select, Toggle, Slider, SegmentedTabs, Avatar, badges, Card, Meter, NavItem, ListItem, PopupMenu, Tooltip, Modal, Toast, ResizeHandle, Spinner, RichText and the EmojiPicker. - shells/: the desktop frame (server rail, top bar, sidebar with the user card) and the phone frame with a bottom navigation, switched at a breakpoint from the settings. - screens/: today's screens re-skinned (channels, chat, streams panel and viewer, settings page, home, dialogs, phone pages); all callbacks and properties keep their behaviour. Navigation state is the Nav global. On the Rust side app.rs keeps setup and event glue; servers.rs, chat.rs, settings_page.rs and appearance.rs hold the logic, vm/ the pure view models, bind/ the callbacks, dev.rs the development switches. Models are created once and updated row by row (vm::list::sync); each chat tab owns its lines model, so a message appends one row. Emoji come from the bundled Twemoji archive through a size-bounded image cache, split into runs that wrap with the text. New settings ui.theme, ui.font_scale, ui.narrow_breakpoint and ui.image_cache_mb apply live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
102 lines
3.4 KiB
Plaintext
102 lines
3.4 KiB
Plaintext
import { Theme } from "../theme.slint";
|
|
|
|
// A horizontal slider: blue track and a round knob. `changed` fires while
|
|
// dragging, `released` at the end.
|
|
export component Slider inherits Rectangle {
|
|
in-out property <float> value;
|
|
in property <float> minimum: 0;
|
|
in property <float> maximum: 100;
|
|
// Arrow keys move by this much.
|
|
in property <float> step: 1;
|
|
in property <bool> enabled: true;
|
|
in property <string> label;
|
|
callback changed(float);
|
|
callback released(float);
|
|
|
|
property <length> knob-size: 16px;
|
|
property <float> ratio: maximum > minimum ? clamp((value - minimum) / (maximum - minimum), 0, 1) : 0;
|
|
|
|
function set(v: float) {
|
|
let clamped = clamp(v, minimum, maximum);
|
|
if clamped != value {
|
|
value = clamped;
|
|
changed(clamped);
|
|
}
|
|
}
|
|
|
|
min-width: 80px;
|
|
height: 24px;
|
|
horizontal-stretch: 1;
|
|
vertical-stretch: 0;
|
|
opacity: enabled ? 1.0 : 0.45;
|
|
|
|
accessible-role: AccessibleRole.slider;
|
|
accessible-label: label;
|
|
accessible-value: round(value);
|
|
accessible-value-minimum: minimum;
|
|
accessible-value-maximum: maximum;
|
|
accessible-value-step: step;
|
|
accessible-enabled: enabled;
|
|
accessible-action-increment => { set(value + step); }
|
|
accessible-action-decrement => { set(value - step); }
|
|
|
|
track := Rectangle {
|
|
x: knob-size / 2;
|
|
width: parent.width - knob-size;
|
|
height: 6px;
|
|
border-radius: 3px;
|
|
background: Theme.meter-off;
|
|
Rectangle {
|
|
x: 0;
|
|
width: parent.width * root.ratio;
|
|
height: 100%;
|
|
border-radius: 3px;
|
|
background: Theme.accent;
|
|
}
|
|
}
|
|
knob := Rectangle {
|
|
x: track.x + track.width * root.ratio - self.width / 2;
|
|
width: knob-size;
|
|
height: knob-size;
|
|
border-radius: knob-size / 2;
|
|
background: #ffffff;
|
|
border-width: focus.has-focus || touch.pressed ? 3px : 2px;
|
|
border-color: Theme.accent;
|
|
}
|
|
focus := FocusScope {
|
|
enabled: root.enabled;
|
|
key-pressed(event) => {
|
|
if event.text == Key.RightArrow || event.text == Key.UpArrow {
|
|
root.set(root.value + root.step);
|
|
root.released(root.value);
|
|
return accept;
|
|
}
|
|
if event.text == Key.LeftArrow || event.text == Key.DownArrow {
|
|
root.set(root.value - root.step);
|
|
root.released(root.value);
|
|
return accept;
|
|
}
|
|
reject
|
|
}
|
|
touch := TouchArea {
|
|
enabled: root.enabled;
|
|
mouse-cursor: MouseCursor.pointer;
|
|
property <float> start-value;
|
|
pointer-event(e) => {
|
|
if e.button == PointerEventButton.left && e.kind == PointerEventKind.down {
|
|
focus.focus();
|
|
root.set(root.minimum + (self.mouse-x - track.x) / max(track.width, 1px) * (root.maximum - root.minimum));
|
|
self.start-value = root.value;
|
|
} else if e.kind == PointerEventKind.up {
|
|
root.released(root.value);
|
|
}
|
|
}
|
|
moved => {
|
|
if self.pressed && root.enabled {
|
|
root.set(self.start-value + (self.mouse-x - self.pressed-x) / max(track.width, 1px) * (root.maximum - root.minimum));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|