Files
spotify/ui/page.slint
Tamas Csikel 3a66e0c7c7
All checks were successful
release / release (push) Successful in 12m14s
Spotify for Fennec OS: native TV client
Rust + Slint on sf-ui's Liquid Glass, with the page engine of Netflex TV.
librespot plays (GStreamer on the TV) and makes the TV a Spotify Connect
device; the Web API (token from the session) feeds the pages.

- Sign-in with the phone: a pairing code / QR code (spotify.com/pair,
  OAuth device flow) or picking the TV in the Spotify app (zeroconf).
- Home, search, library, playlist / album / liked songs / podcast pages,
  artist pages, settings; the user's picture top right.
- Now playing: seek, shuffle, repeat, like, synced lyrics, queue.
- package.sh builds x86-64 and aarch64 (Raspberry Pi); the Gitea CI
  releases both on a tag.
- tools/mock_server.py and SPOTIFY_MOCK for work without an account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:23:34 +01:00

805 lines
29 KiB
Plaintext

// The page renderer (from Netflex TV): every browsing screen is a list of
// Lines built by Rust (src/page.rs), which also owns the focus and the
// scroll position. This file draws them and their glass:
// - the top navigation capsule and, right of it, "now playing",
// - hero buttons (glass at rest),
// - one focus pill that glides to the focused chip on any other line
// (on a track row it covers the whole row),
// - the search keyboard's pane.
// Everything else (cards, texts, unfocused chips) is plain Slint over the
// backdrop, so nothing Slint draws sits under glass.
import { Tv, GlassRect, GlassPane, Keyboard, Spinner, Display, Headline, Title, SectionTitle, Body, Item, Label, Caption } from "@sf-ui/sf-ui.slint";
import { Line, Chip, Card, Check } from "types.slint";
import { SpIcon } from "icons.slint";
export global Accent {
out property <color> green: #1ed760;
out property <color> deep: #1db954;
}
// The liked songs' picture: a heart on Spotify's violet gradient.
component LikedArt inherits Rectangle {
in property <length> icon-size: 72 * Tv.u;
background: @linear-gradient(135deg, #450af5 0%, #8e8ee5 100%);
SpIcon {
name: "heart-filled";
size: root.icon-size;
ink: #ffffff;
}
}
// An album, playlist, show (square) or artist (round) card.
component SpCard inherits Rectangle {
in property <Card> card;
in property <bool> focused;
in property <bool> round;
in property <length> art-h;
in property <bool> captions;
out property <float> f: self.focused ? 1 : 0;
animate f { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
property <length> r: self.round ? root.art-h / 2 : 14 * Tv.u;
art := Rectangle {
y: 0;
height: root.art-h;
transform-scale: 1 + 0.08 * root.f;
Rectangle {
border-radius: root.r;
background: #1b1d24;
drop-shadow-blur: (14 + 22 * root.f) * Tv.u;
drop-shadow-offset-y: (8 + 12 * root.f) * Tv.u;
drop-shadow-color: #00000090;
}
Rectangle {
border-radius: root.r;
clip: true;
if root.card.mark == "liked": LikedArt { }
if root.card.image.width == 0 && root.card.mark != "liked": Text {
x: 20 * Tv.u;
width: parent.width - 40 * Tv.u;
horizontal-alignment: center;
vertical-alignment: center;
text: root.card.title;
font-size: 24 * Tv.u;
font-weight: 600;
color: Tv.text-tertiary;
wrap: word-wrap;
}
Image {
width: 100%;
height: 100%;
source: root.card.image;
image-fit: cover;
}
Rectangle {
background: #000000;
opacity: 0.2 * (1 - root.f);
}
}
if root.card.current: Rectangle {
border-radius: root.r;
border-width: 4 * Tv.u;
border-color: Accent.green;
}
}
if root.captions: Text {
x: 0;
y: root.art-h + 18 * Tv.u;
width: root.width;
horizontal-alignment: root.round ? center : left;
text: root.card.caption;
font-size: 24 * Tv.u;
font-weight: 600;
color: root.focused ? Tv.text : #ffffffd0;
overflow: elide;
}
if root.captions: Text {
x: 0;
y: root.art-h + 52 * Tv.u;
width: root.width;
horizontal-alignment: root.round ? center : left;
text: root.card.detail;
font-size: 20 * Tv.u;
color: Tv.text-tertiary;
overflow: elide;
}
}
// A chip drawn by Slint. Focused chips get the page's glass pill underneath,
// hero chips are glass all the time: neither draws a background then.
component SpChip inherits Rectangle {
in property <Chip> chip;
in property <bool> focused;
in property <bool> on-glass;
property <bool> plain: root.focused || root.on-glass;
property <color> ink: root.focused && root.chip.tone != "primary" ? Tv.ink
: root.chip.tone == "danger" ? Tv.danger-ink
: root.chip.active || root.on-glass || root.chip.tone == "primary" ? Tv.text
: #ffffffd0;
x: root.chip.x * Tv.u;
y: root.chip.y * Tv.u;
width: root.chip.w * Tv.u;
height: root.chip.h * Tv.u;
opacity: root.chip.enabled ? 1 : 0.42;
Rectangle {
visible: !root.plain;
border-radius: root.chip.tone == "field" ? 22 * Tv.u : self.height / 2;
background: root.chip.tone == "field" ? #ffffff10
: root.chip.tone == "primary" ? #1ed76080
: root.chip.active ? #ffffff2c
: #ffffff12;
border-width: root.chip.tone == "field" ? 1.5 * Tv.u : 0;
border-color: #ffffff38;
}
HorizontalLayout {
padding-left: root.chip.tone == "field" ? 28 * Tv.u : root.chip.text == "" ? (root.height - 30 * Tv.u) / 2 : (root.chip.icon == "" ? 26 : 20) * Tv.u;
padding-right: root.chip.tone == "field" ? 28 * Tv.u : root.chip.text == "" ? (root.height - 30 * Tv.u) / 2 : 26 * Tv.u;
spacing: 10 * Tv.u;
alignment: root.chip.tone == "field" ? start : center;
if root.chip.icon != "": SpIcon {
y: (parent.height - self.height) / 2;
name: root.chip.icon;
size: (root.chip.text == "" ? 30 : 28) * Tv.u;
ink: root.ink;
}
if root.chip.text != "": Text {
vertical-alignment: center;
horizontal-stretch: root.chip.tone == "field" ? 1 : 0;
text: root.chip.text;
font-size: (root.chip.tone == "field" ? 26 : 23) * Tv.u;
font-weight: root.chip.active || root.focused || root.chip.tone == "primary" ? 700 : 600;
color: root.ink;
overflow: elide;
}
}
}
// Three bars that move while a track plays (track rows, the nav capsule).
export component Equalizer inherits Rectangle {
in property <color> ink: Accent.green;
in property <bool> moving: true;
in property <length> size: 24 * Tv.u;
width: self.size;
height: self.size;
// Only ticks while moving: a paused screen draws no frames.
property <duration> t: root.moving ? animation-tick() : 0ms;
for i in 3: Rectangle {
property <float> phase: root.moving ? (1 + sin((root.t / 1ms) * (0.45 + i * 0.17) * 1deg)) / 2 : 0.35;
x: i * root.size / 3 + root.size / 18;
width: root.size / 4.5;
height: root.size * (0.25 + 0.75 * self.phase);
y: root.size - self.height;
border-radius: self.width / 3;
background: root.ink;
}
}
export component LinePage inherits Rectangle {
in property <float> alpha: 1;
in property <[Line]> lines;
in property <int> focus-line: -1;
// Vertical scroll position (design px), animated here.
in property <float> scroll;
// Top navigation (main sections).
in property <bool> show-nav;
in property <[string]> nav-items;
in property <int> nav-index;
in property <bool> nav-focused;
// "Now playing" right of the nav ("" = nothing loaded).
in property <string> np-title;
in property <string> np-artist;
in property <bool> np-playing;
in property <bool> np-focused;
// The signed-in user (top right): their picture, or their initial.
in property <image> user-image;
in property <string> user-initial;
// Embedded search keyboard: its top (design px, page coordinates; < 0 = none).
in property <float> kb-y: -1;
in property <bool> kb-focused;
in property <string> kb-placeholder;
in property <string> kb-submit-label: "Keresés";
in-out property <string> query;
callback search-submitted(string);
callback search-exit-down();
callback search-exit-up();
callback search-cancelled();
public function kb-key(event: KeyEvent) -> EventResult {
kb.key(event)
}
public function kb-reset() {
kb.reset();
}
// Content left edge (design px).
property <float> cx: 96;
out property <float> scroll-anim: self.scroll;
animate scroll-anim { duration: 380ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
property <bool> content-focus: !self.nav-focused && !self.np-focused && !self.kb-focused;
// ---- lines ----
for line[li] in root.lines: Rectangle {
property <float> ty: line.y - root.scroll-anim;
property <bool> lf: li == root.focus-line && root.content-focus;
x: (root.cx + line.x) * Tv.u;
y: self.ty * Tv.u;
width: line.w * Tv.u;
height: line.h * Tv.u;
visible: self.ty + line.h > -40 && self.ty < 1120;
opacity: root.alpha;
// hero without a cover (big title)
if line.kind == "hero" && !line.framed: Rectangle {
if line.style != "": Text {
x: 0;
y: 12 * Tv.u;
text: line.style;
font-size: 20 * Tv.u;
font-weight: 700;
letter-spacing: 3 * Tv.u;
color: Tv.text-secondary;
}
Display {
x: 0;
y: 90 * Tv.u;
width: 1300 * Tv.u;
text: line.title;
font-size: (line.title.character-count > 24 ? 64 : 88) * Tv.u;
}
Caption {
x: 0;
y: 242 * Tv.u;
width: 1300 * Tv.u;
text: line.subtitle;
}
Label {
x: 0;
y: 274 * Tv.u;
width: 1500 * Tv.u;
text: line.meta;
color: Tv.text;
}
Body {
x: 0;
y: 316 * Tv.u;
width: 1100 * Tv.u;
height: 152 * Tv.u;
text: line.text;
font-size: 26 * Tv.u;
}
for chip[ci] in line.chips: SpChip {
chip: chip;
focused: lf && line.col == ci;
on-glass: true;
}
}
// hero with a cover: picture left, texts and buttons right
if line.kind == "hero" && line.framed: Rectangle {
Rectangle {
x: 0;
y: 20 * Tv.u;
width: 360 * Tv.u;
height: 360 * Tv.u;
border-radius: line.round ? self.width / 2 : 18 * Tv.u;
background: #1b1d24;
drop-shadow-blur: 40 * Tv.u;
drop-shadow-offset-y: 16 * Tv.u;
drop-shadow-color: #000000a0;
}
Rectangle {
x: 0;
y: 20 * Tv.u;
width: 360 * Tv.u;
height: 360 * Tv.u;
border-radius: line.round ? self.width / 2 : 18 * Tv.u;
clip: true;
if line.icon == "liked": LikedArt { icon-size: 120 * Tv.u; }
Image {
width: 100%;
height: 100%;
source: line.cover;
image-fit: cover;
}
}
property <length> tx: 420 * Tv.u;
Text {
x: parent.tx;
y: 28 * Tv.u;
text: line.style;
font-size: 20 * Tv.u;
font-weight: 700;
letter-spacing: 3 * Tv.u;
color: Tv.text-secondary;
}
Text {
x: parent.tx;
y: 58 * Tv.u;
width: parent.width - parent.tx;
height: 120 * Tv.u;
vertical-alignment: center;
text: line.title;
font-size: (line.title.character-count > 40 ? 44 : line.title.character-count > 22 ? 58 : 80) * Tv.u;
font-weight: 700;
letter-spacing: -2 * Tv.u;
color: Tv.text;
wrap: word-wrap;
overflow: elide;
}
Text {
x: parent.tx;
y: 186 * Tv.u;
width: parent.width - parent.tx;
text: line.subtitle;
font-size: 28 * Tv.u;
font-weight: 700;
color: Tv.text;
overflow: elide;
}
Label {
x: parent.tx;
y: 226 * Tv.u;
width: parent.width - parent.tx;
text: line.meta;
color: Tv.text-secondary;
overflow: elide;
}
Text {
x: parent.tx;
y: 262 * Tv.u;
width: min(parent.width - parent.tx, 1100 * Tv.u);
height: 62 * Tv.u;
text: line.text;
font-size: 22 * Tv.u;
color: Tv.text-tertiary;
wrap: word-wrap;
overflow: elide;
}
for chip[ci] in line.chips: SpChip {
chip: chip;
focused: lf && line.col == ci;
on-glass: true;
}
}
// heading
if line.kind == "heading": Rectangle {
Text {
x: 0;
y: 4 * Tv.u;
text: line.title;
font-size: (line.style == "big" ? 56 : 38) * Tv.u;
font-weight: 700;
letter-spacing: (line.style == "big" ? -1 : -0.4) * Tv.u;
color: Tv.text;
}
Caption {
x: 0;
y: (line.style == "big" ? 76 : 54) * Tv.u;
width: parent.width;
text: line.subtitle;
}
}
// text
if line.kind == "text": Text {
x: 0;
y: 0;
width: parent.width;
height: parent.height;
text: line.text;
wrap: word-wrap;
vertical-alignment: top;
font-size: (line.style == "caption" ? 22 : line.style == "label" ? 24 : 26) * Tv.u;
font-weight: line.style == "label" ? 600 : 400;
color: line.style == "warn" ? Tv.warn-ink : line.style == "bad" ? Tv.danger-ink : line.style == "good" ? Tv.ok-ink : line.style == "caption" ? Tv.text-tertiary : Tv.text-secondary;
}
// notice
if line.kind == "notice": Rectangle {
SpIcon {
x: 0;
y: 4 * Tv.u;
size: 36 * Tv.u;
name: line.icon != "" ? line.icon : line.tone == "good" ? "check" : line.tone == "info" ? "info" : "warning";
ink: line.tone == "good" ? Tv.ok-ink : line.tone == "bad" ? Tv.danger-ink : line.tone == "warn" ? Tv.warn-ink : Tv.text-secondary;
}
Item {
x: 56 * Tv.u;
y: 4 * Tv.u;
width: parent.width - 56 * Tv.u;
text: line.title;
font-size: 27 * Tv.u;
}
Text {
x: 56 * Tv.u;
y: 44 * Tv.u;
width: parent.width - 56 * Tv.u;
height: parent.height - 44 * Tv.u;
text: line.text;
wrap: word-wrap;
font-size: 23 * Tv.u;
color: Tv.text-secondary;
}
}
// chips
if line.kind == "chips": Rectangle {
if line.title != "": Text {
x: 0;
y: 0;
text: line.title;
font-size: 22 * Tv.u;
font-weight: 600;
letter-spacing: 1 * Tv.u;
color: Tv.text-tertiary;
}
for chip[ci] in line.chips: SpChip {
chip: chip;
focused: lf && line.col == ci;
}
}
// item
if line.kind == "item": Rectangle {
Text {
x: 0;
y: 6 * Tv.u;
width: parent.width;
text: line.title;
font-size: 26 * Tv.u;
font-weight: 600;
color: Tv.text;
overflow: elide;
}
Text {
x: 0;
y: 42 * Tv.u;
width: parent.width;
text: line.meta;
font-size: 21 * Tv.u;
font-weight: 500;
color: Tv.text-tertiary;
overflow: elide;
}
Text {
x: 0;
y: 74 * Tv.u;
width: min(parent.width, 1100 * Tv.u);
height: 58 * Tv.u;
text: line.text;
font-size: 21 * Tv.u;
color: Tv.text-secondary;
wrap: word-wrap;
overflow: elide;
}
for chip[ci] in line.chips: SpChip {
chip: chip;
focused: lf && line.col == ci;
}
}
// track row
if line.kind == "track": Rectangle {
property <bool> f0: lf && line.col == 0;
property <bool> playing: line.tone == "playing";
property <length> body-w: parent.width - 96 * Tv.u;
property <color> ink: self.f0 ? Tv.ink : self.playing ? Accent.green : line.tone == "dim" ? Tv.text-tertiary : Tv.text;
if line.note != "" && line.tone != "playing": Text {
x: 8 * Tv.u;
width: 64 * Tv.u;
height: parent.height;
horizontal-alignment: center;
vertical-alignment: center;
text: line.note;
font-size: 24 * Tv.u;
font-weight: 600;
color: parent.f0 ? Tv.ink : Tv.text-tertiary;
}
if line.note != "" && line.tone == "playing": Equalizer {
x: 28 * Tv.u;
y: (parent.height - self.height) / 2;
ink: parent.f0 ? Tv.ink : Accent.green;
}
if line.note == "": Rectangle {
x: 10 * Tv.u;
y: 8 * Tv.u;
width: 64 * Tv.u;
height: 64 * Tv.u;
border-radius: 8 * Tv.u;
clip: true;
background: #1b1d24;
Image {
width: 100%;
height: 100%;
source: line.image;
image-fit: cover;
}
}
Text {
x: 96 * Tv.u;
y: 10 * Tv.u;
width: parent.body-w - 96 * Tv.u - 130 * Tv.u;
text: line.title;
font-size: 26 * Tv.u;
font-weight: 600;
color: parent.ink;
overflow: elide;
}
Text {
x: 96 * Tv.u;
y: 44 * Tv.u;
width: parent.body-w - 96 * Tv.u - 130 * Tv.u;
text: line.meta;
font-size: 21 * Tv.u;
font-weight: 500;
color: parent.f0 ? #121317b0 : Tv.text-tertiary;
overflow: elide;
}
Text {
x: parent.body-w - 130 * Tv.u;
width: 100 * Tv.u;
height: parent.height;
horizontal-alignment: right;
vertical-alignment: center;
text: line.extra;
font-size: 22 * Tv.u;
font-weight: 500;
color: parent.f0 ? Tv.ink : Tv.text-tertiary;
}
if line.chips.length > 1: SpChip {
chip: line.chips[1];
focused: lf && line.col == 1;
}
}
// cards
if line.kind == "cards": Rectangle {
property <float> cw: line.style == "landscape" ? 400 : 216;
property <float> ch: line.style == "landscape" ? 225 : 216;
property <float> step: self.cw + 32;
property <float> head: line.title != "" ? 56 : 0;
property <int> fit: floor((line.w + 32) / self.step);
property <float> scroll-to: clamp(line.col - 1, 0, max(0, line.cards.length - self.fit));
property <float> sc: self.scroll-to;
animate sc { duration: 320ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
if line.title != "": Text {
x: 0;
y: 0;
text: line.title;
font-size: 32 * Tv.u;
font-weight: 700;
color: lf ? Tv.text : #ffffffc8;
}
for card[ci] in line.cards: SpCard {
x: (ci - parent.sc) * parent.step * Tv.u;
y: parent.head * Tv.u;
width: parent.cw * Tv.u;
height: (parent.ch + (line.captions ? 80 : 0)) * Tv.u;
art-h: parent.ch * Tv.u;
round: line.style == "round";
visible: ci >= parent.sc - 2 && ci < parent.sc + parent.fit + 2;
card: card;
captions: line.captions;
focused: lf && line.col == ci;
}
}
}
// ---- embedded keyboard (search) ----
kb-pane := GlassPane {
x: (root.width - self.width) / 2;
y: (root.kb-y - root.scroll-anim) * Tv.u;
width: 1720 * Tv.u;
height: 508 * Tv.u;
radius: 48 * Tv.u;
frost: 3.4;
tint: Tv.smoke.with-alpha(0.44);
alpha: root.kb-y >= 0 ? root.alpha : 0;
visible: root.kb-y >= 0;
kb := Keyboard {
x: 0;
y: 40 * Tv.u;
width: parent.width;
compact: true;
placeholder: root.kb-placeholder;
submit-label: root.kb-submit-label;
min-length: 2;
max-length: 60;
active: root.kb-focused;
alpha: root.kb-y >= 0 ? root.alpha : 0;
text <=> root.query;
submitted(t) => { root.search-submitted(t); }
cancelled => { root.search-cancelled(); }
exit-down => { root.search-exit-down(); }
exit-up => { root.search-exit-up(); }
}
}
// ---- top navigation ----
property <length> tab-w: 190 * Tv.u;
property <float> nav-a: root.show-nav ? root.alpha * (root.nav-focused || root.np-focused ? 1 : clamp(1 - root.scroll-anim / 120, 0, 1)) : 0;
nav := GlassPane {
x: (root.width - self.width) / 2;
y: 40 * Tv.u;
width: root.nav-items.length * root.tab-w + 16 * Tv.u;
height: 80 * Tv.u;
radius: self.height / 2;
frost: 1.6;
tint: #ffffff0a;
alpha: root.nav-a;
visible: root.show-nav;
for t[i] in root.nav-items: Text {
x: 8 * Tv.u + i * root.tab-w;
width: root.tab-w;
height: parent.height;
horizontal-alignment: center;
vertical-alignment: center;
text: t;
font-size: 25 * Tv.u;
font-weight: 600;
color: i == root.nav-index ? (root.nav-focused ? Tv.ink : Tv.text) : Tv.text-secondary;
opacity: root.nav-a;
}
}
// ---- now playing capsule ----
property <bool> np-on: root.show-nav && root.np-title != "";
out property <float> np-t: self.np-focused ? 1 : 0;
animate np-t { duration: 220ms; easing: ease-out; }
np := Rectangle {
x: nav.x + nav.width + 24 * Tv.u;
y: nav.y + 4 * Tv.u;
width: max(0, min(460 * Tv.u, np-text.preferred-width + 100 * Tv.u, avatar.x - 24 * Tv.u - self.x));
height: 72 * Tv.u;
visible: root.np-on;
opacity: root.nav-a;
Equalizer {
x: 24 * Tv.u;
y: (parent.height - self.height) / 2;
moving: root.np-playing;
ink: root.np-focused ? Tv.ink : Accent.green;
}
np-text := VerticalLayout {
x: 64 * Tv.u;
width: parent.width - 88 * Tv.u;
alignment: center;
Text {
text: root.np-title;
font-size: 22 * Tv.u;
font-weight: 700;
color: root.np-focused ? Tv.ink : Tv.text;
overflow: elide;
}
Text {
text: root.np-artist;
font-size: 19 * Tv.u;
font-weight: 500;
color: root.np-focused ? #121317b0 : Tv.text-secondary;
overflow: elide;
}
}
}
// ---- the signed-in user ----
avatar := Rectangle {
x: root.width - Tv.safe-x - self.width;
y: 44 * Tv.u;
width: 72 * Tv.u;
height: 72 * Tv.u;
visible: root.show-nav && (root.user-initial != "" || root.user-image.width > 0);
opacity: root.nav-a;
Rectangle {
border-radius: self.width / 2;
background: #ffffff26;
drop-shadow-blur: 16 * Tv.u;
drop-shadow-offset-y: 6 * Tv.u;
drop-shadow-color: #00000070;
}
Rectangle {
border-radius: self.width / 2;
clip: true;
if root.user-image.width == 0: Text {
text: root.user-initial;
font-size: 32 * Tv.u;
font-weight: 700;
color: Tv.text;
}
Image {
width: 100%;
height: 100%;
source: root.user-image;
image-fit: cover;
}
}
}
out property <float> tab-pos: self.nav-index;
animate tab-pos { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
out property <float> nav-t: self.nav-focused ? 1 : 0;
animate nav-t { duration: 220ms; easing: ease-out; }
// ---- glass ----
property <Line> fl: root.focus-line >= 0 && root.focus-line < root.lines.length ? root.lines[root.focus-line] : root.lines[0];
property <Chip> fc: root.fl.chips[max(0, root.fl.col)];
property <bool> pill-on: root.content-focus && root.focus-line >= 0 && root.fl.kind != "hero" && root.fl.kind != "cards" && root.fc.w > 0;
out property <float> pill-x: root.cx + root.fl.x + root.fc.x;
animate pill-x { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
out property <float> pill-w: root.fc.w;
animate pill-w { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
out property <float> pill-y: root.fl.y + root.fc.y;
animate pill-y { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
out property <float> pill-h: root.fc.h;
animate pill-h { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
out property <float> pill-a: root.pill-on ? 1 : 0;
animate pill-a { duration: 160ms; easing: ease-out; }
property <Line> hero: root.lines.length > 0 && root.lines[0].kind == "hero" ? root.lines[0] : root.fl;
property <bool> has-hero: root.lines.length > 0 && root.lines[0].kind == "hero";
pure function hero-rect(i: int) -> GlassRect {
let c = root.hero.chips[i];
let f = root.has-hero && root.focus-line == 0 && root.content-focus && root.hero.col == i ? 1 : 0;
let s = 1 + 0.05 * f;
{
x: (root.cx + root.hero.x + c.x) * Tv.u - c.w * Tv.u * (s - 1) / 2,
y: (root.hero.y + c.y - root.scroll-anim) * Tv.u - c.h * Tv.u * (s - 1) / 2,
w: c.w * Tv.u * s,
h: c.h * Tv.u * s,
r: c.h * Tv.u * s / 2,
focus: f,
alpha: root.has-hero && c.w > 0 && i < root.hero.chips.length ? root.alpha * (c.enabled ? 1 : 0.5) : 0,
blur: 1.4,
glow: c.tone == "primary" ? Accent.green : #ffffff,
tint: c.tone == "primary" ? Accent.deep.with-alpha(0.5 + 0.4 * f) : #ffffff.with-alpha((c.active ? 0.16 : 0.07) + 0.8 * f),
group: 0,
}
}
out property <[GlassRect]> glass: [
nav.glass,
{
x: nav.absolute-position.x + 8 * Tv.u + root.tab-pos * root.tab-w,
y: nav.absolute-position.y + 8 * Tv.u,
w: root.tab-w,
h: nav.height - 16 * Tv.u,
r: (nav.height - 16 * Tv.u) / 2,
focus: root.nav-t,
alpha: root.nav-a,
blur: -1,
glow: #ffffff,
tint: #ffffff.with-alpha(0.12 + 0.76 * root.nav-t),
group: 0,
},
{
x: np.absolute-position.x,
y: np.absolute-position.y,
w: np.width,
h: np.height,
r: np.height / 2,
focus: root.np-t,
alpha: root.np-on ? root.nav-a : 0,
blur: 1.6,
glow: Accent.green,
tint: #ffffff.with-alpha(0.06 + 0.82 * root.np-t),
group: 0,
},
root.hero-rect(0),
root.hero-rect(1),
root.hero-rect(2),
root.hero-rect(3),
{
x: root.pill-x * Tv.u,
y: (root.pill-y - root.scroll-anim) * Tv.u,
w: root.pill-w * Tv.u,
h: root.pill-h * Tv.u,
r: root.fc.tone == "field" ? 22 * Tv.u : root.pill-h * Tv.u / 2,
focus: 1,
alpha: root.alpha * root.pill-a,
blur: 1.2,
glow: root.fc.tone == "primary" ? Accent.green : #ffffff,
tint: root.fc.tone == "primary" ? Accent.deep.with-alpha(0.85) : #ffffff.with-alpha(root.fc.tone == "field" ? 0.82 : 0.88),
group: 0,
},
kb-pane.glass,
];
out property <[GlassRect]> glass-keyboard: kb.glass;
}