Slint cannot split the .slint compilation across crates, but a Slint LIBRARY crate exposes its generated Rust types to dependent crates (verified with a minimal proof). So: - NEW crate `qbz-ui` (lib): owns the whole .slint tree + build.rs + bundled translations; `slint::include_modules!()` + the generated types (AppWindow, MiniPlayerWindow, all globals/structs) are re-exported. Translation domain is now `qbz-ui` (the .po files renamed accordingly). - `qbz-slint` (bin) -> renamed to `qbz` (package + `[[bin]] name = "qbz"`), reclaiming the binary name from the retired Tauri app. It depends on `qbz-ui` and does `pub use qbz_ui::*;` so existing `crate::AppWindow` / `crate::*State` references resolve unchanged. This splits the single ~20 GB rustc into two crates (UI/codegen vs the 75k LOC of logic) — the foundation for lower build peak, incremental caching, and the upcoming per-feature crate extraction. Also fixed for the move: qbz-i18n bundled-.po include paths, the font/WGSL `include_bytes!`/`include_str!` paths (-> ../../qbz-ui/ui/), workspace members, dev scripts (`-p qbz`), and the CI workflows. `cargo check -p qbz` is green. cc
118 lines
4.2 KiB
Plaintext
118 lines
4.2 KiB
Plaintext
// Segmented tab navigator — the SAME design Discovery's HomeView uses (a
|
||
// small-radius rectangle group, ADR-008-compliant: NOT a capsule pill),
|
||
// promoted to a shared, data-driven primitive so Local Library and Library
|
||
// (Favorites) read identically. Each tab carries an optional count rendered
|
||
// as a compact badge with smaller-but-legible type inside the tab item.
|
||
|
||
import { Theme } from "../foundation/semantic-colors.slint";
|
||
import { Typography } from "../foundation/typography.slint";
|
||
|
||
// One entry in the navigator. `count <= 0` hides the badge.
|
||
export struct SegTab {
|
||
id: string,
|
||
label: string,
|
||
count: int,
|
||
}
|
||
|
||
// A single segment: fills with surface-main when active (Discovery's Tab),
|
||
// hover surface-hover, transparent otherwise. The count sits in a rounded
|
||
// badge to the right of the label.
|
||
component Segment inherits Rectangle {
|
||
in property <string> label;
|
||
in property <int> count;
|
||
in property <bool> active;
|
||
callback clicked();
|
||
|
||
border-radius: 4px;
|
||
background: root.active ? Theme.surface-main
|
||
: ta.has-hover ? Theme.surface-hover : transparent;
|
||
// HC-only: a 1px strong border makes the active/inactive distinction
|
||
// survive a flattened High-Contrast palette where the fill alone reads
|
||
// weakly. Gated so the 31 normal themes keep their clean borderless look.
|
||
border-width: (Theme.is-high-contrast && root.active) ? 1px : 0px;
|
||
border-color: Theme.border-strong;
|
||
|
||
HorizontalLayout {
|
||
padding-left: 12px;
|
||
padding-right: root.count > 0 ? 8px : 12px;
|
||
padding-top: 6px;
|
||
padding-bottom: 6px;
|
||
spacing: 7px;
|
||
Text {
|
||
text: root.label;
|
||
color: root.active ? Theme.text-primary : Theme.text-muted;
|
||
// Discovery's tab type: 13px medium.
|
||
font-size: Typography.legal;
|
||
font-weight: Typography.medium;
|
||
vertical-alignment: center;
|
||
}
|
||
// Count badge — smaller (11px) but legible. min-width keeps single
|
||
// digits balanced; the layout grows the chip for 2–3 digit counts.
|
||
if root.count > 0: VerticalLayout {
|
||
alignment: center;
|
||
Rectangle {
|
||
min-width: 18px;
|
||
height: 16px;
|
||
border-radius: 8px;
|
||
// Alpha-token badge fill follows theme polarity (black-on-light
|
||
// in light themes) instead of a fixed white wash.
|
||
background: root.active ? Theme.alpha-15 : Theme.alpha-8;
|
||
HorizontalLayout {
|
||
alignment: center;
|
||
padding-left: 5px;
|
||
padding-right: 5px;
|
||
Text {
|
||
text: root.count;
|
||
color: root.active ? Theme.text-primary : Theme.text-secondary;
|
||
font-size: 11px;
|
||
font-weight: Typography.medium;
|
||
vertical-alignment: center;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Redundant non-color shape cue for the active segment (Radix/Spotify
|
||
// underline equivalent): a 2px accent bar pinned to the segment's bottom
|
||
// edge, shown only when active. Drawn as a non-layout overlay (positioned
|
||
// off the Segment root's own geometry, never a sibling .height reference)
|
||
// so toggling it never reflows the row. Reads as polish in all 33 themes,
|
||
// not just High-Contrast.
|
||
if root.active: Rectangle {
|
||
x: 4px;
|
||
width: root.width - 8px;
|
||
height: 2px;
|
||
y: root.height - self.height;
|
||
border-radius: 1px;
|
||
background: Theme.accent;
|
||
}
|
||
|
||
ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => { root.clicked(); }
|
||
}
|
||
}
|
||
|
||
export component SegmentedTabBar inherits Rectangle {
|
||
in property <[SegTab]> tabs;
|
||
in property <string> active-id;
|
||
callback selected(string);
|
||
|
||
width: row.preferred-width;
|
||
height: row.preferred-height;
|
||
background: Theme.surface-elevated;
|
||
border-radius: 6px;
|
||
|
||
row := HorizontalLayout {
|
||
padding: 3px;
|
||
spacing: 4px;
|
||
for tab in root.tabs: Segment {
|
||
label: tab.label;
|
||
count: tab.count;
|
||
active: root.active-id == tab.id;
|
||
clicked => { root.selected(tab.id); }
|
||
}
|
||
}
|
||
}
|