Files
Remus/ui/app.slint
T
Ansho Rei f03374b585 feat: replace the login screen's Exit button with an X in the corner
The full-width button under Connect took a row in a card that is close
to filling an 800 px high screen. The X is a focus stop between the
saved servers and the address field, so Up from the address field still
reaches it from a controller.

Bumps the version to 0.10.1.
2026-11-06 23:35:37 +01:00

1664 lines
59 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,
volume-up, volume-down, toggle-mute, cycle-shuffle, shuffle, hold-activate,
}
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 }
// A saved server on the login screen: its label, and "Logged out" or nothing.
export struct KnownServer { label: string, note: 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;
}
}
// As wide as the art, so a row with a cover and a row with a number
// line up, as on an album where some tracks have their own cover.
if !root.item.show-art: Text {
width: 46px * 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;
}
}
// A speaker with sound waves, or with a cross when muted.
component Speaker {
in property <bool> muted;
in property <color> tint: Theme.text;
in property <length> size: 16px * Theme.s;
width: root.size;
height: root.size;
Path {
width: root.size;
height: root.size;
viewbox-width: 16;
viewbox-height: 16;
commands: "M 1 5.5 L 4.5 5.5 L 8.5 2 L 8.5 14 L 4.5 10.5 L 1 10.5 Z";
fill: root.tint;
}
Path {
width: root.size;
height: root.size;
viewbox-width: 16;
viewbox-height: 16;
commands: root.muted
? "M 10.5 5.5 L 15 10 M 15 5.5 L 10.5 10"
: "M 10.5 5.5 A 3.2 3.2 0 0 1 10.5 10.5 M 12.5 3.5 A 6 6 0 0 1 12.5 12.5";
stroke: root.tint;
stroke-width: 1.6px * root.size / 16px;
}
}
// A quiet speaker, bar and number for the current volume.
component VolumeLevel inherits HorizontalLayout {
in property <int> level;
in property <bool> muted;
in property <length> font-size: 13px * Theme.s;
// The speaker gets a box as wide as the number, so the bar is the middle
// of the whole and centring the row centres the bar.
in property <bool> balanced;
// Fixed, so the bar does not shift as the number changes, and wide enough
// for "Muted".
property <length> label-width: 4.2 * root.font-size;
spacing: 10px * Theme.s;
// Its own width only, so a stretching row does not hand it the slack.
horizontal-stretch: 0;
HorizontalLayout {
width: root.balanced ? root.label-width : 14px * Theme.s;
alignment: end;
Speaker {
muted: root.muted || root.level == 0;
tint: Theme.muted;
size: 14px * Theme.s;
y: (parent.height - self.height) / 2;
}
}
VerticalLayout {
alignment: center;
Rectangle {
width: 90px * Theme.s;
height: 4px * Theme.s;
border-radius: 2px * Theme.s;
background: Theme.raised;
Rectangle {
x: 0;
width: parent.width * (root.muted ? 0 : root.level / 100);
border-radius: 2px * Theme.s;
background: Theme.muted;
}
}
}
Text {
width: root.label-width;
text: root.muted ? "Muted" : root.level;
font-size: root.font-size;
color: Theme.muted;
vertical-alignment: center;
}
}
// The level after a volume change, faded out again by the app after a moment.
// Asks before doing something that cannot be undone from where it is asked.
// The choices sit in a row; the app moves the selection and starts with the
// first, which is Cancel.
component ConfirmDialog inherits Rectangle {
in property <string> title;
in property <string> message;
in property <[string]> choices;
in property <int> selected;
callback clicked(int);
background: #00000099;
// Keeps clicks from reaching the page behind.
TouchArea { }
Rectangle {
width: min(620px * Theme.s, parent.width - 40px * Theme.s);
height: col.preferred-height;
border-radius: 18px * Theme.s;
background: Theme.panel;
border-width: 1px * Theme.s;
border-color: Theme.line;
drop-shadow-blur: 30px * Theme.s;
drop-shadow-color: #00000080;
col := VerticalLayout {
padding: 34px * Theme.s;
spacing: 18px * Theme.s;
Text {
text: root.title;
font-size: 24px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
wrap: word-wrap;
}
Text {
text: root.message;
font-size: 16px * Theme.s;
color: Theme.muted;
wrap: word-wrap;
}
HorizontalLayout {
spacing: 12px * Theme.s;
padding-top: 6px * Theme.s;
for label[i] in root.choices: Rectangle {
height: 50px * Theme.s;
border-radius: 12px * Theme.s;
background: i == root.selected ? Theme.accent : Theme.raised;
border-width: 2px * Theme.s;
border-color: i == root.selected ? Theme.focus : transparent;
Text {
text: label;
font-size: 18px * Theme.s;
font-weight: i == root.selected ? 700 : 500;
color: i == root.selected ? Theme.on-accent : Theme.text;
}
TouchArea {
clicked => { root.clicked(i); }
}
}
}
}
}
}
component VolumeOverlay inherits Rectangle {
in property <bool> shown;
in property <int> level;
in property <bool> muted;
width: 300px * Theme.s;
height: 56px * Theme.s;
border-radius: 28px * Theme.s;
background: Theme.raised;
border-width: 1px * Theme.s;
border-color: Theme.line;
drop-shadow-blur: 20px * Theme.s;
drop-shadow-color: #00000080;
opacity: root.shown ? 1 : 0;
animate opacity { duration: 180ms; }
HorizontalLayout {
padding-left: 22px * Theme.s;
padding-right: 22px * Theme.s;
spacing: 14px * Theme.s;
VerticalLayout {
alignment: center;
Speaker {
muted: root.muted || root.level == 0;
size: 22px * Theme.s;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Rectangle {
height: 6px * Theme.s;
border-radius: 3px * Theme.s;
background: Theme.line;
Rectangle {
x: 0;
width: parent.width * (root.muted ? 0 : root.level / 100);
border-radius: 3px * Theme.s;
background: Theme.highlight;
animate width { duration: 100ms; easing: ease-out; }
}
}
}
Text {
min-width: 48px * Theme.s;
text: root.muted ? "Muted" : root.level;
font-size: 16px * Theme.s;
color: Theme.text;
horizontal-alignment: right;
vertical-alignment: center;
}
}
}
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;
in property <int> volume;
in property <bool> muted;
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;
}
}
if root.has-track: Rectangle { width: 6px * Theme.s; }
if root.has-track: VolumeLevel {
level: root.volume;
muted: root.muted;
font-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;
// A password field shows its text while this is set, toggled by the eye.
in-out property <bool> shown;
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;
// Leaves room for the eye on a password field.
width: parent.width - (root.password ? 64px : 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 && !root.shown ? InputType.password : InputType.text;
accepted => { root.accepted(); }
}
if root.password: Rectangle {
x: parent.width - self.width - 8px * Theme.s;
width: 40px * Theme.s;
height: parent.height;
// An eye to show the password, struck through to hide it again.
Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 1.5 12 C 4.5 6.5 8 4.5 12 4.5 C 16 4.5 19.5 6.5 22.5 12 C 19.5 17.5 16 19.5 12 19.5 C 8 19.5 4.5 17.5 1.5 12 Z";
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 1.6px * Theme.s;
}
Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 12 8.5 A 3.5 3.5 0 1 1 11.99 8.5 Z";
fill: eye-area.has-hover ? Theme.text : Theme.muted;
}
if root.shown: Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 3 21 L 21 3";
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 1.8px * Theme.s;
}
eye-area := TouchArea {
clicked => {
root.shown = !root.shown;
input.focus();
}
}
}
}
}
component LoginView inherits Rectangle {
in-out property <string> server;
in-out property <string> username;
in-out property <string> password;
in-out property <bool> password-shown;
in property <int> focus-index;
in property <string> error;
in property <bool> busy;
// Adding a server from inside the app: the bottom button goes back.
in property <bool> can-cancel;
// Saved servers above the form, and which one has focus, -1 for none.
in property <[KnownServer]> known;
in property <int> known-selected: -1;
callback submit;
callback exit;
callback field-clicked(int);
callback known-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%);
// Saved servers in a card of their own beside the form, so the form is
// as tall as without them and still fits an 800 px high screen.
HorizontalLayout {
alignment: center;
spacing: 24px * Theme.s;
padding: 20px * Theme.s;
if root.known.length > 0: VerticalLayout {
alignment: center;
Rectangle {
preferred-width: 400px * Theme.s;
min-width: 240px * Theme.s;
border-radius: 18px * Theme.s;
background: Theme.panel;
VerticalLayout {
padding: 28px * Theme.s;
spacing: 10px * Theme.s;
Text {
text: "Saved servers";
font-size: 22px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
}
Text {
text: "Pick one to fill in its address and username.";
font-size: 14px * Theme.s;
color: Theme.muted;
wrap: word-wrap;
}
for k[i] in root.known: Rectangle {
height: 58px * Theme.s;
border-radius: 10px * Theme.s;
background: i == root.known-selected ? Theme.raised : transparent;
border-width: 2px * Theme.s;
border-color: i == root.known-selected ? Theme.focus : Theme.line;
VerticalLayout {
padding-left: 16px * Theme.s;
padding-right: 16px * Theme.s;
alignment: center;
Text {
text: k.label;
font-size: 17px * Theme.s;
color: Theme.text;
overflow: elide;
}
if k.note != "": Text {
text: k.note;
font-size: 13px * Theme.s;
color: Theme.faint;
}
}
TouchArea {
clicked => { root.known-clicked(i); }
}
}
}
}
}
VerticalLayout {
alignment: center;
Rectangle {
preferred-width: 560px * Theme.s;
min-width: 320px * 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;
shown <=> root.password-shown;
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(); }
}
}
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;
}
}
// Exit, or Cancel when adding a server from inside the app. A
// corner button rather than a row, to keep the card short.
Rectangle {
x: parent.width - self.width - 14px * Theme.s;
y: 14px * Theme.s;
width: 44px * Theme.s;
height: 44px * Theme.s;
border-radius: self.width / 2;
background: root.focus-index == -1 || x-area.has-hover ? Theme.raised : transparent;
border-width: 2px * Theme.s;
border-color: root.focus-index == -1 ? Theme.focus : transparent;
Path {
width: 18px * Theme.s;
height: 18px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 4 4 L 20 20 M 20 4 L 4 20";
stroke: root.focus-index == -1 || x-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 2px * Theme.s;
}
x-area := TouchArea {
clicked => { root.exit(); }
}
}
}
}
}
}
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 <int> volume: 100;
in property <bool> muted;
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;
// How the queue is shuffled, empty when it plays in order.
in property <string> shuffle;
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;
}
}
// Placed by hand: the icon on the bar's midpoint whatever the
// widths of the two times, which a layout would share out.
Rectangle {
height: position-text.preferred-height;
position-text := Text {
x: 0;
width: self.preferred-width;
text: root.position;
font-size: 14px * Theme.s;
color: Theme.muted;
}
Text {
x: parent.width - self.width;
width: self.preferred-width;
text: root.duration;
font-size: 14px * Theme.s;
color: Theme.muted;
}
if root.has-track: PlayState {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
paused: root.paused;
size: 11px * Theme.s;
}
}
HorizontalLayout {
alignment: center;
VolumeLevel {
level: root.volume;
muted: root.muted;
balanced: true;
}
}
}
VerticalLayout {
spacing: 14px * Theme.s;
horizontal-stretch: 1;
HorizontalLayout {
spacing: 16px * Theme.s;
Text {
text: "Queue";
font-size: 28px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
}
Text {
horizontal-stretch: 1;
text: root.shuffle;
font-size: 16px * Theme.s;
color: Theme.muted;
vertical-alignment: center;
overflow: elide;
}
}
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 login-known-clicked(int);
callback confirm-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;
in property <bool> login-can-cancel;
in-out property <bool> login-password-shown;
in property <[KnownServer]> login-known;
in property <int> login-known-selected: -1;
// 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 <string> np-shuffle;
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;
// The volume overlay, shown briefly after any volume change.
in property <bool> volume-shown;
in property <int> volume;
in property <bool> muted;
in property <string> version;
in property <bool> show-hint-bar: true;
// The confirmation prompt, over everything else while shown.
in property <bool> confirm-shown;
in property <string> confirm-title;
in property <string> confirm-message;
in property <[string]> confirm-choices;
in property <int> confirm-selected;
public function focus-main() {
fs.focus();
}
public function focus-search() {
search.focus-input();
}
public function focus-login(i: int) {
// Below 0 is the X or a saved server, 3 is Connect: keys go to the scope.
if (i >= 3 || i < 0) {
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; }
// = is + without shift on most layouts.
if (e.text == "+" || e.text == "=") { root.action(Action.volume-up); return accept; }
if (e.text == "-") { root.action(Action.volume-down); return accept; }
if (e.text == "m") { root.action(Action.toggle-mute); return accept; }
if (e.text == "s") { root.action(Action.cycle-shuffle); return accept; }
if (e.text == "S") { root.action(Action.shuffle); 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;
password-shown <=> root.login-password-shown;
focus-index: root.login-focus;
error: root.login-error;
busy: root.login-busy;
submit => { root.login-submit(); }
can-cancel: root.login-can-cancel;
exit => { root.action(root.login-can-cancel ? Action.back : Action.quit); }
field-clicked(i) => { root.login-field-clicked(i); }
known: root.login-known;
known-selected: root.login-known-selected;
known-clicked(i) => { root.login-known-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;
volume: root.volume;
muted: root.muted;
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;
shuffle: root.np-shuffle;
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.confirm-shown: ConfirmDialog {
title: root.confirm-title;
message: root.confirm-message;
choices: root.confirm-choices;
selected: root.confirm-selected;
clicked(i) => { root.confirm-clicked(i); }
}
VolumeOverlay {
x: (parent.width - self.width) / 2;
y: parent.height - self.height - 32px * Theme.s;
shown: root.volume-shown;
level: root.volume;
muted: root.muted;
}
}
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;
volume: root.volume;
muted: root.muted;
}
// Optional, except on the login screen, where the controls are
// not known yet and Settings cannot be reached.
if root.show-hint-bar || root.screen == Screen.login: HintBar {
height: 46px * Theme.s;
hints: root.hints;
version: root.version;
}
}
}
}