From a274e602ece7a8ce8a2aa33d20e21381d13bafe0 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Tue, 16 Jun 2026 15:55:45 -0600 Subject: [PATCH] feat(slint): use immersive blur in album and artist headers cx --- crates/qbz-slint/src/album.rs | 6 ++++ crates/qbz-slint/src/artist.rs | 6 ++++ crates/qbz-slint/src/immersive.rs | 13 ++++++++ crates/qbz-slint/ui/album/AlbumPageView.slint | 31 +++++++++++++++++-- .../qbz-slint/ui/artist/ArtistPageView.slint | 31 +++++++++++++++++-- crates/qbz-slint/ui/state.slint | 8 +++-- 6 files changed, 87 insertions(+), 8 deletions(-) diff --git a/crates/qbz-slint/src/album.rs b/crates/qbz-slint/src/album.rs index afb89d824..71b98f8c1 100644 --- a/crates/qbz-slint/src/album.rs +++ b/crates/qbz-slint/src/album.rs @@ -437,6 +437,7 @@ pub fn reset_album(window: &AppWindow) { state.set_selected_count(0); state.set_tracks(ModelRc::new(VecModel::from(Vec::::new()))); state.set_artwork(slint::Image::default()); + state.set_header_atmosphere(slint::Image::default()); // Clear the booklet gate so the previous album's value doesn't linger. state.set_has_booklet(false); state.set_album_fully_cached(false); @@ -555,6 +556,11 @@ pub fn apply_artwork(window: &AppWindow, pixels: &[u8], width: u32, height: u32) let state = window.global::(); state.set_artwork(slint::Image::from_rgba8(buffer)); state.set_header_color(slint::Color::from_rgb_u8(r, g, b)); + if let Some(atmosphere) = crate::immersive::generate_atmosphere_image(pixels, width, height) { + state.set_header_atmosphere(atmosphere); + } else { + state.set_header_atmosphere(slint::Image::default()); + } } #[cfg(test)] diff --git a/crates/qbz-slint/src/artist.rs b/crates/qbz-slint/src/artist.rs index 63a2374fa..cc99079cd 100644 --- a/crates/qbz-slint/src/artist.rs +++ b/crates/qbz-slint/src/artist.rs @@ -699,6 +699,7 @@ pub fn reset_artist(window: &AppWindow) { state.set_similar_artists(ModelRc::new(VecModel::from(Vec::::new()))); state.set_jump_tabs(ModelRc::new(VecModel::from(Vec::::new()))); state.set_artwork(slint::Image::default()); + state.set_header_atmosphere(slint::Image::default()); state.set_name("".into()); state.set_bio("".into()); state.set_bio_source("".into()); @@ -795,6 +796,11 @@ pub fn apply_artwork(window: &AppWindow, pixels: &[u8], width: u32, height: u32) let state = window.global::(); state.set_artwork(slint::Image::from_rgba8(buffer)); state.set_header_color(slint::Color::from_rgb_u8(r, g, b)); + if let Some(atmosphere) = crate::immersive::generate_atmosphere_image(pixels, width, height) { + state.set_header_atmosphere(atmosphere); + } else { + state.set_header_atmosphere(slint::Image::default()); + } } // ----- MusicBrainz network sidebar --------------------------------------- diff --git a/crates/qbz-slint/src/immersive.rs b/crates/qbz-slint/src/immersive.rs index d06d867b0..a4be88c77 100644 --- a/crates/qbz-slint/src/immersive.rs +++ b/crates/qbz-slint/src/immersive.rs @@ -21,6 +21,19 @@ pub fn generate_atmosphere(pixels: &[u8], width: u32, height: u32) -> Option<(Ve Some((final_img.into_raw(), 128, 128)) } +/// Static Slint image for album/artist headers that reuse Immersive's blurred +/// artwork atmosphere without mounting the animated full-screen scene. +pub fn generate_atmosphere_image(pixels: &[u8], width: u32, height: u32) -> Option { + let (bg_pixels, bg_w, bg_h) = generate_atmosphere(pixels, width, height)?; + let mut buffer = slint::SharedPixelBuffer::::new(bg_w, bg_h); + let dst = buffer.make_mut_bytes(); + if dst.len() != bg_pixels.len() { + return None; + } + dst.copy_from_slice(&bg_pixels); + Some(slint::Image::from_rgba8(buffer)) +} + /// AlbumReactive glow color: the most saturated non-extreme 8x8 sample. pub fn glow_color(pixels: &[u8], width: u32, height: u32) -> Color { let Some(src) = RgbaImage::from_raw(width, height, pixels.to_vec()) else { diff --git a/crates/qbz-slint/ui/album/AlbumPageView.slint b/crates/qbz-slint/ui/album/AlbumPageView.slint index d11c69e4b..000b078a1 100644 --- a/crates/qbz-slint/ui/album/AlbumPageView.slint +++ b/crates/qbz-slint/ui/album/AlbumPageView.slint @@ -24,6 +24,7 @@ import { ListScrollbar } from "../primitives/ListScrollbar.slint"; import { CircleAction } from "../primitives/CircleAction.slint"; import { MultiSelectBar } from "../primitives/MultiSelectBar.slint"; import { NavButtons } from "../shell/NavButtons.slint"; +import { ImmersiveAtmosphere } from "../immersive/ImmersiveAtmosphere.slint"; // One label/award entry in the album sidebar — a round gradient avatar // and a name. In `compact` mode the name is dropped (the rail is an @@ -145,17 +146,41 @@ export component AlbumPageView inherits Rectangle { changed viewport-height => { self.sr-restore(); } changed viewport-y => { NavState.report-scroll(self.viewport-y); } - // Artwork-tinted gradient behind the header; scrolls with content. - Rectangle { + // Static Immersive-style blurred artwork field behind the header; + // scrolls with content. The old tint gradient remains the fallback + // until artwork decoding finishes. + if AlbumState.header-atmosphere.width > 0: ImmersiveAtmosphere { x: 0; y: 0; width: parent.width; - height: 340px; + height: 360px; + source-image: AlbumState.header-atmosphere; + fallback-image: AlbumState.artwork; + animated: false; + dim: 0.24; + base-opacity: 0.92; + warp-opacity: 0.38; + } + if AlbumState.header-atmosphere.width <= 0: Rectangle { + x: 0; + y: 0; + width: parent.width; + height: 360px; background: @linear-gradient(180deg, AlbumState.header-color 0%, AlbumState.header-color 16%, transparent 100%); } + Rectangle { + x: 0; + y: 0; + width: parent.width; + height: 360px; + background: @linear-gradient(180deg, + transparent 0%, + transparent 58%, + Theme.surface-main 100%); + } page := VerticalLayout { width: parent.width; diff --git a/crates/qbz-slint/ui/artist/ArtistPageView.slint b/crates/qbz-slint/ui/artist/ArtistPageView.slint index 69eb3f153..a92b05ae1 100644 --- a/crates/qbz-slint/ui/artist/ArtistPageView.slint +++ b/crates/qbz-slint/ui/artist/ArtistPageView.slint @@ -33,6 +33,7 @@ import { ReleaseGrid } from "ReleaseGrid.slint"; import { NavButtons } from "../shell/NavButtons.slint"; import { JumpNavBar, JumpNavTab } from "../primitives/JumpNavBar.slint"; import { CircleAction } from "../primitives/CircleAction.slint"; +import { ImmersiveAtmosphere } from "../immersive/ImmersiveAtmosphere.slint"; component SectionTitle inherits Text { color: Theme.text-primary; @@ -167,17 +168,41 @@ export component ArtistPageView inherits Rectangle { changed viewport-height => { self.sr-restore(); } changed viewport-y => { NavState.report-scroll(self.viewport-y); } - // Artwork-tinted gradient behind the header; scrolls with content. - Rectangle { + // Static Immersive-style blurred artwork field behind the header; + // scrolls with content. The old tint gradient remains the fallback + // until artwork decoding finishes. + if ArtistState.header-atmosphere.width > 0: ImmersiveAtmosphere { x: 0; y: 0; width: parent.width; - height: 340px; + height: 360px; + source-image: ArtistState.header-atmosphere; + fallback-image: ArtistState.artwork; + animated: false; + dim: 0.24; + base-opacity: 0.92; + warp-opacity: 0.38; + } + if ArtistState.header-atmosphere.width <= 0: Rectangle { + x: 0; + y: 0; + width: parent.width; + height: 360px; background: @linear-gradient(180deg, ArtistState.header-color 0%, ArtistState.header-color 16%, transparent 100%); } + Rectangle { + x: 0; + y: 0; + width: parent.width; + height: 360px; + background: @linear-gradient(180deg, + transparent 0%, + transparent 58%, + Theme.surface-main 100%); + } page := VerticalLayout { width: parent.width; diff --git a/crates/qbz-slint/ui/state.slint b/crates/qbz-slint/ui/state.slint index dbabef720..9df60379d 100644 --- a/crates/qbz-slint/ui/state.slint +++ b/crates/qbz-slint/ui/state.slint @@ -406,7 +406,9 @@ export global AlbumState { // tracks keep priority. Falls back to the full short text when there's room. in property description-shorter; in property artwork; - // Artwork-derived tint for the header gradient. + // Static Immersive-style blurred artwork field for the header backdrop. + in property header-atmosphere; + // Artwork-derived tint for the header fallback gradient. in property header-color: #181820; in property label; // Label id for the sidebar label card → label page navigation ("" = none). @@ -2664,7 +2666,9 @@ export global ArtistState { // "Source: " line under the Read more toggle when present. in property bio-source; in property artwork; - // Artwork-derived tint for the header gradient. + // Static Immersive-style blurred artwork field for the header backdrop. + in property header-atmosphere; + // Artwork-derived tint for the header fallback gradient. in property header-color: #181820; in property <[TrackItem]> top-tracks: []; // Popular Tracks multi-select (track selection) mode + selected count —