diff --git a/resources/window.blp b/resources/window.blp index 5ec38e1..92a3652 100644 --- a/resources/window.blp +++ b/resources/window.blp @@ -7,8 +7,6 @@ template $AudreyUiWindow: Adw.ApplicationWindow { default-height: 600; Adw.ToolbarView { - top-bar-style: raised; - bottom-bar-style: raised; [top] Adw.HeaderBar { diff --git a/src/ui/window.rs b/src/ui/window.rs index e474213..2cfc3bb 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -38,6 +38,8 @@ mod imp { #[property(get, set, nullable)] playing_cover_art: RefCell>, + #[property(get, set, nullable)] + background: RefCell>, #[property(type = Option, get = Self::song, nullable)] _song: (), @@ -112,6 +114,7 @@ mod imp { play_queue: Default::default(), can_click_shuffle_all: Cell::new(false), playing_cover_art: Default::default(), + background: Default::default(), _song: (), setup: Default::default(), api: Default::default(), @@ -273,7 +276,18 @@ mod imp { } } - impl WidgetImpl for Window {} + impl WidgetImpl for Window { + fn snapshot(&self, snapshot: >k::Snapshot) { + if let Some(background) = self.background.borrow().as_ref() { + background.snapshot( + snapshot, + self.obj().width() as f64, + self.obj().height() as f64, + ); + } + self.parent_snapshot(snapshot); + } + } impl WindowImpl for Window {} @@ -533,7 +547,30 @@ mod imp { Some(song) if song.id() == song_id => { let texture = gdk::Texture::from_bytes(&glib::Bytes::from_owned(bytes)) .expect("could not create texture from cover art for {song_id}"); - window.set_playing_cover_art(Some(texture)); + window.set_playing_cover_art(Some(&texture.clone().into())); + + // from g4music + let snapshot = gtk::Snapshot::new(); + snapshot.push_blur(512.0 * 0.2); + snapshot.push_opacity(0.5); + texture.snapshot(&snapshot, 512.0, 512.0); + snapshot.pop(); + snapshot.pop(); + + use gtk::graphene; + let rect = graphene::Rect::new(0.0, 0.0, 512.0, 512.0); + if let Some(node) = snapshot.clone().to_node() { + window.set_background(Some( + window + .native() + .unwrap() + .renderer() + .unwrap() + .render_texture(node, Some(&rect)), + )); + } else { + todo!(); + } } _ => { event!(