Files
qbz/crates/qbz-ui/ui/discover/PinnedCarousel.slint
T
vicrodh 8c2f84b798 feat(shell): per-GPU selector, ambient scene in immersive, glass carousels/viewall
Smoke round 5 (owner feedback). Checkpoint.

- Preferred GPU selector (Settings > Renderer, Linux/wgpu): lists each detected
  GPU by name ("Auto" + e.g. "NVIDIA … (discrete)" / "Intel … (integrated)"),
  persisted (ui_prefs.gpu_power by device name), applied at startup via the wgpu
  adapter PowerPreference (WGPU_POWER_PREF env still wins). Fixes the iGPU running
  hot under the shader background on hybrid laptops — pick the discrete GPU.
  New gpu_adapters() enumerates+dedups adapters; gpu_power_from_prefs /
  _options / _seed_index / _value_for_index.
- Ambient metaball added to the IMMERSIVE scene picker (mode 7, wgpu-only opt-in);
  the non-shader atmosphere stays the fallback for GL/software tiers.
- Glass treatment on the surfaces that were still opaque: carousel < > nav
  buttons (6 carousels), "Filter by category" pill, "Filter by genre" buttons,
  and the PlaylistBrowseView (View-all) header band + category radio row.
- i18n: "Preferred GPU" + description + discrete/integrated + restart toast (8
  locales).

Base: 76ea5a82. Prior checkpoint: a0f5cf2b.

cc
2026-07-17 10:54:45 -06:00

176 lines
6.3 KiB
Plaintext

// Pinned carousel — title, prev/next page controls, and a clipped sliding
// track of MIXED cards (albums / artists / playlists), dispatched per-item
// on `PinnedItem.kind`. Same simple paging mechanism as PlaylistCarousel;
// one fixed 200x246 slot per item (the ArtistCarousel slot pattern) so the
// three card types share one row. Used by the Home / For You "pinned"
// section arms, fed from the shared PinnedState global.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { PinnedItem, ShellState, AppearanceState } from "../state.slint";
import { AlbumCard } from "AlbumCard.slint";
import { ArtistGridCard } from "ArtistGridCard.slint";
import { PlaylistCard } from "PlaylistCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component NavButton inherits Rectangle {
in property <image> icon;
in property <bool> enabled: true;
callback clicked();
width: 28px;
height: 28px;
border-radius: 14px;
opacity: root.enabled ? 1.0 : 0.4;
background: ta.has-hover && root.enabled
? Theme.surface-hover
: (ShellState.app-background-active
? Theme.surface-elevated.with-alpha(AppearanceState.app-background-surface-alpha)
: Theme.surface-elevated);
QbzIcon {
source: root.icon;
width: 15px;
height: 15px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.enabled ? Theme.text-primary : Theme.text-muted;
}
ta := TouchArea {
enabled: root.enabled;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.clicked();
}
}
}
export component PinnedCarousel inherits VerticalLayout {
in property <string> title;
in property <[PinnedItem]> items;
callback album-clicked(string);
callback artist-clicked(string);
// Playlist open/play rides media-action ("playlist", id, "open"/"play")
// — PlaylistCard has no clicked callback (body-opens: true, Home
// convention).
callback media-action(string, string, string);
property <length> card-width: 200px;
property <length> card-height: 246px;
property <length> gap: 32px;
property <int> count: root.items.length;
property <int> per-page: Math.max(
1,
Math.floor((viewport.width + root.gap) / (root.card-width + root.gap)));
property <int> page-count: Math.max(1, Math.ceil(root.count / root.per-page));
property <int> page: 0;
property <int> current-page: Math.min(Math.max(0, root.page), root.page-count - 1);
property <length> step: root.per-page * (root.card-width + root.gap);
property <length> content-width:
root.count * root.card-width + Math.max(0, root.count - 1) * root.gap;
spacing: 12px;
HorizontalLayout {
spacing: 8px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
HorizontalLayout {
spacing: 4px;
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-left.svg");
enabled: root.current-page > 0;
clicked => {
root.page = root.current-page - 1;
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-right.svg");
enabled: root.current-page < root.page-count - 1;
clicked => {
root.page = root.current-page + 1;
}
}
}
}
}
viewport := Rectangle {
height: root.card-height;
clip: true;
Rectangle {
x: -root.current-page * root.step;
y: 0px;
width: root.content-width;
height: root.card-height;
animate x { duration: 220ms; easing: ease-in-out; }
HorizontalLayout {
spacing: root.gap;
// One fixed-width slot per item; the slot hosts exactly one
// card, selected by the item's kind.
for item in root.items: Rectangle {
width: root.card-width;
height: root.card-height;
if item.kind == "album": AlbumCard {
album: item.album;
clicked(id) => {
root.album-clicked(id);
}
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
if item.kind == "artist": ArtistGridCard {
artist: item.artist;
clicked(id) => {
root.artist-clicked(id);
}
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
if item.kind == "playlist": PlaylistCard {
playlist: item.playlist;
body-opens: true;
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
}
}
}
Rectangle {
x: 0px;
width: 56px;
background: @linear-gradient(90deg, Theme.surface-main 0%, transparent 100%);
opacity: root.current-page > 0 ? 1.0 : 0.0;
visible: !ShellState.app-background-active;
animate opacity { duration: 150ms; }
}
Rectangle {
x: parent.width - self.width;
width: 56px;
background: @linear-gradient(90deg, transparent 0%, Theme.surface-main 100%);
opacity: root.current-page < root.page-count - 1 ? 1.0 : 0.0;
visible: !ShellState.app-background-active;
animate opacity { duration: 150ms; }
}
}
}