shitty g4 like background blur
This commit is contained in:
parent
418cf01884
commit
2f510c55ac
2 changed files with 39 additions and 4 deletions
|
@ -7,8 +7,6 @@ template $AudreyUiWindow: Adw.ApplicationWindow {
|
|||
default-height: 600;
|
||||
|
||||
Adw.ToolbarView {
|
||||
top-bar-style: raised;
|
||||
bottom-bar-style: raised;
|
||||
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
|
|
|
@ -38,6 +38,8 @@ mod imp {
|
|||
|
||||
#[property(get, set, nullable)]
|
||||
playing_cover_art: RefCell<Option<gdk::Paintable>>,
|
||||
#[property(get, set, nullable)]
|
||||
background: RefCell<Option<gdk::Paintable>>,
|
||||
|
||||
#[property(type = Option<Song>, 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!(
|
||||
|
|
Loading…
Reference in a new issue