diff options
author | 2023-04-12 18:47:53 +1200 | |
---|---|---|
committer | 2023-04-12 06:47:53 +0000 | |
commit | 5a056ce0510343621305474af74ade1db028c01a (patch) | |
tree | 424aa80f7151e594ebc5e38fb6445fa33e121ea1 /native/src/window/action.rs | |
parent | e7549877ef396471df1509bce2b1d85243206022 (diff) | |
download | iced-5a056ce0510343621305474af74ade1db028c01a.tar.gz iced-5a056ce0510343621305474af74ade1db028c01a.tar.bz2 iced-5a056ce0510343621305474af74ade1db028c01a.zip |
add action set icon while running (#1590)
* set windows icon live action
* change get icon to insto raw
* remove mobile docs
* format
* fix format
* add file methods to Icon
* Rename action to `ChangeIcon` and tidy up `Icon` modules
* Fix documentation of `icon::Error`
* Remove unnecessary `\` in `icon` documentation
* Remove `etc.` from `Icon` documentation
---------
Co-authored-by: Héctor Ramón Jiménez <hector0193@gmail.com>
Diffstat (limited to 'native/src/window/action.rs')
-rw-r--r-- | native/src/window/action.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/native/src/window/action.rs b/native/src/window/action.rs index ce36d129..095a8eec 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -1,4 +1,4 @@ -use crate::window::{Mode, UserAttention}; +use crate::window::{Icon, Mode, UserAttention}; use iced_futures::MaybeSend; use std::fmt; @@ -78,6 +78,21 @@ pub enum Action<T> { ChangeAlwaysOnTop(bool), /// Fetch an identifier unique to the window. FetchId(Box<dyn FnOnce(u64) -> T + 'static>), + /// Changes the window [`Icon`]. + /// + /// On Windows and X11, this is typically the small icon in the top-left + /// corner of the titlebar. + /// + /// ## Platform-specific + /// + /// - **Web / Wayland / macOS:** Unsupported. + /// + /// - **Windows:** Sets `ICON_SMALL`. The base size for a window icon is 16x16, but it's + /// recommended to account for screen scaling and pick a multiple of that, i.e. 32x32. + /// + /// - **X11:** Has no universal guidelines for icon sizes, so you're at the whims of the WM. That + /// said, it's usually in the same ballpark as on Windows. + ChangeIcon(Icon), } impl<T> Action<T> { @@ -108,6 +123,7 @@ impl<T> Action<T> { Action::ChangeAlwaysOnTop(on_top) } Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))), + Self::ChangeIcon(icon) => Action::ChangeIcon(icon), } } } @@ -142,6 +158,9 @@ impl<T> fmt::Debug for Action<T> { write!(f, "Action::AlwaysOnTop({on_top})") } Self::FetchId(_) => write!(f, "Action::FetchId"), + Self::ChangeIcon(_icon) => { + write!(f, "Action::ChangeIcon(icon)") + } } } } |