A PlayState component draws the triangle and the two bars as vectors in the highlight colour. The mini player uses it too, in place of the ▶ and ❚❚ glyphs, which a font fallback could draw as emoji or at different weights.
1250 lines
42 KiB
Plaintext
1250 lines
42 KiB
Plaintext
// All sizes are multiplied by Theme.s, which is derived from the window height
|
|
// (800px = 1.0, the Steam Deck). The UI keeps the same proportions on a Deck
|
|
// and on a 4K TV, whatever scale factor the compositor reports.
|
|
|
|
// Bundled so headings look the same on every machine. Licence in fonts/OFL.txt.
|
|
import "fonts/NotoSerif-SemiBold.ttf";
|
|
|
|
export enum Action {
|
|
none, up, down, left, right, page-up, page-down, activate, back,
|
|
play-pause, next, prev, queue, section-next, section-prev,
|
|
now-playing, search, seek-forward, seek-back, toggle-fullscreen, quit,
|
|
}
|
|
|
|
export enum Screen { login, browse, now-playing }
|
|
export enum Area { sidebar, content, search }
|
|
|
|
export struct Item {
|
|
index: int,
|
|
title: string,
|
|
subtitle: string,
|
|
detail: string,
|
|
number: string,
|
|
letter: string,
|
|
cover: image,
|
|
has-cover: bool,
|
|
tint: color,
|
|
round: bool,
|
|
show-art: bool,
|
|
playing: bool,
|
|
// A setting with a range: draws `level` (0 to 1) as a slider before `detail`.
|
|
slider: bool,
|
|
level: float,
|
|
}
|
|
|
|
export struct Header {
|
|
visible: bool,
|
|
kind: string,
|
|
title: string,
|
|
subtitle: string,
|
|
info: string,
|
|
letter: string,
|
|
cover: image,
|
|
has-cover: bool,
|
|
tint: color,
|
|
round: bool,
|
|
}
|
|
|
|
export struct Hint { icons: [image], label: string }
|
|
|
|
export global Theme {
|
|
in-out property <float> s: 1.0;
|
|
// The brand palette: warm darks and cream text, from the logo's maroon
|
|
// (#5a0712) and cream. The app replaces these with colours from the album
|
|
// art when that setting is on; src/palette.rs must keep the same defaults.
|
|
in-out property <color> bg: #140b0c;
|
|
in-out property <color> panel: #1d1012;
|
|
in-out property <color> raised: #2b181b;
|
|
in-out property <color> line: #42272b;
|
|
in-out property <color> text: #faebda;
|
|
in-out property <color> muted: #bea999;
|
|
in-out property <color> faint: #80685f;
|
|
// Filled surfaces: the current section, buttons, the playing badge.
|
|
in-out property <color> accent: #a51d2d;
|
|
in-out property <color> on-accent: #faebda;
|
|
// Accent for text and thin lines, where the fill colour is too dark to read.
|
|
in-out property <color> highlight: #e8757b;
|
|
// Ring around whatever has focus.
|
|
in-out property <color> focus: #faebda;
|
|
// Tops of the sidebar and login backgrounds.
|
|
in-out property <color> glow: #2a0b11;
|
|
in-out property <color> login-glow: #3a0b13;
|
|
// Not part of the palette: errors stay red whatever the album art.
|
|
out property <color> error: #f0605d;
|
|
out property <string> serif: "Noto Serif";
|
|
}
|
|
|
|
component Art inherits Rectangle {
|
|
in property <image> source;
|
|
in property <bool> has-image;
|
|
in property <color> tint: Theme.raised;
|
|
in property <string> letter;
|
|
in property <bool> round;
|
|
in property <length> letter-size: 64px * Theme.s;
|
|
border-radius: root.round ? self.width / 2 : 8px * Theme.s;
|
|
clip: true;
|
|
background: @linear-gradient(135deg, root.tint, root.tint.darker(0.7));
|
|
|
|
Text {
|
|
width: parent.width;
|
|
height: parent.height;
|
|
text: root.letter;
|
|
// Not derived from the art's own height: that feeds back into layout.
|
|
font-size: root.letter-size;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
color: Theme.text.with-alpha(0.4);
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
visible: !root.has-image;
|
|
}
|
|
|
|
Image {
|
|
width: parent.width;
|
|
height: parent.height;
|
|
source: root.source;
|
|
image-fit: ImageFit.cover;
|
|
opacity: root.has-image ? 1 : 0;
|
|
animate opacity { duration: 220ms; }
|
|
}
|
|
}
|
|
|
|
component Card inherits Rectangle {
|
|
in property <Item> item;
|
|
in property <bool> selected;
|
|
in property <bool> active;
|
|
in property <length> art;
|
|
callback clicked;
|
|
|
|
property <length> ring: 5px * Theme.s;
|
|
|
|
Rectangle {
|
|
x: -root.ring;
|
|
y: -root.ring;
|
|
width: root.art + 2 * root.ring;
|
|
height: root.art + 2 * root.ring;
|
|
border-radius: root.item.round ? self.width / 2 : 13px * Theme.s;
|
|
border-width: 3px * Theme.s;
|
|
border-color: root.selected ? (root.active ? Theme.focus : Theme.faint) : transparent;
|
|
animate border-color { duration: 120ms; }
|
|
}
|
|
|
|
Art {
|
|
x: 0;
|
|
y: 0;
|
|
width: root.art;
|
|
height: root.art;
|
|
source: root.item.cover;
|
|
has-image: root.item.has-cover;
|
|
tint: root.item.tint;
|
|
letter: root.item.letter;
|
|
round: root.item.round;
|
|
}
|
|
|
|
if root.item.playing: Rectangle {
|
|
x: root.art - self.width - 10px * Theme.s;
|
|
y: root.art - self.height - 10px * Theme.s;
|
|
width: 34px * Theme.s;
|
|
height: 34px * Theme.s;
|
|
border-radius: self.width / 2;
|
|
background: Theme.accent;
|
|
Text {
|
|
text: "▶";
|
|
color: Theme.on-accent;
|
|
font-size: 15px * Theme.s;
|
|
}
|
|
}
|
|
|
|
Text {
|
|
x: 0;
|
|
y: root.art + 12px * Theme.s;
|
|
width: root.art;
|
|
text: root.item.title;
|
|
font-size: 16px * Theme.s;
|
|
font-weight: 600;
|
|
color: root.selected && root.active ? Theme.text : Theme.text.darker(0.08);
|
|
overflow: elide;
|
|
horizontal-alignment: root.item.round ? center : left;
|
|
}
|
|
|
|
Text {
|
|
x: 0;
|
|
y: root.art + 35px * Theme.s;
|
|
width: root.art;
|
|
text: root.item.subtitle;
|
|
font-size: 13px * Theme.s;
|
|
color: Theme.muted;
|
|
overflow: elide;
|
|
horizontal-alignment: root.item.round ? center : left;
|
|
}
|
|
|
|
TouchArea {
|
|
clicked => { root.clicked(); }
|
|
}
|
|
}
|
|
|
|
component Row inherits Rectangle {
|
|
in property <Item> item;
|
|
in property <bool> selected;
|
|
in property <bool> active;
|
|
callback clicked;
|
|
|
|
border-radius: 10px * Theme.s;
|
|
background: root.selected ? (root.active ? Theme.raised : Theme.panel) : transparent;
|
|
border-width: root.selected && root.active ? 2px * Theme.s : 0;
|
|
border-color: Theme.focus;
|
|
|
|
HorizontalLayout {
|
|
padding-left: 16px * Theme.s;
|
|
padding-right: 22px * Theme.s;
|
|
spacing: 18px * Theme.s;
|
|
|
|
if root.item.show-art: VerticalLayout {
|
|
alignment: center;
|
|
Art {
|
|
width: 46px * Theme.s;
|
|
height: 46px * Theme.s;
|
|
source: root.item.cover;
|
|
has-image: root.item.has-cover;
|
|
tint: root.item.tint;
|
|
letter: root.item.letter;
|
|
letter-size: 20px * Theme.s;
|
|
round: root.item.round;
|
|
}
|
|
}
|
|
if !root.item.show-art: Text {
|
|
width: 34px * Theme.s;
|
|
text: root.item.playing ? "▶" : root.item.number;
|
|
font-size: 15px * Theme.s;
|
|
color: root.item.playing ? Theme.highlight : Theme.faint;
|
|
horizontal-alignment: right;
|
|
vertical-alignment: center;
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 3px * Theme.s;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: root.item.title;
|
|
font-size: 17px * Theme.s;
|
|
font-weight: 600;
|
|
color: root.item.playing ? Theme.highlight : Theme.text;
|
|
overflow: elide;
|
|
}
|
|
if root.item.subtitle != "": Text {
|
|
text: root.item.subtitle;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
|
|
if root.item.slider: VerticalLayout {
|
|
alignment: center;
|
|
Rectangle {
|
|
width: 180px * Theme.s;
|
|
height: 6px * Theme.s;
|
|
border-radius: 3px * Theme.s;
|
|
background: Theme.line;
|
|
Rectangle {
|
|
x: 0;
|
|
width: parent.width * root.item.level;
|
|
border-radius: 3px * Theme.s;
|
|
background: root.selected && root.active ? Theme.highlight : Theme.muted;
|
|
animate width { duration: 120ms; easing: ease-out; }
|
|
}
|
|
Rectangle {
|
|
x: parent.width * root.item.level - self.width / 2;
|
|
width: 16px * Theme.s;
|
|
height: 16px * Theme.s;
|
|
border-radius: 8px * Theme.s;
|
|
background: root.selected && root.active ? Theme.text : Theme.muted;
|
|
animate x { duration: 120ms; easing: ease-out; }
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
// Fixed for a slider, so the bar does not shift as the number grows.
|
|
min-width: root.item.slider ? 44px * Theme.s : 0;
|
|
text: root.item.detail;
|
|
font-size: 15px * Theme.s;
|
|
color: Theme.muted;
|
|
horizontal-alignment: right;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
|
|
TouchArea {
|
|
clicked => { root.clicked(); }
|
|
}
|
|
}
|
|
|
|
// A scrolling grid or list. Only a window of items around the selection is in
|
|
// `items`; each carries its absolute index, which positions it.
|
|
component ItemView inherits Rectangle {
|
|
in property <[Item]> items;
|
|
in property <int> count;
|
|
in property <int> selected;
|
|
in property <bool> list-mode;
|
|
in property <bool> active: true;
|
|
in property <string> status;
|
|
callback item-clicked(int);
|
|
callback wheel(int);
|
|
|
|
property <length> gap: 26px * Theme.s;
|
|
property <length> min-art: 170px * Theme.s;
|
|
property <length> pad: 8px * Theme.s;
|
|
out property <int> columns: root.list-mode ? 1 : max(1, floor((root.width - 2 * root.pad + root.gap) / (root.min-art + root.gap)));
|
|
out property <length> art: root.list-mode ? 0px : (root.width - 2 * root.pad - (root.columns - 1) * root.gap) / root.columns;
|
|
property <length> row-h: root.list-mode ? 70px * Theme.s : root.art + 64px * Theme.s + root.gap;
|
|
property <int> total-rows: ceil(root.count / root.columns);
|
|
property <int> sel-row: floor(root.selected / root.columns);
|
|
property <length> max-scroll: max(0px, root.total-rows * root.row-h + 2 * root.pad - root.height);
|
|
property <length> scroll: max(0px, min(root.max-scroll, root.sel-row * root.row-h - (root.height - root.row-h) / 2));
|
|
animate scroll { duration: 200ms; easing: ease-out; }
|
|
|
|
clip: true;
|
|
|
|
TouchArea {
|
|
scroll-event(e) => {
|
|
if (e.delta-y < 0) {
|
|
root.wheel(1);
|
|
} else if (e.delta-y > 0) {
|
|
root.wheel(-1);
|
|
}
|
|
accept
|
|
}
|
|
|
|
for it in root.items: Rectangle {
|
|
x: root.pad + (root.list-mode ? 0px : mod(it.index, root.columns) * (root.art + root.gap));
|
|
y: root.pad + floor(it.index / root.columns) * root.row-h - root.scroll;
|
|
width: root.list-mode ? root.width - 2 * root.pad : root.art;
|
|
height: root.list-mode ? 64px * Theme.s : root.row-h - root.gap;
|
|
|
|
if root.list-mode: Row {
|
|
width: parent.width;
|
|
height: parent.height;
|
|
item: it;
|
|
selected: it.index == root.selected;
|
|
active: root.active;
|
|
clicked => { root.item-clicked(it.index); }
|
|
}
|
|
if !root.list-mode: Card {
|
|
width: parent.width;
|
|
height: parent.height;
|
|
art: root.art;
|
|
item: it;
|
|
selected: it.index == root.selected;
|
|
active: root.active;
|
|
clicked => { root.item-clicked(it.index); }
|
|
}
|
|
}
|
|
}
|
|
|
|
if root.status != "": Text {
|
|
text: root.status;
|
|
font-size: 20px * Theme.s;
|
|
color: Theme.muted;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
wrap: word-wrap;
|
|
width: parent.width * 0.7;
|
|
}
|
|
}
|
|
|
|
component PageHeader inherits Rectangle {
|
|
in property <Header> h;
|
|
property <length> art: 176px * Theme.s;
|
|
|
|
HorizontalLayout {
|
|
spacing: 30px * Theme.s;
|
|
padding-left: 8px * Theme.s;
|
|
padding-bottom: 12px * Theme.s;
|
|
|
|
if root.h.has-cover || root.h.letter != "": VerticalLayout {
|
|
alignment: end;
|
|
Art {
|
|
width: root.art;
|
|
height: root.art;
|
|
source: root.h.cover;
|
|
has-image: root.h.has-cover;
|
|
tint: root.h.tint;
|
|
letter: root.h.letter;
|
|
letter-size: 72px * Theme.s;
|
|
round: root.h.round;
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: end;
|
|
spacing: 6px * Theme.s;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: root.h.kind;
|
|
font-size: 14px * Theme.s;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
letter-spacing: 3px * Theme.s;
|
|
color: Theme.highlight;
|
|
}
|
|
Text {
|
|
text: root.h.title;
|
|
font-size: 40px * Theme.s;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
color: Theme.text;
|
|
overflow: elide;
|
|
}
|
|
if root.h.subtitle != "": Text {
|
|
text: root.h.subtitle;
|
|
font-size: 20px * Theme.s;
|
|
color: Theme.text;
|
|
overflow: elide;
|
|
}
|
|
if root.h.info != "": Text {
|
|
text: root.h.info;
|
|
font-size: 15px * Theme.s;
|
|
color: Theme.muted;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
component Sidebar inherits Rectangle {
|
|
in property <[string]> sections;
|
|
in property <int> current;
|
|
in property <bool> active;
|
|
in property <string> footer;
|
|
callback clicked(int);
|
|
|
|
background: @linear-gradient(180deg, Theme.glow 0%, Theme.panel 55%);
|
|
|
|
VerticalLayout {
|
|
padding: 26px * Theme.s;
|
|
padding-top: 34px * Theme.s;
|
|
spacing: 6px * Theme.s;
|
|
alignment: start;
|
|
|
|
HorizontalLayout {
|
|
alignment: start;
|
|
padding-left: 6px * Theme.s;
|
|
Image {
|
|
source: @image-url("../branding/svg/remus-logo.svg");
|
|
height: 44px * Theme.s;
|
|
// The lockup's aspect ratio, so the image box hugs the logo.
|
|
width: self.height * 2.93;
|
|
}
|
|
}
|
|
Rectangle { height: 26px * Theme.s; }
|
|
|
|
for name[i] in root.sections: Rectangle {
|
|
height: 50px * Theme.s;
|
|
border-radius: 11px * Theme.s;
|
|
background: i == root.current ? (root.active ? Theme.accent : Theme.raised) : transparent;
|
|
animate background { duration: 120ms; }
|
|
Text {
|
|
x: 18px * Theme.s;
|
|
height: parent.height;
|
|
text: name;
|
|
font-size: 18px * Theme.s;
|
|
font-weight: i == root.current ? 700 : 500;
|
|
color: i == root.current ? (root.active ? Theme.on-accent : Theme.text) : Theme.muted;
|
|
vertical-alignment: center;
|
|
}
|
|
TouchArea {
|
|
clicked => { root.clicked(i); }
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
x: 26px * Theme.s;
|
|
y: parent.height - self.height - 22px * Theme.s;
|
|
width: parent.width - 52px * Theme.s;
|
|
text: root.footer;
|
|
font-size: 12px * Theme.s;
|
|
color: Theme.faint;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
|
|
component SearchBox inherits Rectangle {
|
|
in-out property <string> text;
|
|
in property <bool> highlighted;
|
|
callback accepted(string);
|
|
public function focus-input() {
|
|
input.focus();
|
|
}
|
|
|
|
border-radius: 12px * Theme.s;
|
|
background: Theme.raised;
|
|
border-width: 2px * Theme.s;
|
|
border-color: input.has-focus || root.highlighted ? Theme.focus : Theme.line;
|
|
|
|
input := TextInput {
|
|
x: 18px * Theme.s;
|
|
width: parent.width - 36px * Theme.s;
|
|
height: parent.height;
|
|
text <=> root.text;
|
|
font-size: 20px * Theme.s;
|
|
color: Theme.text;
|
|
vertical-alignment: center;
|
|
single-line: true;
|
|
accepted => { root.accepted(self.text); }
|
|
}
|
|
if root.text == "": Text {
|
|
x: 18px * Theme.s;
|
|
height: parent.height;
|
|
text: "Search artists, albums and songs";
|
|
font-size: 20px * Theme.s;
|
|
color: Theme.faint;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
|
|
// Play triangle or pause bars, drawn as vectors so no font fallback can turn
|
|
// them into emoji or give the two different weights.
|
|
component PlayState {
|
|
in property <bool> paused;
|
|
in property <color> tint: Theme.highlight;
|
|
in property <length> size: 14px * Theme.s;
|
|
width: root.size;
|
|
height: root.size;
|
|
|
|
if !root.paused: Path {
|
|
width: root.size;
|
|
height: root.size;
|
|
viewbox-width: 12;
|
|
viewbox-height: 12;
|
|
commands: "M 1.5 0.5 L 11.5 6 L 1.5 11.5 Z";
|
|
fill: root.tint;
|
|
}
|
|
if root.paused: Rectangle {
|
|
x: root.size * 0.12;
|
|
width: root.size * 0.28;
|
|
height: root.size;
|
|
border-radius: root.size * 0.06;
|
|
background: root.tint;
|
|
}
|
|
if root.paused: Rectangle {
|
|
x: root.size * 0.60;
|
|
width: root.size * 0.28;
|
|
height: root.size;
|
|
border-radius: root.size * 0.06;
|
|
background: root.tint;
|
|
}
|
|
}
|
|
|
|
component NowBar inherits Rectangle {
|
|
in property <bool> has-track;
|
|
in property <string> title;
|
|
in property <string> artist;
|
|
in property <image> cover;
|
|
in property <bool> has-cover;
|
|
in property <color> tint;
|
|
in property <string> letter;
|
|
in property <float> progress;
|
|
in property <string> time;
|
|
in property <bool> paused;
|
|
|
|
background: Theme.panel;
|
|
|
|
Rectangle {
|
|
x: 0;
|
|
y: 0;
|
|
width: parent.width;
|
|
height: 3px * Theme.s;
|
|
background: Theme.raised;
|
|
Rectangle {
|
|
x: 0;
|
|
width: parent.width * root.progress;
|
|
background: Theme.highlight;
|
|
}
|
|
}
|
|
|
|
HorizontalLayout {
|
|
padding-left: 22px * Theme.s;
|
|
padding-right: 30px * Theme.s;
|
|
padding-top: 12px * Theme.s;
|
|
padding-bottom: 10px * Theme.s;
|
|
spacing: 16px * Theme.s;
|
|
|
|
if root.has-track: VerticalLayout {
|
|
alignment: center;
|
|
Art {
|
|
width: 54px * Theme.s;
|
|
height: 54px * Theme.s;
|
|
source: root.cover;
|
|
has-image: root.has-cover;
|
|
tint: root.tint;
|
|
letter: root.letter;
|
|
letter-size: 22px * Theme.s;
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
spacing: 3px * Theme.s;
|
|
Text {
|
|
text: root.has-track ? root.title : "Nothing playing";
|
|
font-size: 17px * Theme.s;
|
|
font-weight: 600;
|
|
color: root.has-track ? Theme.text : Theme.faint;
|
|
overflow: elide;
|
|
}
|
|
if root.has-track: Text {
|
|
text: root.artist;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
if root.has-track: Text {
|
|
text: root.time;
|
|
font-size: 15px * Theme.s;
|
|
color: Theme.muted;
|
|
vertical-alignment: center;
|
|
}
|
|
if root.has-track: VerticalLayout {
|
|
alignment: center;
|
|
PlayState {
|
|
paused: root.paused;
|
|
size: 15px * Theme.s;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
component HintBar inherits Rectangle {
|
|
in property <[Hint]> hints;
|
|
in property <string> version;
|
|
|
|
HorizontalLayout {
|
|
padding-left: 28px * Theme.s;
|
|
padding-right: 28px * Theme.s;
|
|
spacing: 28px * Theme.s;
|
|
alignment: end;
|
|
|
|
for h in root.hints: HorizontalLayout {
|
|
spacing: 9px * Theme.s;
|
|
HorizontalLayout {
|
|
spacing: 3px * Theme.s;
|
|
for icon in h.icons: VerticalLayout {
|
|
alignment: center;
|
|
Image {
|
|
source: icon;
|
|
height: 30px * Theme.s;
|
|
// Keys such as Space are wider than a button.
|
|
width: self.height * icon.width / max(1, icon.height);
|
|
}
|
|
}
|
|
}
|
|
Text {
|
|
text: h.label;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Which build is running, so a report from the Deck can be matched to it.
|
|
Text {
|
|
x: 28px * Theme.s;
|
|
height: parent.height;
|
|
text: "remus " + root.version;
|
|
font-size: 12px * Theme.s;
|
|
color: Theme.faint;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
|
|
component Field inherits VerticalLayout {
|
|
in property <string> label;
|
|
in-out property <string> text;
|
|
in property <bool> password;
|
|
in property <bool> highlighted;
|
|
callback accepted;
|
|
public function focus-input() {
|
|
input.focus();
|
|
}
|
|
|
|
spacing: 7px * Theme.s;
|
|
Text {
|
|
text: root.label;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
}
|
|
Rectangle {
|
|
height: 50px * Theme.s;
|
|
border-radius: 10px * Theme.s;
|
|
background: Theme.raised;
|
|
border-width: 2px * Theme.s;
|
|
border-color: input.has-focus || root.highlighted ? Theme.focus : Theme.line;
|
|
input := TextInput {
|
|
x: 16px * Theme.s;
|
|
width: parent.width - 32px * Theme.s;
|
|
height: parent.height;
|
|
text <=> root.text;
|
|
font-size: 19px * Theme.s;
|
|
color: Theme.text;
|
|
vertical-alignment: center;
|
|
single-line: true;
|
|
input-type: root.password ? InputType.password : InputType.text;
|
|
accepted => { root.accepted(); }
|
|
}
|
|
}
|
|
}
|
|
|
|
component LoginView inherits Rectangle {
|
|
in-out property <string> server;
|
|
in-out property <string> username;
|
|
in-out property <string> password;
|
|
in property <int> focus-index;
|
|
in property <string> error;
|
|
in property <bool> busy;
|
|
callback submit;
|
|
callback exit;
|
|
callback field-clicked(int);
|
|
public function focus-field(i: int) {
|
|
if (i == 0) {
|
|
f0.focus-input();
|
|
} else if (i == 1) {
|
|
f1.focus-input();
|
|
} else if (i == 2) {
|
|
f2.focus-input();
|
|
}
|
|
}
|
|
|
|
background: @radial-gradient(circle, Theme.login-glow 0%, Theme.bg 70%);
|
|
|
|
Rectangle {
|
|
width: min(560px * Theme.s, parent.width - 40px * Theme.s);
|
|
height: col.preferred-height;
|
|
border-radius: 18px * Theme.s;
|
|
background: Theme.panel;
|
|
|
|
col := VerticalLayout {
|
|
padding: 40px * Theme.s;
|
|
spacing: 20px * Theme.s;
|
|
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
Image {
|
|
source: @image-url("../branding/svg/remus-logo.svg");
|
|
height: 68px * Theme.s;
|
|
// The lockup's aspect ratio, so the image box hugs the logo.
|
|
width: self.height * 2.93;
|
|
}
|
|
}
|
|
Text {
|
|
text: "Connect to your Subsonic server";
|
|
font-size: 17px * Theme.s;
|
|
color: Theme.muted;
|
|
}
|
|
f0 := Field {
|
|
label: "Server address";
|
|
text <=> root.server;
|
|
highlighted: root.focus-index == 0;
|
|
accepted => { root.field-clicked(1); }
|
|
}
|
|
f1 := Field {
|
|
label: "Username";
|
|
text <=> root.username;
|
|
highlighted: root.focus-index == 1;
|
|
accepted => { root.field-clicked(2); }
|
|
}
|
|
f2 := Field {
|
|
label: "Password";
|
|
text <=> root.password;
|
|
password: true;
|
|
highlighted: root.focus-index == 2;
|
|
accepted => { root.submit(); }
|
|
}
|
|
Rectangle {
|
|
height: 54px * Theme.s;
|
|
border-radius: 12px * Theme.s;
|
|
background: root.focus-index == 3 ? Theme.accent : Theme.raised;
|
|
Text {
|
|
text: root.busy ? "Connecting…" : "Connect";
|
|
font-size: 19px * Theme.s;
|
|
font-weight: 700;
|
|
color: root.focus-index == 3 ? Theme.on-accent : Theme.text;
|
|
}
|
|
TouchArea {
|
|
clicked => { root.submit(); }
|
|
}
|
|
}
|
|
// Secondary to Connect: outlined, no fill, and only lit when focused.
|
|
Rectangle {
|
|
height: 46px * Theme.s;
|
|
border-radius: 12px * Theme.s;
|
|
border-width: 2px * Theme.s;
|
|
border-color: root.focus-index == 4 ? Theme.focus : Theme.line;
|
|
Text {
|
|
text: "Exit";
|
|
font-size: 17px * Theme.s;
|
|
color: root.focus-index == 4 ? Theme.text : Theme.muted;
|
|
}
|
|
TouchArea {
|
|
clicked => { root.exit(); }
|
|
}
|
|
}
|
|
if root.error != "": Text {
|
|
text: root.error;
|
|
font-size: 15px * Theme.s;
|
|
color: Theme.error;
|
|
wrap: word-wrap;
|
|
}
|
|
Text {
|
|
text: "On a Steam Deck, press Steam + X to bring up the keyboard.";
|
|
font-size: 13px * Theme.s;
|
|
color: Theme.faint;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
component NowPlayingView inherits Rectangle {
|
|
in property <string> title;
|
|
in property <string> artist;
|
|
in property <string> album;
|
|
in property <image> cover;
|
|
in property <bool> has-cover;
|
|
in property <color> tint;
|
|
in property <string> letter;
|
|
in property <float> progress;
|
|
in property <string> position;
|
|
in property <string> duration;
|
|
in property <bool> paused;
|
|
in property <bool> has-track;
|
|
// From the cover backdrop setting: the blown-up cover's opacity and the
|
|
// alpha of the background drawn over it, at the left and right edges.
|
|
in property <float> backdrop-opacity: 0.16;
|
|
in property <float> backdrop-left: 0.67;
|
|
in property <float> backdrop-right: 0.95;
|
|
// True while the cover turns away; the app swaps the cover at edge-on and
|
|
// sets it back to false to turn the new one in.
|
|
in property <bool> flip-out;
|
|
in property <[Item]> queue;
|
|
in property <int> queue-count;
|
|
in property <int> queue-selected;
|
|
callback queue-clicked(int);
|
|
callback queue-wheel(int);
|
|
// From the scale, not our own size: a layout child sized from its parent loops.
|
|
out property <length> art-size: 440px * Theme.s;
|
|
|
|
// Blown-up cover as a dim backdrop.
|
|
if root.has-cover && root.backdrop-opacity > 0: Image {
|
|
width: parent.width;
|
|
height: parent.height;
|
|
source: root.cover;
|
|
image-fit: ImageFit.cover;
|
|
opacity: root.backdrop-opacity;
|
|
}
|
|
Rectangle {
|
|
background: @linear-gradient(90deg, Theme.bg.with-alpha(root.backdrop-left), Theme.bg.with-alpha(root.backdrop-right));
|
|
}
|
|
|
|
HorizontalLayout {
|
|
padding: 56px * Theme.s;
|
|
padding-bottom: 28px * Theme.s;
|
|
spacing: 64px * Theme.s;
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 10px * Theme.s;
|
|
width: root.art-size;
|
|
|
|
art := Art {
|
|
width: root.art-size;
|
|
height: root.art-size;
|
|
// Set here so the turned state below has a value to return to.
|
|
transform-scale-x: 100%;
|
|
source: root.cover;
|
|
has-image: root.has-cover;
|
|
tint: root.tint;
|
|
letter: root.letter;
|
|
letter-size: 150px * Theme.s;
|
|
drop-shadow-blur: 40px * Theme.s;
|
|
drop-shadow-color: #00000090;
|
|
}
|
|
Rectangle { height: 14px * Theme.s; }
|
|
Text {
|
|
text: root.has-track ? root.title : "Nothing playing";
|
|
font-size: 32px * Theme.s;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
color: Theme.text;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
text: root.artist;
|
|
font-size: 20px * Theme.s;
|
|
color: Theme.text;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
text: root.album;
|
|
font-size: 16px * Theme.s;
|
|
color: Theme.muted;
|
|
overflow: elide;
|
|
}
|
|
Rectangle { height: 8px * Theme.s; }
|
|
Rectangle {
|
|
height: 6px * Theme.s;
|
|
border-radius: 3px * Theme.s;
|
|
background: Theme.raised;
|
|
Rectangle {
|
|
x: 0;
|
|
width: parent.width * root.progress;
|
|
border-radius: 3px * Theme.s;
|
|
background: Theme.highlight;
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
Text {
|
|
text: root.position;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
}
|
|
// Sized below the time text, so the row keeps the text's height.
|
|
HorizontalLayout {
|
|
horizontal-stretch: 1;
|
|
alignment: center;
|
|
if root.has-track: VerticalLayout {
|
|
alignment: center;
|
|
PlayState {
|
|
paused: root.paused;
|
|
size: 11px * Theme.s;
|
|
}
|
|
}
|
|
}
|
|
Text {
|
|
text: root.duration;
|
|
font-size: 14px * Theme.s;
|
|
color: Theme.muted;
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
spacing: 14px * Theme.s;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: "Queue";
|
|
font-size: 28px * Theme.s;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
color: Theme.text;
|
|
}
|
|
ItemView {
|
|
vertical-stretch: 1;
|
|
list-mode: true;
|
|
items: root.queue;
|
|
count: root.queue-count;
|
|
selected: root.queue-selected;
|
|
status: root.queue-count == 0 ? "The queue is empty. Press Y on an album or track to add it." : "";
|
|
item-clicked(i) => { root.queue-clicked(i); }
|
|
wheel(d) => { root.queue-wheel(d); }
|
|
}
|
|
}
|
|
}
|
|
|
|
// A flip around the vertical axis, faked by squashing the width: Slint has
|
|
// no perspective. The turn back overshoots a little and settles.
|
|
states [
|
|
turned when root.flip-out: {
|
|
art.transform-scale-x: 0%;
|
|
in {
|
|
animate art.transform-scale-x { duration: 170ms; easing: ease-in; }
|
|
}
|
|
out {
|
|
animate art.transform-scale-x { duration: 380ms; easing: cubic-bezier(0.34, 1.5, 0.64, 1); }
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
export component AppWindow inherits Window {
|
|
title: "Remus";
|
|
background: Theme.bg;
|
|
preferred-width: 1280px;
|
|
preferred-height: 800px;
|
|
min-width: 640px;
|
|
min-height: 400px;
|
|
default-font-size: 16px * Theme.s;
|
|
|
|
callback action(Action);
|
|
callback item-clicked(int);
|
|
callback wheel(int);
|
|
callback sidebar-clicked(int);
|
|
callback queue-clicked(int);
|
|
callback queue-wheel(int);
|
|
callback search-accepted(string);
|
|
callback login-submit();
|
|
callback login-field-clicked(int);
|
|
callback layout-changed();
|
|
|
|
in property <Screen> screen: Screen.login;
|
|
in property <Area> area: Area.sidebar;
|
|
|
|
// Login
|
|
in-out property <string> login-server;
|
|
in-out property <string> login-username;
|
|
in-out property <string> login-password;
|
|
in property <int> login-focus;
|
|
in property <string> login-error;
|
|
in property <bool> login-busy;
|
|
|
|
// Browse
|
|
in property <[string]> sections;
|
|
in property <int> section;
|
|
in property <string> server-label;
|
|
in property <string> page-title;
|
|
in property <bool> page-loading;
|
|
in property <Header> header;
|
|
in property <bool> is-search;
|
|
in-out property <string> search-text;
|
|
in property <[Item]> items;
|
|
in property <int> item-count;
|
|
in property <int> selected;
|
|
in property <bool> list-mode;
|
|
in property <string> status;
|
|
out property <int> grid-columns: view.columns;
|
|
out property <length> grid-art: view.art;
|
|
|
|
// Playback
|
|
in property <bool> np-has-track;
|
|
in property <string> np-title;
|
|
in property <string> np-artist;
|
|
in property <string> np-album;
|
|
in property <image> np-cover;
|
|
in property <bool> np-has-cover;
|
|
in property <color> np-tint;
|
|
in property <string> np-letter;
|
|
in property <float> np-progress;
|
|
in property <string> np-position;
|
|
in property <string> np-duration;
|
|
in property <bool> np-paused;
|
|
in property <bool> np-flip-out;
|
|
in property <float> np-backdrop-opacity: 0.16;
|
|
in property <float> np-backdrop-left: 0.67;
|
|
in property <float> np-backdrop-right: 0.95;
|
|
in property <[Item]> queue-items;
|
|
in property <int> queue-count;
|
|
in property <int> queue-selected;
|
|
out property <length> np-art-size: np.art-size;
|
|
|
|
in property <[Hint]> hints;
|
|
in property <string> toast;
|
|
in property <string> version;
|
|
|
|
public function focus-main() {
|
|
fs.focus();
|
|
}
|
|
public function focus-search() {
|
|
search.focus-input();
|
|
}
|
|
public function focus-login(i: int) {
|
|
if (i >= 3) {
|
|
fs.focus();
|
|
} else {
|
|
login.focus-field(i);
|
|
}
|
|
}
|
|
|
|
init => {
|
|
Theme.s = max(0.5, root.height / 800px);
|
|
}
|
|
changed height => {
|
|
Theme.s = max(0.5, root.height / 800px);
|
|
}
|
|
changed grid-columns => {
|
|
root.layout-changed();
|
|
}
|
|
|
|
forward-focus: fs;
|
|
|
|
fs := FocusScope {
|
|
key-pressed(e) => {
|
|
if (e.modifiers.control && (e.text == "q" || e.text == "Q")) {
|
|
root.action(Action.quit);
|
|
return accept;
|
|
}
|
|
if (e.text == Key.UpArrow) { root.action(Action.up); return accept; }
|
|
if (e.text == Key.DownArrow) { root.action(Action.down); return accept; }
|
|
if (e.text == Key.LeftArrow) { root.action(Action.left); return accept; }
|
|
if (e.text == Key.RightArrow) { root.action(Action.right); return accept; }
|
|
if (e.text == Key.PageUp) { root.action(Action.page-up); return accept; }
|
|
if (e.text == Key.PageDown) { root.action(Action.page-down); return accept; }
|
|
if (e.text == Key.Return) { root.action(Action.activate); return accept; }
|
|
if (e.text == Key.Escape || e.text == Key.Backspace) { root.action(Action.back); return accept; }
|
|
if (e.text == Key.Backtab || (e.text == Key.Tab && e.modifiers.shift)) { root.action(Action.section-prev); return accept; }
|
|
if (e.text == Key.Tab) { root.action(Action.section-next); return accept; }
|
|
if (e.text == Key.F11) { root.action(Action.toggle-fullscreen); return accept; }
|
|
if (e.text == " ") { root.action(Action.play-pause); return accept; }
|
|
if (e.text == "n") { root.action(Action.next); return accept; }
|
|
if (e.text == "p") { root.action(Action.prev); return accept; }
|
|
if (e.text == "q") { root.action(Action.queue); return accept; }
|
|
if (e.text == "/") { root.action(Action.search); return accept; }
|
|
if (e.text == "f") { root.action(Action.now-playing); return accept; }
|
|
if (e.text == ",") { root.action(Action.seek-back); return accept; }
|
|
if (e.text == ".") { root.action(Action.seek-forward); return accept; }
|
|
reject
|
|
}
|
|
|
|
VerticalLayout {
|
|
Rectangle {
|
|
vertical-stretch: 1;
|
|
// Hidden screens still report their minimum size; ignore it so the
|
|
// bars below always fit.
|
|
min-height: 0px;
|
|
|
|
login := LoginView {
|
|
visible: root.screen == Screen.login;
|
|
server <=> root.login-server;
|
|
username <=> root.login-username;
|
|
password <=> root.login-password;
|
|
focus-index: root.login-focus;
|
|
error: root.login-error;
|
|
busy: root.login-busy;
|
|
submit => { root.login-submit(); }
|
|
exit => { root.action(Action.quit); }
|
|
field-clicked(i) => { root.login-field-clicked(i); }
|
|
}
|
|
|
|
Rectangle {
|
|
visible: root.screen == Screen.browse;
|
|
HorizontalLayout {
|
|
Sidebar {
|
|
width: 236px * Theme.s;
|
|
sections: root.sections;
|
|
current: root.section;
|
|
active: root.area == Area.sidebar;
|
|
footer: root.server-label;
|
|
clicked(i) => { root.sidebar-clicked(i); }
|
|
}
|
|
VerticalLayout {
|
|
padding-left: 36px * Theme.s;
|
|
padding-right: 36px * Theme.s;
|
|
padding-top: 30px * Theme.s;
|
|
spacing: 14px * Theme.s;
|
|
|
|
HorizontalLayout {
|
|
spacing: 16px * Theme.s;
|
|
height: root.header.visible ? 0px : 44px * Theme.s;
|
|
visible: !root.header.visible;
|
|
Text {
|
|
text: root.page-title;
|
|
font-size: 32px * Theme.s;
|
|
font-family: Theme.serif;
|
|
font-weight: 600;
|
|
color: Theme.text;
|
|
vertical-alignment: center;
|
|
}
|
|
Text {
|
|
horizontal-stretch: 1;
|
|
text: root.page-loading && root.item-count > 0 ? "Loading…" : "";
|
|
font-size: 15px * Theme.s;
|
|
color: Theme.faint;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
PageHeader {
|
|
height: root.header.visible ? 200px * Theme.s : 0px;
|
|
visible: root.header.visible;
|
|
h: root.header;
|
|
}
|
|
search := SearchBox {
|
|
height: root.is-search ? 60px * Theme.s : 0px;
|
|
visible: root.is-search;
|
|
text <=> root.search-text;
|
|
highlighted: root.area == Area.search;
|
|
accepted(t) => { root.search-accepted(t); }
|
|
}
|
|
view := ItemView {
|
|
vertical-stretch: 1;
|
|
items: root.items;
|
|
count: root.item-count;
|
|
selected: root.selected;
|
|
list-mode: root.list-mode;
|
|
active: root.area == Area.content;
|
|
status: root.status;
|
|
item-clicked(i) => { root.item-clicked(i); }
|
|
wheel(d) => { root.wheel(d); }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
np := NowPlayingView {
|
|
visible: root.screen == Screen.now-playing;
|
|
title: root.np-title;
|
|
artist: root.np-artist;
|
|
album: root.np-album;
|
|
cover: root.np-cover;
|
|
has-cover: root.np-has-cover;
|
|
tint: root.np-tint;
|
|
letter: root.np-letter;
|
|
progress: root.np-progress;
|
|
position: root.np-position;
|
|
duration: root.np-duration;
|
|
paused: root.np-paused;
|
|
has-track: root.np-has-track;
|
|
flip-out: root.np-flip-out;
|
|
backdrop-opacity: root.np-backdrop-opacity;
|
|
backdrop-left: root.np-backdrop-left;
|
|
backdrop-right: root.np-backdrop-right;
|
|
queue: root.queue-items;
|
|
queue-count: root.queue-count;
|
|
queue-selected: root.queue-selected;
|
|
queue-clicked(i) => { root.queue-clicked(i); }
|
|
queue-wheel(d) => { root.queue-wheel(d); }
|
|
}
|
|
|
|
if root.toast != "": Rectangle {
|
|
x: (parent.width - self.width) / 2;
|
|
y: 24px * Theme.s;
|
|
width: toast-text.preferred-width + 48px * Theme.s;
|
|
height: 48px * Theme.s;
|
|
border-radius: 24px * Theme.s;
|
|
background: Theme.raised;
|
|
border-width: 1px * Theme.s;
|
|
border-color: Theme.line;
|
|
drop-shadow-blur: 20px * Theme.s;
|
|
drop-shadow-color: #00000080;
|
|
toast-text := Text {
|
|
text: root.toast;
|
|
font-size: 16px * Theme.s;
|
|
color: Theme.text;
|
|
}
|
|
}
|
|
}
|
|
|
|
if root.screen == Screen.browse: NowBar {
|
|
height: 80px * Theme.s;
|
|
has-track: root.np-has-track;
|
|
title: root.np-title;
|
|
artist: root.np-artist;
|
|
cover: root.np-cover;
|
|
has-cover: root.np-has-cover;
|
|
tint: root.np-tint;
|
|
letter: root.np-letter;
|
|
progress: root.np-progress;
|
|
time: root.np-position + " / " + root.np-duration;
|
|
paused: root.np-paused;
|
|
}
|
|
|
|
HintBar {
|
|
height: 46px * Theme.s;
|
|
hints: root.hints;
|
|
version: root.version;
|
|
}
|
|
}
|
|
}
|
|
}
|