// 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 } export global Theme { in-out property 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 bg: #140b0c; in-out property panel: #1d1012; in-out property raised: #2b181b; in-out property line: #42272b; in-out property text: #faebda; in-out property muted: #bea999; in-out property faint: #80685f; // Filled surfaces: the current section, buttons, the playing badge. in-out property accent: #a51d2d; in-out property on-accent: #faebda; // Accent for text and thin lines, where the fill colour is too dark to read. in-out property highlight: #e8757b; // Ring around whatever has focus. in-out property focus: #faebda; // Tops of the sidebar and login backgrounds. in-out property glow: #2a0b11; in-out property login-glow: #3a0b13; // Not part of the palette: errors stay red whatever the album art. out property error: #f0605d; out property serif: "Noto Serif"; } component Art inherits Rectangle { in property source; in property has-image; in property tint: Theme.raised; 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-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; 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.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; 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.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 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: 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 current; in property active; in property 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 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.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 paused; in property tint: Theme.highlight; in property 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 muted; in property tint: Theme.text; in property 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 level; in property muted; in property 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 balanced; // Fixed, so the bar does not shift as the number changes, and wide enough // for "Muted". property 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. component VolumeOverlay inherits Rectangle { in property shown; in property level; in property 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 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; in property volume; in property 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 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 label; in-out property text; in property password; // A password field shows its text while this is set, toggled by the eye. in-out property shown; 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.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 server; in-out property username; in-out property password; in-out property password-shown; in property focus-index; in property error; in property busy; // Adding a server from inside the app: the bottom button goes back. in property can-cancel; 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; 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(); } } } // 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: root.can-cancel ? "Cancel" : "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 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; // 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 volume: 100; in property muted; in property backdrop-opacity: 0.16; in property backdrop-left: 0.67; in property 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 flip-out; in property <[Item]> queue; in property queue-count; in property queue-selected; // How the queue is shuffled, empty when it plays in order. in property 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 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 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; in property login-can-cancel; in-out property login-password-shown; // 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 np-shuffle; in property np-flip-out; in property np-backdrop-opacity: 0.16; in property np-backdrop-left: 0.67; in property np-backdrop-right: 0.95; 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; // The volume overlay, shown briefly after any volume change. in property volume-shown; in property volume; in property muted; in property version; in property show-hint-bar: true; 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; } // = 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); } } 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; } } 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; } } } }