feat(slint): use immersive blur in album and artist headers
cx
This commit is contained in:
6 files changed
+87
-8
No files matched your search
@@ -437,6 +437,7 @@ pub fn reset_album(window: &AppWindow) {
|
|||||||
state.set_selected_count(0);
|
state.set_selected_count(0);
|
||||||
state.set_tracks(ModelRc::new(VecModel::from(Vec::<TrackItem>::new())));
|
state.set_tracks(ModelRc::new(VecModel::from(Vec::<TrackItem>::new())));
|
||||||
state.set_artwork(slint::Image::default());
|
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.
|
// Clear the booklet gate so the previous album's value doesn't linger.
|
||||||
state.set_has_booklet(false);
|
state.set_has_booklet(false);
|
||||||
state.set_album_fully_cached(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::<AlbumState>();
|
let state = window.global::<AlbumState>();
|
||||||
state.set_artwork(slint::Image::from_rgba8(buffer));
|
state.set_artwork(slint::Image::from_rgba8(buffer));
|
||||||
state.set_header_color(slint::Color::from_rgb_u8(r, g, b));
|
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)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -699,6 +699,7 @@ pub fn reset_artist(window: &AppWindow) {
|
|||||||
state.set_similar_artists(ModelRc::new(VecModel::from(Vec::<SimilarEntry>::new())));
|
state.set_similar_artists(ModelRc::new(VecModel::from(Vec::<SimilarEntry>::new())));
|
||||||
state.set_jump_tabs(ModelRc::new(VecModel::from(Vec::<JumpNavTab>::new())));
|
state.set_jump_tabs(ModelRc::new(VecModel::from(Vec::<JumpNavTab>::new())));
|
||||||
state.set_artwork(slint::Image::default());
|
state.set_artwork(slint::Image::default());
|
||||||
|
state.set_header_atmosphere(slint::Image::default());
|
||||||
state.set_name("".into());
|
state.set_name("".into());
|
||||||
state.set_bio("".into());
|
state.set_bio("".into());
|
||||||
state.set_bio_source("".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::<ArtistState>();
|
let state = window.global::<ArtistState>();
|
||||||
state.set_artwork(slint::Image::from_rgba8(buffer));
|
state.set_artwork(slint::Image::from_rgba8(buffer));
|
||||||
state.set_header_color(slint::Color::from_rgb_u8(r, g, b));
|
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 ---------------------------------------
|
// ----- MusicBrainz network sidebar ---------------------------------------
|
||||||
|
|||||||
@@ -21,6 +21,19 @@ pub fn generate_atmosphere(pixels: &[u8], width: u32, height: u32) -> Option<(Ve
|
|||||||
Some((final_img.into_raw(), 128, 128))
|
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<slint::Image> {
|
||||||
|
let (bg_pixels, bg_w, bg_h) = generate_atmosphere(pixels, width, height)?;
|
||||||
|
let mut buffer = slint::SharedPixelBuffer::<slint::Rgba8Pixel>::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.
|
/// AlbumReactive glow color: the most saturated non-extreme 8x8 sample.
|
||||||
pub fn glow_color(pixels: &[u8], width: u32, height: u32) -> Color {
|
pub fn glow_color(pixels: &[u8], width: u32, height: u32) -> Color {
|
||||||
let Some(src) = RgbaImage::from_raw(width, height, pixels.to_vec()) else {
|
let Some(src) = RgbaImage::from_raw(width, height, pixels.to_vec()) else {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
|||||||
import { CircleAction } from "../primitives/CircleAction.slint";
|
import { CircleAction } from "../primitives/CircleAction.slint";
|
||||||
import { MultiSelectBar } from "../primitives/MultiSelectBar.slint";
|
import { MultiSelectBar } from "../primitives/MultiSelectBar.slint";
|
||||||
import { NavButtons } from "../shell/NavButtons.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
|
// 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
|
// 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-height => { self.sr-restore(); }
|
||||||
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
|
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
|
||||||
|
|
||||||
// Artwork-tinted gradient behind the header; scrolls with content.
|
// Static Immersive-style blurred artwork field behind the header;
|
||||||
Rectangle {
|
// scrolls with content. The old tint gradient remains the fallback
|
||||||
|
// until artwork decoding finishes.
|
||||||
|
if AlbumState.header-atmosphere.width > 0: ImmersiveAtmosphere {
|
||||||
x: 0;
|
x: 0;
|
||||||
y: 0;
|
y: 0;
|
||||||
width: parent.width;
|
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,
|
background: @linear-gradient(180deg,
|
||||||
AlbumState.header-color 0%,
|
AlbumState.header-color 0%,
|
||||||
AlbumState.header-color 16%,
|
AlbumState.header-color 16%,
|
||||||
transparent 100%);
|
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 {
|
page := VerticalLayout {
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { ReleaseGrid } from "ReleaseGrid.slint";
|
|||||||
import { NavButtons } from "../shell/NavButtons.slint";
|
import { NavButtons } from "../shell/NavButtons.slint";
|
||||||
import { JumpNavBar, JumpNavTab } from "../primitives/JumpNavBar.slint";
|
import { JumpNavBar, JumpNavTab } from "../primitives/JumpNavBar.slint";
|
||||||
import { CircleAction } from "../primitives/CircleAction.slint";
|
import { CircleAction } from "../primitives/CircleAction.slint";
|
||||||
|
import { ImmersiveAtmosphere } from "../immersive/ImmersiveAtmosphere.slint";
|
||||||
|
|
||||||
component SectionTitle inherits Text {
|
component SectionTitle inherits Text {
|
||||||
color: Theme.text-primary;
|
color: Theme.text-primary;
|
||||||
@@ -167,17 +168,41 @@ export component ArtistPageView inherits Rectangle {
|
|||||||
changed viewport-height => { self.sr-restore(); }
|
changed viewport-height => { self.sr-restore(); }
|
||||||
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
|
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
|
||||||
|
|
||||||
// Artwork-tinted gradient behind the header; scrolls with content.
|
// Static Immersive-style blurred artwork field behind the header;
|
||||||
Rectangle {
|
// scrolls with content. The old tint gradient remains the fallback
|
||||||
|
// until artwork decoding finishes.
|
||||||
|
if ArtistState.header-atmosphere.width > 0: ImmersiveAtmosphere {
|
||||||
x: 0;
|
x: 0;
|
||||||
y: 0;
|
y: 0;
|
||||||
width: parent.width;
|
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,
|
background: @linear-gradient(180deg,
|
||||||
ArtistState.header-color 0%,
|
ArtistState.header-color 0%,
|
||||||
ArtistState.header-color 16%,
|
ArtistState.header-color 16%,
|
||||||
transparent 100%);
|
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 {
|
page := VerticalLayout {
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
|
|||||||
@@ -406,7 +406,9 @@ export global AlbumState {
|
|||||||
// tracks keep priority. Falls back to the full short text when there's room.
|
// tracks keep priority. Falls back to the full short text when there's room.
|
||||||
in property <string> description-shorter;
|
in property <string> description-shorter;
|
||||||
in property <image> artwork;
|
in property <image> artwork;
|
||||||
// Artwork-derived tint for the header gradient.
|
// Static Immersive-style blurred artwork field for the header backdrop.
|
||||||
|
in property <image> header-atmosphere;
|
||||||
|
// Artwork-derived tint for the header fallback gradient.
|
||||||
in property <color> header-color: #181820;
|
in property <color> header-color: #181820;
|
||||||
in property <string> label;
|
in property <string> label;
|
||||||
// Label id for the sidebar label card → label page navigation ("" = none).
|
// Label id for the sidebar label card → label page navigation ("" = none).
|
||||||
@@ -2664,7 +2666,9 @@ export global ArtistState {
|
|||||||
// "Source: <name>" line under the Read more toggle when present.
|
// "Source: <name>" line under the Read more toggle when present.
|
||||||
in property <string> bio-source;
|
in property <string> bio-source;
|
||||||
in property <image> artwork;
|
in property <image> artwork;
|
||||||
// Artwork-derived tint for the header gradient.
|
// Static Immersive-style blurred artwork field for the header backdrop.
|
||||||
|
in property <image> header-atmosphere;
|
||||||
|
// Artwork-derived tint for the header fallback gradient.
|
||||||
in property <color> header-color: #181820;
|
in property <color> header-color: #181820;
|
||||||
in property <[TrackItem]> top-tracks: [];
|
in property <[TrackItem]> top-tracks: [];
|
||||||
// Popular Tracks multi-select (track selection) mode + selected count —
|
// Popular Tracks multi-select (track selection) mode + selected count —
|
||||||
|
|||||||
Reference in new issue
Block a user