diff options
author | 2023-04-17 23:46:18 +0200 | |
---|---|---|
committer | 2023-04-17 23:46:18 +0200 | |
commit | 619ba9294d5e0f7913f82838d78018fc6714d26a (patch) | |
tree | b0631aa66875e0e9f486665227c306832ac19a5b /runtime | |
parent | d206b82ebb7617337cd378bd19542a7abf8a4529 (diff) | |
parent | e3730106e9d4f75de199e1b83cf285b8ff031968 (diff) | |
download | iced-619ba9294d5e0f7913f82838d78018fc6714d26a.tar.gz iced-619ba9294d5e0f7913f82838d78018fc6714d26a.tar.bz2 iced-619ba9294d5e0f7913f82838d78018fc6714d26a.zip |
Merge branch 'advanced-text' into incremental-rendering
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/Cargo.toml | 4 | ||||
-rw-r--r-- | runtime/README.md | 7 | ||||
-rw-r--r-- | runtime/src/lib.rs | 4 | ||||
-rw-r--r-- | runtime/src/user_interface.rs | 4 | ||||
-rw-r--r-- | runtime/src/window.rs | 7 | ||||
-rw-r--r-- | runtime/src/window/action.rs | 21 |
6 files changed, 32 insertions, 15 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2d3e8db3..a65f07f2 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_runtime" -version = "0.9.1" +version = "0.1.0" authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"] edition = "2021" description = "A renderer-agnostic library for native GUIs" @@ -14,7 +14,7 @@ debug = [] thiserror = "1" [dependencies.iced_core] -version = "0.8" +version = "0.9" path = "../core" [dependencies.iced_futures] diff --git a/runtime/README.md b/runtime/README.md index 497fd145..1b0fa857 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -12,13 +12,6 @@ [`druid`]: https://github.com/xi-editor/druid [`raw-window-handle`]: https://github.com/rust-windowing/raw-window-handle -## Installation -Add `iced_runtime` as a dependency in your `Cargo.toml`: - -```toml -iced_runtime = "0.9" -``` - __Iced moves fast and the `master` branch can contain breaking changes!__ If you want to learn about a specific release, check out [the release list]. diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index aa45e57a..8a277e47 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -23,8 +23,8 @@ //! - Build a new renderer, see the [renderer] module. //! - Build a custom widget, start at the [`Widget`] trait. //! -//! [`iced_core`]: https://github.com/iced-rs/iced/tree/0.8/core -//! [`iced_winit`]: https://github.com/iced-rs/iced/tree/0.8/winit +//! [`iced_core`]: https://github.com/iced-rs/iced/tree/0.9/core +//! [`iced_winit`]: https://github.com/iced-rs/iced/tree/0.9/winit //! [`druid`]: https://github.com/xi-editor/druid //! [`raw-window-handle`]: https://github.com/rust-windowing/raw-window-handle //! [renderer]: crate::renderer diff --git a/runtime/src/user_interface.rs b/runtime/src/user_interface.rs index 2c76fd8a..c29de7db 100644 --- a/runtime/src/user_interface.rs +++ b/runtime/src/user_interface.rs @@ -19,8 +19,8 @@ use crate::core::{Element, Layout, Shell}; /// The [`integration_opengl`] & [`integration_wgpu`] examples use a /// [`UserInterface`] to integrate Iced in an existing graphical application. /// -/// [`integration_opengl`]: https://github.com/iced-rs/iced/tree/0.8/examples/integration_opengl -/// [`integration_wgpu`]: https://github.com/iced-rs/iced/tree/0.8/examples/integration_wgpu +/// [`integration_opengl`]: https://github.com/iced-rs/iced/tree/0.9/examples/integration_opengl +/// [`integration_wgpu`]: https://github.com/iced-rs/iced/tree/0.9/examples/integration_wgpu #[allow(missing_debug_implementations)] pub struct UserInterface<'a, Message, Renderer> { root: Element<'a, Message, Renderer>, diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 236064f7..833a1125 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -5,7 +5,7 @@ pub use action::Action; use crate::command::{self, Command}; use crate::core::time::Instant; -use crate::core::window::{Event, Mode, UserAttention}; +use crate::core::window::{Event, Icon, Mode, UserAttention}; use crate::futures::subscription::{self, Subscription}; /// Subscribes to the frames of the window of the running application. @@ -110,3 +110,8 @@ pub fn fetch_id<Message>( ) -> Command<Message> { Command::single(command::Action::Window(Action::FetchId(Box::new(f)))) } + +/// Changes the [`Icon`] of the window. +pub fn change_icon<Message>(icon: Icon) -> Command<Message> { + Command::single(command::Action::Window(Action::ChangeIcon(icon))) +} diff --git a/runtime/src/window/action.rs b/runtime/src/window/action.rs index c1dbd84f..83b71c75 100644 --- a/runtime/src/window/action.rs +++ b/runtime/src/window/action.rs @@ -1,4 +1,4 @@ -use crate::core::window::{Mode, UserAttention}; +use crate::core::window::{Icon, Mode, UserAttention}; use crate::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)") + } } } } |