// 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. 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, } 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 { key: string, label: string } export global Theme { in-out property s: 1.0; out property bg: #0d0f13; out property panel: #14171d; out property raised: #1e222a; out property line: #2a2f39; out property text: #f3f4f6; out property muted: #a0a7b4; out property faint: #626a78; out property accent: #8ab4ff; out property on-accent: #0d0f13; } component Art inherits Rectangle { in property source; in property has-image; in property tint: #39404d; in property letter; in property round; in property 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-weight: 800; color: #ffffff60; 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; in property selected; in property active; in property art; callback clicked; property 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.accent : 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; in property selected; in property 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.accent; 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.accent : 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.accent : Theme.text; overflow: elide; } if root.item.subtitle != "": Text { text: root.item.subtitle; font-size: 14px * Theme.s; color: Theme.muted; overflow: elide; } } Text { text: root.item.detail; font-size: 15px * Theme.s; color: Theme.muted; 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 count; in property selected; in property list-mode; in property active: true; in property status; callback item-clicked(int); callback wheel(int); property gap: 26px * Theme.s; property min-art: 170px * Theme.s; property pad: 8px * Theme.s; out property columns: root.list-mode ? 1 : max(1, floor((root.width - 2 * root.pad + root.gap) / (root.min-art + root.gap))); out property art: root.list-mode ? 0px : (root.width - 2 * root.pad - (root.columns - 1) * root.gap) / root.columns; property row-h: root.list-mode ? 70px * Theme.s : root.art + 64px * Theme.s + root.gap; property total-rows: ceil(root.count / root.columns); property sel-row: floor(root.selected / root.columns); property max-scroll: max(0px, root.total-rows * root.row-h + 2 * root.pad - root.height); property 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
h; property 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: 13px * Theme.s; font-weight: 700; letter-spacing: 2px * Theme.s; color: Theme.accent; } Text { text: root.h.title; font-size: 40px * Theme.s; font-weight: 800; 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 current; in property active; in property footer; callback clicked(int); background: Theme.panel; VerticalLayout { padding: 26px * Theme.s; padding-top: 34px * Theme.s; spacing: 6px * Theme.s; alignment: start; Text { text: "remus"; font-size: 30px * Theme.s; font-weight: 800; color: Theme.text; } 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 text; in property 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.accent : 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; } } component NowBar inherits Rectangle { in property has-track; in property title; in property artist; in property cover; in property has-cover; in property tint; in property letter; in property progress; in property time; in property 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.accent; } } 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: Text { text: root.paused ? "❚❚" : "▶"; font-size: 18px * Theme.s; color: Theme.accent; vertical-alignment: center; } } } component HintBar inherits Rectangle { in property <[Hint]> hints; pure function key-color(k: string) -> color { if (k == "A") { return #3fb950; } if (k == "B") { return #f0605d; } if (k == "X") { return #4d8ff7; } if (k == "Y") { return #e3b341; } return Theme.line; } 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; VerticalLayout { alignment: center; Rectangle { min-width: 26px * Theme.s; height: 26px * Theme.s; border-radius: 13px * Theme.s; background: root.key-color(h.key); HorizontalLayout { padding-left: 8px * Theme.s; padding-right: 8px * Theme.s; Text { text: h.key; font-size: 12px * Theme.s; font-weight: 800; color: #ffffff; horizontal-alignment: center; vertical-alignment: center; } } } } Text { text: h.label; font-size: 14px * Theme.s; color: Theme.muted; vertical-alignment: center; } } } } component Field inherits VerticalLayout { in property label; in-out property text; in property password; in property 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.accent : 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 server; in-out property username; in-out property password; in property focus-index; in property error; in property busy; callback submit; 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(); } } 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; Text { text: "remus"; font-size: 38px * Theme.s; font-weight: 800; color: Theme.text; } 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(); } } } if root.error != "": Text { text: root.error; font-size: 15px * Theme.s; color: #f0605d; 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 title; in property artist; in property album; in property cover; in property has-cover; in property tint; in property letter; in property progress; in property position; in property duration; in property paused; in property has-track; in property <[Item]> queue; in property queue-count; in property 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 art-size: 440px * Theme.s; // Blown-up cover as a dim backdrop. if root.has-cover: Image { width: parent.width; height: parent.height; source: root.cover; image-fit: ImageFit.cover; opacity: 0.16; } Rectangle { background: @linear-gradient(90deg, #0d0f13aa, #0d0f13f2); } 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 { width: root.art-size; height: root.art-size; 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: 30px * Theme.s; font-weight: 800; 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.accent; } } HorizontalLayout { Text { text: root.position; font-size: 14px * Theme.s; color: Theme.muted; } Text { horizontal-stretch: 1; text: root.has-track ? (root.paused ? "Paused" : "Playing") : ""; font-size: 14px * Theme.s; color: Theme.accent; horizontal-alignment: center; } 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: 26px * Theme.s; font-weight: 800; 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); } } } } } 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.login; in property area: Area.sidebar; // Login in-out property login-server; in-out property login-username; in-out property login-password; in property login-focus; in property login-error; in property login-busy; // Browse in property <[string]> sections; in property section; in property server-label; in property page-title; in property page-loading; in property
header; in property is-search; in-out property search-text; in property <[Item]> items; in property item-count; in property selected; in property list-mode; in property status; out property grid-columns: view.columns; out property grid-art: view.art; // Playback in property np-has-track; in property np-title; in property np-artist; in property np-album; in property np-cover; in property np-has-cover; in property np-tint; in property np-letter; in property np-progress; in property np-position; in property np-duration; in property np-paused; in property <[Item]> queue-items; in property queue-count; in property queue-selected; out property np-art-size: np.art-size; in property <[Hint]> hints; in property toast; 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(); } 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: 30px * Theme.s; font-weight: 800; 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; 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; } } } }