Blend the colour wash between titles and keep full screen for the miniplayer

- The backdrop's colour wash is one layer whose corner colours are
  registered custom properties, so a change of title blends them instead
  of stacking a half-opacity layer and removing the old one (which made
  the colour jump). Outgoing artwork fades out before it is removed, and
  quick changes keep the layer that is on screen.
- Going to the miniplayer no longer leaves full screen. Esc while
  browsing leaves full screen first, Windows' caption buttons show Exit
  full screen in place of maximize, closing the miniplayer keeps the
  window as it is, and the player's full-screen state follows changes
  made outside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-06 19:29:16 -07:00
parent 8755d16735
commit b5dc5d8666
6 changed files with 135 additions and 54 deletions

View file

@ -11,7 +11,7 @@ import { PageLoader } from '../ui/primitives';
import { Splash } from '../screens/Splash'; import { Splash } from '../screens/Splash';
import { SignIn } from '../screens/SignIn'; import { SignIn } from '../screens/SignIn';
import { ServerPicker } from '../screens/ServerPicker'; import { ServerPicker } from '../screens/ServerPicker';
import { isMac, win } from '../platform/native'; import { isMac, isNative, win } from '../platform/native';
import { usePlayer } from '../player/store'; import { usePlayer } from '../player/store';
import { PlayerOverlay } from '../player/PlayerOverlay'; import { PlayerOverlay } from '../player/PlayerOverlay';
import { DialogHost } from '../screens/dialogs/DialogHost'; import { DialogHost } from '../screens/dialogs/DialogHost';
@ -111,7 +111,9 @@ function useGlobalShortcuts() {
win.isFullscreen().then((fs) => win.setFullscreen(!fs)); win.isFullscreen().then((fs) => win.setFullscreen(!fs));
} else if ((e.key === 'Escape' || e.key === 'Backspace') && !isTyping(e.target) && !document.querySelector('.menu-layer, .dialog-layer')) { } else if ((e.key === 'Escape' || e.key === 'Backspace') && !isTyping(e.target) && !document.querySelector('.menu-layer, .dialog-layer')) {
if (e.key === 'Escape' && document.fullscreenElement) return; if (e.key === 'Escape' && document.fullscreenElement) return;
useRouter.getState().back(); // Esc leaves full screen first (kept from the player when it went to the corner).
if (e.key === 'Escape' && isNative) win.isFullscreen().then((fs) => (fs ? win.setFullscreen(false) : useRouter.getState().back()));
else useRouter.getState().back();
} else if ((e.ctrlKey || e.metaKey) && e.key === ',') { } else if ((e.ctrlKey || e.metaKey) && e.key === ',') {
e.preventDefault(); e.preventDefault();
navigate({ name: 'settings', mode: 'app', tab: 'general' }); navigate({ name: 'settings', mode: 'app', tab: 'general' });

View file

@ -19,13 +19,21 @@ const NAV = [
/** Caption buttons drawn by the page; macOS shows its own traffic lights instead. */ /** Caption buttons drawn by the page; macOS shows its own traffic lights instead. */
export function WindowControls() { export function WindowControls() {
const [maximized, setMaximized] = useState(false); const [maximized, setMaximized] = useState(false);
const [fullscreen, setFullscreen] = useState(false);
useEffect(() => { useEffect(() => {
if (!isNative || isMac) return; if (!isNative || isMac) return;
let off: (() => void) | undefined; let off: (() => void) | undefined;
const sync = () => win.isMaximized().then(setMaximized); let gone = false;
const sync = () => {
win.isMaximized().then((m) => !gone && setMaximized(m));
win.isFullscreen().then((f) => !gone && setFullscreen(f));
};
sync(); sync();
win.onResized(sync).then((u) => (off = u)); win.onResized(sync).then((u) => (gone ? u() : (off = u)));
return () => off?.(); return () => {
gone = true;
off?.();
};
}, []); }, []);
if (!isNative || isMac) return null; if (!isNative || isMac) return null;
return ( return (
@ -33,9 +41,15 @@ export function WindowControls() {
<button aria-label="Minimize" onClick={() => win.minimize()}> <button aria-label="Minimize" onClick={() => win.minimize()}>
<Icon name="minimize" size={15} strokeWidth={1.4} /> <Icon name="minimize" size={15} strokeWidth={1.4} />
</button> </button>
<button aria-label={maximized ? 'Restore' : 'Maximize'} onClick={() => win.toggleMaximize()}> {fullscreen ? (
<Icon name={maximized ? 'restore' : 'maximize'} size={13} strokeWidth={1.4} /> <button aria-label="Exit full screen" title="Exit full screen (Esc)" onClick={() => win.setFullscreen(false)}>
</button> <Icon name="collapse" size={14} strokeWidth={1.4} />
</button>
) : (
<button aria-label={maximized ? 'Restore' : 'Maximize'} onClick={() => win.toggleMaximize()}>
<Icon name={maximized ? 'restore' : 'maximize'} size={13} strokeWidth={1.4} />
</button>
)}
<button aria-label="Close" className="close" onClick={() => win.close()}> <button aria-label="Close" className="close" onClick={() => win.close()}>
<Icon name="x" size={15} strokeWidth={1.4} /> <Icon name="x" size={15} strokeWidth={1.4} />
</button> </button>

View file

@ -174,17 +174,24 @@ export function plural(n: number, word: string, pluralWord = `${word}s`) {
return `${n.toLocaleString()} ${n === 1 ? word : pluralWord}`; return `${n.toLocaleString()} ${n === 1 ? word : pluralWord}`;
} }
/** Hex UltraBlur colors → CSS gradient layers for the artwork colour wash. */ /** Hex UltraBlur colors → the wash's four corner colours, each at its own strength. */
export function washGradient(u: Item['ultraBlur'], strength = 1): string { export function washColors(u: Item['ultraBlur'], strength = 1) {
if (!u) return ''; if (!u) return null;
const c = (hex: string, a: number) => { const c = (hex: string, a: number) => {
const n = parseInt(hex, 16); const n = parseInt(hex, 16);
return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${(a * strength).toFixed(3)})`; return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${(a * strength).toFixed(3)})`;
}; };
return { topRight: c(u.topRight, 0.95), topLeft: c(u.topLeft, 0.7), bottomRight: c(u.bottomRight, 0.55), bottomLeft: c(u.bottomLeft, 0.45) };
}
/** Hex UltraBlur colors → CSS gradient layers for the artwork colour wash. */
export function washGradient(u: Item['ultraBlur'], strength = 1): string {
const c = washColors(u, strength);
if (!c) return '';
return [ return [
`radial-gradient(ellipse at 100% 0%, ${c(u.topRight, 0.95)} 0%, transparent 62%)`, `radial-gradient(ellipse at 100% 0%, ${c.topRight} 0%, transparent 62%)`,
`radial-gradient(ellipse at 0% 0%, ${c(u.topLeft, 0.7)} 0%, transparent 55%)`, `radial-gradient(ellipse at 0% 0%, ${c.topLeft} 0%, transparent 55%)`,
`radial-gradient(ellipse at 100% 100%, ${c(u.bottomRight, 0.55)} 0%, transparent 60%)`, `radial-gradient(ellipse at 100% 100%, ${c.bottomRight} 0%, transparent 60%)`,
`radial-gradient(ellipse at 0% 100%, ${c(u.bottomLeft, 0.45)} 0%, transparent 60%)`, `radial-gradient(ellipse at 0% 100%, ${c.bottomLeft} 0%, transparent 60%)`,
].join(', '); ].join(', ');
} }

View file

@ -702,10 +702,12 @@ export const usePlayer = create<PlayerState>((set, get) => ({
playServer = s; playServer = s;
playDownload = download; playDownload = download;
localScrobbled = false; localScrobbled = false;
// From the miniplayer the window may have gone full screen (or left it) since.
const fullscreenNow = await win.isFullscreen().catch(() => false);
if (stale()) return;
if (!previous.open) { if (!previous.open) {
triedFallback = false; triedFallback = false;
wasFullscreenBeforePlay = await win.isFullscreen().catch(() => false); wasFullscreenBeforePlay = fullscreenNow;
if (stale()) return;
} }
set({ set({
open: true, open: true,
@ -730,7 +732,7 @@ export const usePlayer = create<PlayerState>((set, get) => ({
audioKey: opts.tracks?.audioKey ?? '', audioKey: opts.tracks?.audioKey ?? '',
subKey: opts.tracks?.subKey ?? '__init', subKey: opts.tracks?.subKey ?? '__init',
video: null, video: null,
fullscreen: wasFullscreenBeforePlay, fullscreen: fullscreenNow,
mini: false, mini: false,
videoGamma: '', videoGamma: '',
enhance: { ...previous.enhance, bypass: false, preparing: false }, enhance: { ...previous.enhance, bypass: false, preparing: false },
@ -856,8 +858,12 @@ export const usePlayer = create<PlayerState>((set, get) => ({
await mpv.show(false).catch(() => {}); await mpv.show(false).catch(() => {});
} }
set({ open: false, mini: false, item: null, delivery: null, error: '', terminated: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false }); set({ open: false, mini: false, item: null, delivery: null, error: '', terminated: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false });
const fs = await win.isFullscreen().catch(() => false); // Closing the full player hands back the window it found; closing the
if (fs && !wasFullscreenBeforePlay) win.setFullscreen(false); // miniplayer leaves browsing as it is, full screen or not.
if (!st.mini) {
const fs = await win.isFullscreen().catch(() => false);
if (fs && !wasFullscreenBeforePlay) win.setFullscreen(false);
}
if (st.item) invalidateLibrary(); if (st.item) invalidateLibrary();
}, },
@ -913,12 +919,8 @@ export const usePlayer = create<PlayerState>((set, get) => ({
async minimize() { async minimize() {
const st = get(); const st = get();
if (!st.open || st.mini) return; if (!st.open || st.mini) return;
// Full screen stays for browsing; Esc or the window controls leave it.
set({ mini: true }); set({ mini: true });
// Full screen was for the video; browsing goes back to the window.
if (st.fullscreen && !wasFullscreenBeforePlay) {
await win.setFullscreen(false).catch(() => {});
set({ fullscreen: false });
}
if (separateMini) { if (separateMini) {
// Once the page is opaque again (no video in it), the video moves into // Once the page is opaque again (no video in it), the video moves into
// the miniplayer's own window (miniWindow.ts). // the miniplayer's own window (miniWindow.ts).
@ -1025,6 +1027,13 @@ usePlayer.subscribe((st, prev) => {
bridgeMiniWindow(usePlayer); bridgeMiniWindow(usePlayer);
// Full screen can change outside the player (Esc or the window controls while
// browsing with the miniplayer, the OS): the player's controls follow it.
win.onResized(() => {
if (!usePlayer.getState().open) return;
win.isFullscreen().then((fs) => usePlayer.getState().fullscreen !== fs && usePlayer.setState({ fullscreen: fs }), () => {});
});
/** /**
* Signing out, or switching server or profile, ends a stream from the old one: its * Signing out, or switching server or profile, ends a stream from the old one: its
* progress belongs to that account. A download keeps playing, without reporting. * progress belongs to that account. A download keeps playing, without reporting.

View file

@ -515,6 +515,12 @@ html.splash-arrival .auth-screen {
.backdrop-layer.ready { .backdrop-layer.ready {
opacity: 1; opacity: 1;
} }
/* The outgoing art fades too, a beat behind the incoming, so nothing of it is
left to vanish through the new art's faded edges. */
.backdrop-layer.ready.leaving {
opacity: 0;
transition-delay: 180ms;
}
/* The colour wash lives outside the clipped backdrop so it can carry on down /* The colour wash lives outside the clipped backdrop so it can carry on down
the page behind the rows, fading out as it goes. */ the page behind the rows, fading out as it goes. */
.backdrop-tint { .backdrop-tint {
@ -528,14 +534,42 @@ html.splash-arrival .auth-screen {
-webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%); -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%); mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
} }
/* Registered as colours so a change of title blends the wash from one set of
colours to the next, instead of swapping the gradient outright. */
@property --wash-tr {
syntax: '<color>';
inherits: false;
initial-value: transparent;
}
@property --wash-tl {
syntax: '<color>';
inherits: false;
initial-value: transparent;
}
@property --wash-br {
syntax: '<color>';
inherits: false;
initial-value: transparent;
}
@property --wash-bl {
syntax: '<color>';
inherits: false;
initial-value: transparent;
}
.backdrop-wash { .backdrop-wash {
position: absolute; position: absolute;
inset: 0; inset: 0;
opacity: 0;
transition: opacity 420ms var(--ease);
}
.backdrop-wash.ready {
opacity: 0.5; opacity: 0.5;
background:
radial-gradient(ellipse at 100% 0%, var(--wash-tr) 0%, transparent 62%),
radial-gradient(ellipse at 0% 0%, var(--wash-tl) 0%, transparent 55%),
radial-gradient(ellipse at 100% 100%, var(--wash-br) 0%, transparent 60%),
radial-gradient(ellipse at 0% 100%, var(--wash-bl) 0%, transparent 60%);
transition:
--wash-tr 700ms var(--ease),
--wash-tl 700ms var(--ease),
--wash-br 700ms var(--ease),
--wash-bl 700ms var(--ease);
} }
.backdrop-art { .backdrop-art {
position: absolute; position: absolute;

View file

@ -1,21 +1,25 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState, type CSSProperties } from 'react';
import type { Item } from '../plex/types'; import type { Item } from '../plex/types';
import { useServer } from '../app/session'; import { useServer } from '../app/session';
import { useSettings } from '../app/settings'; import { useSettings } from '../app/settings';
import { art, washGradient } from '../app/format'; import { art, washColors } from '../app/format';
interface Layer { interface Layer {
key: number; key: number;
src: string; src: string;
wash: string; blur: Item['ultraBlur'];
ready: boolean; ready: boolean;
} }
/** How long an outgoing layer lingers: its fade (with delay) plus a margin. */
const LEAVE_MS = 700;
/** /**
* Artwork-led page background. The image sits top-right and fades into the * Artwork-led page background. The image sits top-right and fades into the
* page toward its left and bottom edges; the UltraBlur colour wash tints the * page toward its left and bottom edges; the UltraBlur colour wash tints the
* page beneath it and carries on down behind the rows. Changes crossfade; the * page beneath it and carries on down behind the rows. Artwork crossfades
* outgoing layer stays until the new image has decoded. * once the new image has decoded, and the wash's colours blend into the new
* title's at the same moment (registered custom properties, app.css).
*/ */
export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) { export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) {
const server = useServer(); const server = useServer();
@ -25,39 +29,50 @@ export function Backdrop({ item, className = '', width = 1600, height = 900, was
const path = item ? art.backdrop(item) : ''; const path = item ? art.backdrop(item) : '';
const src = path ? server.image(path, width, height) : ''; const src = path ? server.image(path, width, height) : '';
const blur = forceWash ?? item?.ultraBlur ?? null; const blur = forceWash ?? item?.ultraBlur ?? null;
const wash = colorWash && blur ? washGradient(blur) : ''; const blurKey = blur ? `${blur.topLeft}${blur.topRight}${blur.bottomRight}${blur.bottomLeft}` : '';
useEffect(() => { useEffect(() => {
if (!src && !wash) return; if (!src && !blur) return;
setLayers((prev) => { setLayers((prev) => {
if (prev.length && prev[prev.length - 1].src === src) { const last = prev[prev.length - 1];
// Same art, maybe new wash. // Same art, maybe new colours: the wash blends to them in place.
return prev.map((l, i) => (i === prev.length - 1 ? { ...l, wash } : l)); if (last && last.src === src) return prev.map((l) => (l === last ? { ...l, blur } : l));
} // Keep only what is on screen (the newest layer that has shown) under the new one.
return [...prev.slice(-1), { key: ++counter.current, src, wash, ready: !src }]; const shown = prev.filter((l) => l.ready).slice(-1);
return [...shown, { key: ++counter.current, src, blur, ready: !src }];
}); });
}, [src, wash]); }, [src, blurKey]);
const onReady = (key: number) => const onReady = (key: number) => setLayers((prev) => (prev.some((l) => l.key === key && !l.ready) ? prev.map((l) => (l.key === key ? { ...l, ready: true } : l)) : prev));
setLayers((prev) => {
const idx = prev.findIndex((l) => l.key === key); // Once the newest layer is in, the ones beneath fade out and then go.
if (idx < 0) return prev; const newest = layers[layers.length - 1];
const next = prev.map((l) => (l.key === key ? { ...l, ready: true } : l)); useEffect(() => {
// Drop older layers once the newest is visible (after its fade). if (!newest?.ready || layers.length < 2) return;
setTimeout(() => setLayers((p) => (p.length > 1 && p[p.length - 1].key === key ? p.slice(-1) : p)), 500); const t = setTimeout(() => setLayers((p) => (p[p.length - 1]?.key === newest.key ? p.slice(-1) : p)), LEAVE_MS);
return next; return () => clearTimeout(t);
}); }, [newest?.key, newest?.ready, layers.length]);
let top = -1;
layers.forEach((l, i) => l.ready && (top = i));
const colors = top >= 0 ? washColors(layers[top].blur) : null;
const washStyle = {
'--wash-tr': colors?.topRight ?? 'transparent',
'--wash-tl': colors?.topLeft ?? 'transparent',
'--wash-br': colors?.bottomRight ?? 'transparent',
'--wash-bl': colors?.bottomLeft ?? 'transparent',
} as CSSProperties;
return ( return (
<> <>
{colorWash && ( {colorWash && (
<div className={`backdrop-tint ${className}`} aria-hidden="true"> <div className={`backdrop-tint ${className}`} aria-hidden="true">
{layers.map((l) => l.wash && <div key={l.key} className={`backdrop-wash${l.ready ? ' ready' : ''}`} style={{ background: l.wash }} />)} <div className="backdrop-wash" style={washStyle} />
</div> </div>
)} )}
<div className={`backdrop ${className}${colorWash ? ' washed' : ''}`} aria-hidden="true"> <div className={`backdrop ${className}${colorWash ? ' washed' : ''}`} aria-hidden="true">
{layers.map((l) => ( {layers.map((l, i) => (
<div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}`}> <div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}${i < top ? ' leaving' : ''}`}>
{l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />} {l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />}
</div> </div>
))} ))}