Files
qbz/crates/qbz-slint/ui/primitives/ListScrollbar.slint
T
vicrodh 82129cff35 feat(slint): LocalLibrary ephemeral folders + Folders tree 1:1 port
Ephemeral folders: open / browse / play a folder without indexing it —
album-grouped pane, CUE seek fast-path (no full re-decode per virtual track),
folder-path persistence + rehydrate, "already playing" add-vs-replace choice
dialog (ephemeral-only), and now-playing / queue / menu gating so an ephemeral
track exposes no persistence actions.

Folders tree brought 1:1 with Tauri:
- Rail header: select-mode, collapse-all, open-ephemeral, tree search.
- Resizable rail (default ~20% narrower; drag handle, min 50% default /
  max 50% of the content area).
- Subfolder cover grid + grid/list toggle, recursive track count, name search;
  compact icon bulk bar (folder-check / play-next / queue / playlist / clear).
- Tree is the default mode; circular checkboxes homologated with TrackRow;
  compact rows (smaller type + icon, no ambiguous trailing count).
- Flat/Tree icon toggle (disc-album / folder-tree), floated right.

Per-source TrackRow context menu (logic, not a blanket trim): Qobuz/offline =
full; local = play/next/queue + add-to-playlist; plex/ephemeral = play/next/
queue only.

App-wide standard: Math.round pixel-snap on icon centering across the UI to
kill sub-pixel blur (CircleAction, header back/forward/collapse, and the rest).
NowPlayingBar context icon -> turntable (frees disc-album for the Folders
toggle). New assets: folder-check, folder-tree, turntable.

cc
2026-06-07 10:12:59 -06:00

66 lines
2.4 KiB
Plaintext

// Custom vertical scrollbar for a ListView — Slint's built-in one is
// too thin and its thumb has no minimum size, so on a thousands-row
// list it shrinks to a sliver. This sits in its own gutter (not over
// the rows), is thicker, keeps a minimum thumb height, and is
// draggable. Bind `viewport-y` two-way to the ListView and feed it the
// list's viewport/visible heights.
import { Theme } from "../foundation/semantic-colors.slint";
export component ListScrollbar inherits Rectangle {
in property <length> viewport-height;
in property <length> visible-height;
in-out property <length> viewport-y;
// Only meaningful when the content overflows.
property <length> max-scroll: max(0px, root.viewport-height - root.visible-height);
property <length> thumb-h:
root.viewport-height > 0px
? max(48px, root.visible-height / root.viewport-height * root.height)
: root.height;
property <length> travel: max(0px, root.height - root.thumb-h);
width: 14px;
visible: root.max-scroll > 0px;
// Track.
Rectangle {
width: 6px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
height: 100%;
background: #ffffff12;
border-radius: 3px;
}
// Thumb.
thumb := Rectangle {
width: bar-ta.has-hover || bar-ta.pressed ? 10px : 8px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
height: root.thumb-h;
y: root.max-scroll > 0px
? (-root.viewport-y / root.max-scroll) * root.travel
: 0px;
border-radius: 5px;
background: bar-ta.has-hover || bar-ta.pressed ? #ffffff77 : #ffffff44;
animate width { duration: 100ms; }
}
// Drag / click-to-position over the whole gutter — centers the
// thumb on the pointer.
bar-ta := TouchArea {
mouse-cursor: pointer;
moved => {
if (bar-ta.pressed && root.travel > 0px) {
root.viewport-y = -min(root.max-scroll, max(0px,
(bar-ta.mouse-y - root.thumb-h / 2) / root.travel * root.max-scroll));
}
}
pointer-event(e) => {
if (e.kind == PointerEventKind.down && root.travel > 0px) {
root.viewport-y = -min(root.max-scroll, max(0px,
(bar-ta.mouse-y - root.thumb-h / 2) / root.travel * root.max-scroll));
}
}
}
}