Files
qbz/crates/qbz-ui/ui/shell/NavRail.slint
T
vicrodh f1eeaf9126 feat(steam-deck): game mode support (plan PR1-PR5)
- PR1: gamescope detection at boot — X11 backend, scale 1, kiosk
  fullscreen; tray + miniplayer suppressed (click-offset fix).
- PR2: full keyboard navigation for the kiosk (3 zones, focus ring,
  scroll-into-view; typing never navigates).
- PR3: native gamepad via gilrs — D-pad/stick/A/B to synthetic Slint
  keys with hysteresis, repeat and debounce; B suppresses Escape while
  a text field is focused (closes the Steam OSK).
- PR4: Steam OSK via the steam://open/keyboard deeplink on text focus.
- PR5: scripts/qbz-add-to-steam (stdlib-only, 19/19 unit tests) with
  artwork assets + pure-gamepad controller layout.

Spec: qbz-nix-docs/steam-deck/STEAM_DECK_GAME_MODE_PLAN.md

km
2026-07-25 12:04:58 -06:00

194 lines
6.6 KiB
Plaintext

// Bottom NavRail — small-panel touch navigation (2.0.2 frente #3, Axis B).
//
// Icon+label tiles (Radius.sm rectangles, NO pills — ADR-008) replacing the
// desktop Sidebar, driving the SAME NavState routes. Tiles are positioned
// MANUALLY (absolute x + explicit width from root.width) — every layout-based
// attempt left them collapsed to icon width on the left; absolute positioning
// takes the width straight from the rail (which KioskShell stretches to the
// panel).
import { Theme } from "../foundation/semantic-colors.slint";
import { Radius } from "../foundation/radius.slint";
import { NavState, ContentView, ImmersiveState, MyQbzBrandingState, KioskNavState } from "../state.slint";
component NavTile inherits Rectangle {
in property <image> icon;
in property <string> label;
in property <bool> active;
// Keyboard/gamepad nav (PR 2): this tile holds the shell focus ring.
in property <bool> nav-focused: false;
callback clicked;
border-radius: Radius.sm;
background: root.nav-focused
? Theme.accent.with-alpha(0.22)
: root.active
? Theme.accent.with-alpha(0.12)
: ta.has-hover ? Theme.alpha-6 : transparent;
border-width: root.nav-focused ? 2px : root.active ? 1px : 0px;
border-color: root.nav-focused ? Theme.accent : Theme.accent.with-alpha(0.30);
VerticalLayout {
alignment: center;
spacing: 5px;
// A fixed-size child does not center itself horizontally in a
// VerticalLayout — wrap the icon in a full-width centering row.
HorizontalLayout {
alignment: center;
Image {
source: root.icon;
colorize: root.active ? Theme.accent : Theme.text-muted;
width: 24px;
height: 24px;
}
}
Text {
text: root.label;
color: root.active ? Theme.accent : Theme.text-muted;
font-size: 11.5px;
font-weight: 600;
horizontal-alignment: center;
overflow: elide;
}
}
ta := TouchArea {
clicked => {
root.clicked();
}
}
}
export component NavRail inherits Rectangle {
callback discover();
callback library();
callback local-library();
callback myqbz();
callback playing();
callback visualizer();
callback menu();
background: Theme.surface-main;
// Keyboard/gamepad nav (PR 2): tile count for the shell's rail zone and
// the activation seam for Enter (the rail is always mounted, so the
// shell calls this directly instead of using the activate-seq pulse).
out property <int> tile-count: 7;
public function activate-index(i: int) {
if (i == 0) { root.discover(); }
else if (i == 1) { root.library(); }
else if (i == 2) { root.local-library(); }
else if (i == 3) { root.myqbz(); }
else if (i == 4) { root.playing(); }
else if (i == 5) { root.visualizer(); }
else if (i == 6) { root.menu(); }
}
// 7 tiles, 8px outer padding, 6px gaps (6 gaps). Search is intentionally
// absent — the back-bar carries a persistent search field, so a footer
// Search tile is redundant.
property <length> tw: (root.width - 16px - 6 * 6px) / 7;
property <length> th: root.height - 18px;
Rectangle {
x: 0;
y: 0;
width: root.width;
height: 1px;
background: Theme.border-subtle;
}
NavTile {
x: 8px + 0 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/compass.svg");
label: @tr("Discover");
active: NavState.view == ContentView.home;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 0;
clicked => {
root.discover();
}
}
NavTile {
x: 8px + 1 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/library-big.svg");
label: @tr("Library");
active: NavState.view == ContentView.favorites;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 1;
clicked => {
root.library();
}
}
NavTile {
x: 8px + 2 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/hard-drive.svg");
label: @tr("Local Library");
active: NavState.view == ContentView.local-library || NavState.view == ContentView.local-album;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 2;
clicked => {
root.local-library();
}
}
NavTile {
x: 8px + 3 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/music-library-2.svg");
label: MyQbzBrandingState.label;
active: NavState.view == ContentView.mixtapes
|| NavState.view == ContentView.collections
|| NavState.view == ContentView.mixtape-detail;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 3;
clicked => {
root.myqbz();
}
}
NavTile {
x: 8px + 4 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/play-fill.svg");
label: @tr("Now Playing");
active: NavState.view == ContentView.now-playing;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 4;
clicked => {
root.playing();
}
}
NavTile {
x: 8px + 5 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/sliders-horizontal.svg");
label: @tr("Visualizer");
active: false;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 5;
clicked => {
root.visualizer();
}
}
NavTile {
x: 8px + 6 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/settings.svg");
label: @tr("Settings");
active: NavState.view == ContentView.settings;
nav-focused: KioskNavState.nav-active && KioskNavState.zone == "rail" && KioskNavState.index == 6;
clicked => {
root.menu();
}
}
}