fix: use enable and disable methods

This commit is contained in:
Eduardo Flores 2024-10-30 17:19:19 +01:00 committed by Ashley Wulber
parent 344567dd8d
commit 61cdb6fe1f
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
2 changed files with 24 additions and 7 deletions

View file

@ -188,8 +188,12 @@ pub enum Action {
/// Recompute the layouts of all the windows.
RelayoutAll,
/// Set window blur.
SetBlur(bool),
/// Enable window blur.
EnableBlur(Id),
/// Disable window blur.
DisableBlur(Id),
}
/// A window managed by iced.
@ -541,8 +545,16 @@ pub fn allow_automatic_tabbing<T>(enabled: bool) -> Task<T> {
}
/// Sets the blur effect for the window.
/// Enable the blur effect for a window.
///
/// This is only supported on platforms that support window blur.
pub fn set_blur<Message>(enable: bool) -> Task<Message> {
task::effect(crate::Action::Window(Action::SetBlur(enable)))
pub fn enable_blur<Message>(id: Id) -> Task<Message> {
task::effect(crate::Action::Window(Action::EnableBlur(id)))
}
/// Enable the blur effect for a window.
///
/// This is only supported on platforms that support window blur.
pub fn disable_blur<Message>(id: Id) -> Task<Message> {
task::effect(crate::Action::Window(Action::DisableBlur(id)))
}

View file

@ -1960,9 +1960,14 @@ fn run_action<'a, P, C>(
window.raw.request_redraw();
}
}
window::Action::SetBlur(enable) => {
for (_, window) in window_manager.iter_mut() {
window.raw.set_blur(enable);
window::Action::EnableBlur(id) => {
if let Some(window) = window_manager.get_mut(id) {
window.raw.set_blur(true);
}
}
window::Action::DisableBlur(id) => {
if let Some(window) = window_manager.get_mut(id) {
window.raw.set_blur(false);
}
}
},