From 529589d7fe9278858e3f251b559a1118598a8250 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 1 Apr 2022 17:16:15 -0300 Subject: Introduce `multi_window` from `pure` --- src/lib.rs | 3 + src/multi_window.rs | 4 + src/multi_window/application.rs | 196 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+) create mode 100644 src/multi_window.rs create mode 100644 src/multi_window/application.rs (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index a0e31be4..6cda8c41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,6 +181,9 @@ pub mod touch; pub mod widget; pub mod window; +#[cfg(feature = "multi_window")] +pub mod multi_window; + #[cfg(all(not(feature = "glow"), feature = "wgpu"))] use iced_winit as runtime; diff --git a/src/multi_window.rs b/src/multi_window.rs new file mode 100644 index 00000000..5b7a00b4 --- /dev/null +++ b/src/multi_window.rs @@ -0,0 +1,4 @@ +//! Leverage multi-window support in your application. +mod application; + +pub use application::Application; diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs new file mode 100644 index 00000000..db41d54a --- /dev/null +++ b/src/multi_window/application.rs @@ -0,0 +1,196 @@ +use crate::{Command, Element, Executor, Settings, Subscription}; + +pub use iced_native::application::{Appearance, StyleSheet}; + +/// A pure version of [`Application`]. +/// +/// Unlike the impure version, the `view` method of this trait takes an +/// immutable reference to `self` and returns a pure [`Element`]. +/// +/// [`Application`]: crate::Application +/// [`Element`]: pure::Element +pub trait Application: Sized { + /// The [`Executor`] that will run commands and subscriptions. + /// + /// The [default executor] can be a good starting point! + /// + /// [`Executor`]: Self::Executor + /// [default executor]: crate::executor::Default + type Executor: Executor; + + /// The type of __messages__ your [`Application`] will produce. + type Message: std::fmt::Debug + Send; + + /// The theme of your [`Application`]. + type Theme: Default + StyleSheet; + + /// The data needed to initialize your [`Application`]. + type Flags; + + /// Initializes the [`Application`] with the flags provided to + /// [`run`] as part of the [`Settings`]. + /// + /// Here is where you should return the initial state of your app. + /// + /// Additionally, you can return a [`Command`] if you need to perform some + /// async action in the background on startup. This is useful if you want to + /// load state from a file, perform an initial HTTP request, etc. + /// + /// [`run`]: Self::run + fn new(flags: Self::Flags) -> (Self, Command); + + /// Returns the current title of the [`Application`]. + /// + /// This title can be dynamic! The runtime will automatically update the + /// title of your application when necessary. + fn title(&self) -> String; + + /// Handles a __message__ and updates the state of the [`Application`]. + /// + /// This is where you define your __update logic__. All the __messages__, + /// produced by either user interactions or commands, will be handled by + /// this method. + /// + /// Any [`Command`] returned will be executed immediately in the background. + fn update(&mut self, message: Self::Message) -> Command; + + /// Returns the current [`Theme`] of the [`Application`]. + /// + /// [`Theme`]: Self::Theme + fn theme(&self) -> Self::Theme { + Self::Theme::default() + } + + /// Returns the current [`Style`] of the [`Theme`]. + /// + /// [`Style`]: ::Style + /// [`Theme`]: Self::Theme + fn style(&self) -> ::Style { + ::Style::default() + } + + /// Returns the event [`Subscription`] for the current state of the + /// application. + /// + /// A [`Subscription`] will be kept alive as long as you keep returning it, + /// and the __messages__ produced will be handled by + /// [`update`](#tymethod.update). + /// + /// By default, this method returns an empty [`Subscription`]. + fn subscription(&self) -> Subscription { + Subscription::none() + } + + /// Returns the widgets to display in the [`Application`]. + /// + /// These widgets can produce __messages__ based on user interaction. + fn view(&self) -> Element<'_, Self::Message, crate::Renderer>; + + /// Returns the scale factor of the [`Application`]. + /// + /// It can be used to dynamically control the size of the UI at runtime + /// (i.e. zooming). + /// + /// For instance, a scale factor of `2.0` will make widgets twice as big, + /// while a scale factor of `0.5` will shrink them to half their size. + /// + /// By default, it returns `1.0`. + fn scale_factor(&self) -> f64 { + 1.0 + } + + /// Returns whether the [`Application`] should be terminated. + /// + /// By default, it returns `false`. + fn should_exit(&self) -> bool { + false + } + + /// Runs the [`Application`]. + /// + /// On native platforms, this method will take control of the current thread + /// until the [`Application`] exits. + /// + /// On the web platform, this method __will NOT return__ unless there is an + /// [`Error`] during startup. + /// + /// [`Error`]: crate::Error + fn run(settings: Settings) -> crate::Result + where + Self: 'static, + { + #[allow(clippy::needless_update)] + let renderer_settings = crate::renderer::Settings { + default_font: settings.default_font, + default_text_size: settings.default_text_size, + text_multithreading: settings.text_multithreading, + antialiasing: if settings.antialiasing { + Some(crate::renderer::settings::Antialiasing::MSAAx4) + } else { + None + }, + ..crate::renderer::Settings::from_env() + }; + + Ok(crate::runtime::application::run::< + Instance, + Self::Executor, + crate::renderer::window::Compositor, + >(settings.into(), renderer_settings)?) + } +} + +struct Instance(A); + +impl iced_winit::Program for Instance +where + A: Application, +{ + type Renderer = crate::Renderer; + type Message = A::Message; + + fn update(&mut self, message: Self::Message) -> Command { + self.0.update(message) + } + + fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { + self.0.view() + } +} + +impl crate::runtime::Application for Instance +where + A: Application, +{ + type Flags = A::Flags; + + fn new(flags: Self::Flags) -> (Self, Command) { + let (app, command) = A::new(flags); + + (Instance(app), command) + } + + fn title(&self) -> String { + self.0.title() + } + + fn theme(&self) -> A::Theme { + self.0.theme() + } + + fn style(&self) -> ::Style { + self.0.style() + } + + fn subscription(&self) -> Subscription { + self.0.subscription() + } + + fn scale_factor(&self) -> f64 { + self.0.scale_factor() + } + + fn should_exit(&self) -> bool { + self.0.should_exit() + } +} -- cgit From b896e41c6e03f1447419194ce41d15fb0db39d96 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 1 Apr 2022 17:39:08 -0300 Subject: Unify `Application` and `Program` Instead of creating a separate `multi_window::Program`, the new `multi_window::Application` unifies both traits --- src/multi_window/application.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index db41d54a..fa0c15b1 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -132,7 +132,7 @@ pub trait Application: Sized { ..crate::renderer::Settings::from_env() }; - Ok(crate::runtime::application::run::< + Ok(crate::runtime::multi_window::run::< Instance, Self::Executor, crate::renderer::window::Compositor, @@ -142,28 +142,14 @@ pub trait Application: Sized { struct Instance(A); -impl iced_winit::Program for Instance +impl crate::runtime::multi_window::Application for Instance where A: Application, { + type Flags = A::Flags; type Renderer = crate::Renderer; type Message = A::Message; - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) - } - - fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { - self.0.view() - } -} - -impl crate::runtime::Application for Instance -where - A: Application, -{ - type Flags = A::Flags; - fn new(flags: Self::Flags) -> (Self, Command) { let (app, command) = A::new(flags); @@ -174,6 +160,14 @@ where self.0.title() } + fn update(&mut self, message: Self::Message) -> Command { + self.0.update(message) + } + + fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { + self.0.view() + } + fn theme(&self) -> A::Theme { self.0.theme() } -- cgit From ec56c0686df1a200e37af951a3a8eca562c32a5c Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 21 Jun 2022 15:59:45 -0300 Subject: Introduce opaque `window::Id` type --- src/multi_window/application.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index fa0c15b1..6b3f4676 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -1,3 +1,4 @@ +use crate::window; use crate::{Command, Element, Executor, Settings, Subscription}; pub use iced_native::application::{Appearance, StyleSheet}; @@ -45,6 +46,9 @@ pub trait Application: Sized { /// title of your application when necessary. fn title(&self) -> String; + /// TODO(derezzedex) + fn windows(&self) -> Vec<(window::Id, window::Settings)>; + /// Handles a __message__ and updates the state of the [`Application`]. /// /// This is where you define your __update logic__. All the __messages__, @@ -160,6 +164,16 @@ where self.0.title() } + fn windows(&self) -> Vec<(window::Id, iced_winit::settings::Window)> { + self.0 + .windows() + .into_iter() + .map(|(id, settings)| { + (id, iced_winit::settings::Window::from(settings)) + }) + .collect() + } + fn update(&mut self, message: Self::Message) -> Command { self.0.update(message) } -- cgit From 2fe58e12619186eb3755491db2bdaf02de297afb Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 21 Jul 2022 09:52:32 -0300 Subject: add `window::Id` to `view` --- src/multi_window/application.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 6b3f4676..e849bf2b 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -88,7 +88,10 @@ pub trait Application: Sized { /// Returns the widgets to display in the [`Application`]. /// /// These widgets can produce __messages__ based on user interaction. - fn view(&self) -> Element<'_, Self::Message, crate::Renderer>; + fn view( + &self, + window: window::Id, + ) -> Element<'_, Self::Message, crate::Renderer>; /// Returns the scale factor of the [`Application`]. /// @@ -178,8 +181,11 @@ where self.0.update(message) } - fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { - self.0.view() + fn view( + &self, + window: window::Id, + ) -> Element<'_, Self::Message, Self::Renderer> { + self.0.view(window) } fn theme(&self) -> A::Theme { -- cgit From dc86bd03733969033df7389c3d21e78ecc6291bb Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 27 Jul 2022 15:37:48 -0300 Subject: Introduce `close_requested` for `multi-window` --- src/multi_window/application.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index e849bf2b..df45ca1e 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -113,6 +113,9 @@ pub trait Application: Sized { false } + /// TODO(derezzedex) + fn close_requested(&self, window: window::Id) -> Self::Message; + /// Runs the [`Application`]. /// /// On native platforms, this method will take control of the current thread @@ -207,4 +210,8 @@ where fn should_exit(&self) -> bool { self.0.should_exit() } + + fn close_requested(&self, window: window::Id) -> Self::Message { + self.0.close_requested(window) + } } -- cgit From 1bc0c480f9747826b244c30e92d8c4a29b576e4a Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 19 Oct 2022 22:56:00 -0300 Subject: move window settings to `iced_native` --- src/window.rs | 11 +--- src/window/icon.rs | 172 ------------------------------------------------- src/window/position.rs | 32 --------- src/window/settings.rs | 70 -------------------- 4 files changed, 3 insertions(+), 282 deletions(-) delete mode 100644 src/window/icon.rs delete mode 100644 src/window/position.rs delete mode 100644 src/window/settings.rs (limited to 'src') diff --git a/src/window.rs b/src/window.rs index 2018053f..73e90243 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,12 +1,7 @@ //! Configure the window of your application in native platforms. -mod position; -mod settings; - -pub mod icon; - -pub use icon::Icon; -pub use position::Position; -pub use settings::Settings; +pub use iced_native::window::Icon; +pub use iced_native::window::Position; +pub use iced_native::window::Settings; #[cfg(not(target_arch = "wasm32"))] pub use crate::runtime::window::*; diff --git a/src/window/icon.rs b/src/window/icon.rs deleted file mode 100644 index bacad41a..00000000 --- a/src/window/icon.rs +++ /dev/null @@ -1,172 +0,0 @@ -//! Attach an icon to the window of your application. -use std::fmt; -use std::io; - -#[cfg(feature = "image_rs")] -use std::path::Path; - -/// The icon of a window. -#[derive(Debug, Clone)] -pub struct Icon(iced_winit::winit::window::Icon); - -impl Icon { - /// Creates an icon from 32bpp RGBA data. - pub fn from_rgba( - rgba: Vec, - width: u32, - height: u32, - ) -> Result { - let raw = - iced_winit::winit::window::Icon::from_rgba(rgba, width, height)?; - - Ok(Icon(raw)) - } - - /// Creates an icon from an image file. - /// - /// This will return an error in case the file is missing at run-time. You may prefer [`Self::from_file_data`] instead. - #[cfg(feature = "image_rs")] - pub fn from_file>(icon_path: P) -> Result { - let icon = image_rs::io::Reader::open(icon_path)?.decode()?.to_rgba8(); - - Self::from_rgba(icon.to_vec(), icon.width(), icon.height()) - } - - /// Creates an icon from the content of an image file. - /// - /// This content can be included in your application at compile-time, e.g. using the `include_bytes!` macro. \ - /// You can pass an explicit file format. Otherwise, the file format will be guessed at runtime. - #[cfg(feature = "image_rs")] - pub fn from_file_data( - data: &[u8], - explicit_format: Option, - ) -> Result { - let mut icon = image_rs::io::Reader::new(std::io::Cursor::new(data)); - let icon_with_format = match explicit_format { - Some(format) => { - icon.set_format(format); - icon - } - None => icon.with_guessed_format()?, - }; - - let pixels = icon_with_format.decode()?.to_rgba8(); - - Self::from_rgba(pixels.to_vec(), pixels.width(), pixels.height()) - } -} - -/// An error produced when using `Icon::from_rgba` with invalid arguments. -#[derive(Debug)] -pub enum Error { - /// The provided RGBA data isn't divisble by 4. - /// - /// Therefore, it cannot be safely interpreted as 32bpp RGBA pixels. - InvalidData { - /// The length of the provided RGBA data. - byte_count: usize, - }, - - /// The number of RGBA pixels does not match the provided dimensions. - DimensionsMismatch { - /// The provided width. - width: u32, - /// The provided height. - height: u32, - /// The amount of pixels of the provided RGBA data. - pixel_count: usize, - }, - - /// The underlying OS failed to create the icon. - OsError(io::Error), - - /// The `image` crate reported an error - #[cfg(feature = "image_rs")] - ImageError(image_rs::error::ImageError), -} - -impl From for Error { - fn from(os_error: std::io::Error) -> Self { - Error::OsError(os_error) - } -} - -impl From for Error { - fn from(error: iced_winit::winit::window::BadIcon) -> Self { - use iced_winit::winit::window::BadIcon; - - match error { - BadIcon::ByteCountNotDivisibleBy4 { byte_count } => { - Error::InvalidData { byte_count } - } - BadIcon::DimensionsVsPixelCount { - width, - height, - pixel_count, - .. - } => Error::DimensionsMismatch { - width, - height, - pixel_count, - }, - BadIcon::OsError(os_error) => Error::OsError(os_error), - } - } -} - -impl From for iced_winit::winit::window::Icon { - fn from(icon: Icon) -> Self { - icon.0 - } -} - -#[cfg(feature = "image_rs")] -impl From for Error { - fn from(image_error: image_rs::error::ImageError) -> Self { - Self::ImageError(image_error) - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Error::InvalidData { byte_count } => { - write!( - f, - "The provided RGBA data (with length {:?}) isn't divisble by \ - 4. Therefore, it cannot be safely interpreted as 32bpp RGBA \ - pixels.", - byte_count, - ) - } - Error::DimensionsMismatch { - width, - height, - pixel_count, - } => { - write!( - f, - "The number of RGBA pixels ({:?}) does not match the provided \ - dimensions ({:?}x{:?}).", - pixel_count, width, height, - ) - } - Error::OsError(e) => write!( - f, - "The underlying OS failed to create the window \ - icon: {:?}", - e - ), - #[cfg(feature = "image_rs")] - Error::ImageError(e) => { - write!(f, "Unable to create icon from a file: {:?}", e) - } - } - } -} - -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(self) - } -} diff --git a/src/window/position.rs b/src/window/position.rs deleted file mode 100644 index 6b9fac41..00000000 --- a/src/window/position.rs +++ /dev/null @@ -1,32 +0,0 @@ -/// The position of a window in a given screen. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Position { - /// The platform-specific default position for a new window. - Default, - /// The window is completely centered on the screen. - Centered, - /// The window is positioned with specific coordinates: `(X, Y)`. - /// - /// When the decorations of the window are enabled, Windows 10 will add some - /// invisible padding to the window. This padding gets included in the - /// position. So if you have decorations enabled and want the window to be - /// at (0, 0) you would have to set the position to - /// `(PADDING_X, PADDING_Y)`. - Specific(i32, i32), -} - -impl Default for Position { - fn default() -> Self { - Self::Default - } -} - -impl From for iced_winit::Position { - fn from(position: Position) -> Self { - match position { - Position::Default => Self::Default, - Position::Centered => Self::Centered, - Position::Specific(x, y) => Self::Specific(x, y), - } - } -} diff --git a/src/window/settings.rs b/src/window/settings.rs deleted file mode 100644 index 24d0f4f9..00000000 --- a/src/window/settings.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::window::{Icon, Position}; - -/// The window settings of an application. -#[derive(Debug, Clone)] -pub struct Settings { - /// The initial size of the window. - pub size: (u32, u32), - - /// The initial position of the window. - pub position: Position, - - /// The minimum size of the window. - pub min_size: Option<(u32, u32)>, - - /// The maximum size of the window. - pub max_size: Option<(u32, u32)>, - - /// Whether the window should be visible or not. - pub visible: bool, - - /// Whether the window should be resizable or not. - pub resizable: bool, - - /// Whether the window should have a border, a title bar, etc. or not. - pub decorations: bool, - - /// Whether the window should be transparent. - pub transparent: bool, - - /// Whether the window will always be on top of other windows. - pub always_on_top: bool, - - /// The icon of the window. - pub icon: Option, -} - -impl Default for Settings { - fn default() -> Settings { - Settings { - size: (1024, 768), - position: Position::default(), - min_size: None, - max_size: None, - visible: true, - resizable: true, - decorations: true, - transparent: false, - always_on_top: false, - icon: None, - } - } -} - -impl From for iced_winit::settings::Window { - fn from(settings: Settings) -> Self { - Self { - size: settings.size, - position: iced_winit::Position::from(settings.position), - min_size: settings.min_size, - max_size: settings.max_size, - visible: settings.visible, - resizable: settings.resizable, - decorations: settings.decorations, - transparent: settings.transparent, - always_on_top: settings.always_on_top, - icon: settings.icon.map(Icon::into), - platform_specific: Default::default(), - } - } -} -- cgit From 5e4e410b18eb744cf70ae1f18b9ef08611f59150 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 3 Nov 2022 14:53:05 -0300 Subject: remove `windows` method (use commands instead) --- src/multi_window/application.rs | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index df45ca1e..7d559397 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -46,9 +46,6 @@ pub trait Application: Sized { /// title of your application when necessary. fn title(&self) -> String; - /// TODO(derezzedex) - fn windows(&self) -> Vec<(window::Id, window::Settings)>; - /// Handles a __message__ and updates the state of the [`Application`]. /// /// This is where you define your __update logic__. All the __messages__, @@ -170,16 +167,6 @@ where self.0.title() } - fn windows(&self) -> Vec<(window::Id, iced_winit::settings::Window)> { - self.0 - .windows() - .into_iter() - .map(|(id, settings)| { - (id, iced_winit::settings::Window::from(settings)) - }) - .collect() - } - fn update(&mut self, message: Self::Message) -> Command { self.0.update(message) } -- cgit From ec41918ec40bddaba81235372f1566da59fd09f2 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Thu, 5 Jan 2023 15:26:28 -0800 Subject: Implemented window title update functionality for multiwindow. --- src/multi_window/application.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 7d559397..dc1ac5b0 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -44,7 +44,7 @@ pub trait Application: Sized { /// /// This title can be dynamic! The runtime will automatically update the /// title of your application when necessary. - fn title(&self) -> String; + fn title(&self, window: window::Id) -> String; /// Handles a __message__ and updates the state of the [`Application`]. /// @@ -110,7 +110,7 @@ pub trait Application: Sized { false } - /// TODO(derezzedex) + /// Requests that the [`window`] be closed. fn close_requested(&self, window: window::Id) -> Self::Message; /// Runs the [`Application`]. @@ -163,8 +163,8 @@ where (Instance(app), command) } - fn title(&self) -> String { - self.0.title() + fn title(&self, window: window::Id) -> String { + self.0.title(window) } fn update(&mut self, message: Self::Message) -> Command { -- cgit From 3e5d34f25fa07fa99f57b686bbde87d73b8ed548 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Mon, 9 Jan 2023 10:19:12 -0800 Subject: Formatting --- src/multi_window/application.rs | 79 +++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index dc1ac5b0..3f20382c 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -3,13 +3,62 @@ use crate::{Command, Element, Executor, Settings, Subscription}; pub use iced_native::application::{Appearance, StyleSheet}; -/// A pure version of [`Application`]. +/// An interactive cross-platform multi-window application. /// -/// Unlike the impure version, the `view` method of this trait takes an -/// immutable reference to `self` and returns a pure [`Element`]. +/// This trait is the main entrypoint of Iced. Once implemented, you can run +/// your GUI application by simply calling [`run`](#method.run). /// -/// [`Application`]: crate::Application -/// [`Element`]: pure::Element +/// An [`Application`] can execute asynchronous actions by returning a +/// [`Command`] in some of its methods. For example, to spawn a new window, you +/// can use the `iced_winit::window::spawn()` [`Command`]. +/// +/// When using an [`Application`] with the `debug` feature enabled, a debug view +/// can be toggled by pressing `F12`. +/// +/// ## A simple "Hello, world!" +/// +/// If you just want to get started, here is a simple [`Application`] that +/// says "Hello, world!": +/// +/// ```no_run +/// use iced::executor; +/// use iced::multi_window::Application; +/// use iced::window; +/// use iced::{Command, Element, Settings, Theme}; +/// +/// pub fn main() -> iced::Result { +/// Hello::run(Settings::default()) +/// } +/// +/// struct Hello; +/// +/// impl Application for Hello { +/// type Executor = executor::Default; +/// type Message = (); +/// type Theme = Theme; +/// type Flags = (); +/// +/// fn new(_flags: ()) -> (Hello, Command) { +/// (Hello, Command::none()) +/// } +/// +/// fn title(&self, window: window::Id) -> String { +/// String::from("A cool application") +/// } +/// +/// fn update(&mut self, _message: Self::Message) -> Command { +/// Command::none() +/// } +/// +/// fn view(&self, window: window::Id) -> Element { +/// "Hello, world!".into() +/// } +/// +/// fn close_requested(&self, window: window::Id) -> Self::Message { +/// () +/// } +/// } +/// ``` pub trait Application: Sized { /// The [`Executor`] that will run commands and subscriptions. /// @@ -157,16 +206,6 @@ where type Renderer = crate::Renderer; type Message = A::Message; - fn new(flags: Self::Flags) -> (Self, Command) { - let (app, command) = A::new(flags); - - (Instance(app), command) - } - - fn title(&self, window: window::Id) -> String { - self.0.title(window) - } - fn update(&mut self, message: Self::Message) -> Command { self.0.update(message) } @@ -178,6 +217,16 @@ where self.0.view(window) } + fn new(flags: Self::Flags) -> (Self, Command) { + let (app, command) = A::new(flags); + + (Instance(app), command) + } + + fn title(&self, window: window::Id) -> String { + self.0.title(window) + } + fn theme(&self) -> A::Theme { self.0.theme() } -- cgit From 0a643287deece9234b64cc843a9f6ae3e6e4806e Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 18 Jan 2023 17:04:11 -0800 Subject: Added window::Id to multi_window application's scale_factor --- src/multi_window/application.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 3f20382c..3af1d8d5 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -148,7 +148,7 @@ pub trait Application: Sized { /// while a scale factor of `0.5` will shrink them to half their size. /// /// By default, it returns `1.0`. - fn scale_factor(&self) -> f64 { + fn scale_factor(&self, window: window::Id) -> f64 { 1.0 } @@ -239,8 +239,8 @@ where self.0.subscription() } - fn scale_factor(&self) -> f64 { - self.0.scale_factor() + fn scale_factor(&self, window: window::Id) -> f64 { + self.0.scale_factor(window) } fn should_exit(&self) -> bool { -- cgit From 2d427455ce8f9627da7c09eb80f38a615f0ddcb7 Mon Sep 17 00:00:00 2001 From: Bingus Date: Fri, 17 Feb 2023 11:50:52 -0800 Subject: Iced master merge (again) --- src/multi_window/application.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 3af1d8d5..d0b515ab 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -148,6 +148,7 @@ pub trait Application: Sized { /// while a scale factor of `0.5` will shrink them to half their size. /// /// By default, it returns `1.0`. + #[allow(unused_variables)] fn scale_factor(&self, window: window::Id) -> f64 { 1.0 } -- cgit From e36daa6f937abd7cb2071fd8852a3c12263944ea Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Tue, 28 Feb 2023 13:44:36 -0800 Subject: Removed glutin MW support and reverted glutin changes back to Iced master since it's being axed as we speak. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 993e94b1..65fe3b93 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,7 +182,7 @@ pub mod touch; pub mod widget; pub mod window; -#[cfg(feature = "multi_window")] +#[cfg(all(not(feature = "glow"), feature = "multi_window"))] pub mod multi_window; #[cfg(all(not(feature = "glow"), feature = "wgpu"))] -- cgit From 8ba18430800142965549077373e2a45d0a3429a1 Mon Sep 17 00:00:00 2001 From: Bingus Date: Mon, 13 Mar 2023 14:16:45 -0700 Subject: Code cleanup, clearer comments + removed some unnecessary dupe; Removed `Frames` struct return for `window::frames()` since we are just redrawing every window anyways; Interface dropping; --- src/lib.rs | 2 +- src/multi_window/application.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 65fe3b93..e7481c77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,7 +182,7 @@ pub mod touch; pub mod widget; pub mod window; -#[cfg(all(not(feature = "glow"), feature = "multi_window"))] +#[cfg(all(not(feature = "glow"), feature = "multi-window"))] pub mod multi_window; #[cfg(all(not(feature = "glow"), feature = "wgpu"))] diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index d0b515ab..1fb4bcd4 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -139,7 +139,7 @@ pub trait Application: Sized { window: window::Id, ) -> Element<'_, Self::Message, crate::Renderer>; - /// Returns the scale factor of the [`Application`]. + /// Returns the scale factor of the `window` of the [`Application`]. /// /// It can be used to dynamically control the size of the UI at runtime /// (i.e. zooming). @@ -160,7 +160,8 @@ pub trait Application: Sized { false } - /// Requests that the [`window`] be closed. + /// Returns the `Self::Message` that should be processed when a `window` is requested to + /// be closed. fn close_requested(&self, window: window::Id) -> Self::Message; /// Runs the [`Application`]. -- cgit From 41836dd80d0534608e7aedfbf2319c540a23de1a Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 15 Mar 2023 18:20:38 -0700 Subject: Added per-window theme support. --- src/multi_window/application.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 1fb4bcd4..9974128c 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -107,7 +107,8 @@ pub trait Application: Sized { /// Returns the current [`Theme`] of the [`Application`]. /// /// [`Theme`]: Self::Theme - fn theme(&self) -> Self::Theme { + #[allow(unused_variables)] + fn theme(&self, window: window::Id) -> Self::Theme { Self::Theme::default() } @@ -229,8 +230,8 @@ where self.0.title(window) } - fn theme(&self) -> A::Theme { - self.0.theme() + fn theme(&self, window: window::Id) -> A::Theme { + self.0.theme(window) } fn style(&self) -> ::Style { -- cgit From d53ccc857da4d4cda769904342aeb5a82a64f146 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 12 Jul 2023 19:21:05 -0700 Subject: refactored window storage; new helper window events (Destroyed, Created); clippy + fmt; --- src/multi_window/application.rs | 96 ++++++++++++++++++----------------------- src/settings.rs | 2 +- src/window.rs | 4 -- src/window/icon.rs | 63 +++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 59 deletions(-) create mode 100644 src/window/icon.rs (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 9974128c..0486159e 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -1,30 +1,37 @@ use crate::window; use crate::{Command, Element, Executor, Settings, Subscription}; -pub use iced_native::application::{Appearance, StyleSheet}; +pub use crate::style::application::{Appearance, StyleSheet}; /// An interactive cross-platform multi-window application. /// /// This trait is the main entrypoint of Iced. Once implemented, you can run /// your GUI application by simply calling [`run`](#method.run). /// +/// - On native platforms, it will run in its own windows. +/// - On the web, it will take control of the `` and the `<body>` of the +/// document and display only the contents of the `window::Id::MAIN` window. +/// /// An [`Application`] can execute asynchronous actions by returning a -/// [`Command`] in some of its methods. For example, to spawn a new window, you -/// can use the `iced_winit::window::spawn()` [`Command`]. +/// [`Command`] in some of its methods. If you do not intend to perform any +/// background work in your program, the [`Sandbox`] trait offers a simplified +/// interface. /// /// When using an [`Application`] with the `debug` feature enabled, a debug view /// can be toggled by pressing `F12`. /// +/// # Examples +/// See the `examples/multi-window` example to see this multi-window `Application` trait in action. +/// /// ## A simple "Hello, world!" /// /// If you just want to get started, here is a simple [`Application`] that /// says "Hello, world!": /// /// ```no_run -/// use iced::executor; -/// use iced::multi_window::Application; -/// use iced::window; +/// use iced::{executor, window}; /// use iced::{Command, Element, Settings, Theme}; +/// use iced::multi_window::{self, Application}; /// /// pub fn main() -> iced::Result { /// Hello::run(Settings::default()) @@ -32,17 +39,17 @@ pub use iced_native::application::{Appearance, StyleSheet}; /// /// struct Hello; /// -/// impl Application for Hello { +/// impl multi_window::Application for Hello { /// type Executor = executor::Default; +/// type Flags = (); /// type Message = (); /// type Theme = Theme; -/// type Flags = (); /// /// fn new(_flags: ()) -> (Hello, Command<Self::Message>) { /// (Hello, Command::none()) /// } /// -/// fn title(&self, window: window::Id) -> String { +/// fn title(&self, _window: window::Id) -> String { /// String::from("A cool application") /// } /// @@ -50,13 +57,9 @@ pub use iced_native::application::{Appearance, StyleSheet}; /// Command::none() /// } /// -/// fn view(&self, window: window::Id) -> Element<Self::Message> { +/// fn view(&self, _window: window::Id) -> Element<Self::Message> { /// "Hello, world!".into() /// } -/// -/// fn close_requested(&self, window: window::Id) -> Self::Message { -/// () -/// } /// } /// ``` pub trait Application: Sized { @@ -89,10 +92,10 @@ pub trait Application: Sized { /// [`run`]: Self::run fn new(flags: Self::Flags) -> (Self, Command<Self::Message>); - /// Returns the current title of the [`Application`]. + /// Returns the current title of the `window` of the [`Application`]. /// /// This title can be dynamic! The runtime will automatically update the - /// title of your application when necessary. + /// title of your window when necessary. fn title(&self, window: window::Id) -> String; /// Handles a __message__ and updates the state of the [`Application`]. @@ -104,7 +107,15 @@ pub trait Application: Sized { /// Any [`Command`] returned will be executed immediately in the background. fn update(&mut self, message: Self::Message) -> Command<Self::Message>; - /// Returns the current [`Theme`] of the [`Application`]. + /// Returns the widgets to display in the `window` of the [`Application`]. + /// + /// These widgets can produce __messages__ based on user interaction. + fn view( + &self, + window: window::Id, + ) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>; + + /// Returns the current [`Theme`] of the `window` of the [`Application`]. /// /// [`Theme`]: Self::Theme #[allow(unused_variables)] @@ -112,9 +123,8 @@ pub trait Application: Sized { Self::Theme::default() } - /// Returns the current [`Style`] of the [`Theme`]. + /// Returns the current `Style` of the [`Theme`]. /// - /// [`Style`]: <Self::Theme as StyleSheet>::Style /// [`Theme`]: Self::Theme fn style(&self) -> <Self::Theme as StyleSheet>::Style { <Self::Theme as StyleSheet>::Style::default() @@ -132,14 +142,6 @@ pub trait Application: Sized { Subscription::none() } - /// Returns the widgets to display in the [`Application`]. - /// - /// These widgets can produce __messages__ based on user interaction. - fn view( - &self, - window: window::Id, - ) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>; - /// Returns the scale factor of the `window` of the [`Application`]. /// /// It can be used to dynamically control the size of the UI at runtime @@ -154,18 +156,7 @@ pub trait Application: Sized { 1.0 } - /// Returns whether the [`Application`] should be terminated. - /// - /// By default, it returns `false`. - fn should_exit(&self) -> bool { - false - } - - /// Returns the `Self::Message` that should be processed when a `window` is requested to - /// be closed. - fn close_requested(&self, window: window::Id) -> Self::Message; - - /// Runs the [`Application`]. + /// Runs the multi-window [`Application`]. /// /// On native platforms, this method will take control of the current thread /// until the [`Application`] exits. @@ -182,30 +173,28 @@ pub trait Application: Sized { let renderer_settings = crate::renderer::Settings { default_font: settings.default_font, default_text_size: settings.default_text_size, - text_multithreading: settings.text_multithreading, antialiasing: if settings.antialiasing { - Some(crate::renderer::settings::Antialiasing::MSAAx4) + Some(crate::graphics::Antialiasing::MSAAx4) } else { None }, - ..crate::renderer::Settings::from_env() + ..crate::renderer::Settings::default() }; - Ok(crate::runtime::multi_window::run::< + Ok(crate::shell::multi_window::run::< Instance<Self>, Self::Executor, - crate::renderer::window::Compositor<Self::Theme>, + crate::renderer::Compositor<Self::Theme>, >(settings.into(), renderer_settings)?) } } struct Instance<A: Application>(A); -impl<A> crate::runtime::multi_window::Application for Instance<A> +impl<A> crate::runtime::multi_window::Program for Instance<A> where A: Application, { - type Flags = A::Flags; type Renderer = crate::Renderer<A::Theme>; type Message = A::Message; @@ -219,6 +208,13 @@ where ) -> Element<'_, Self::Message, Self::Renderer> { self.0.view(window) } +} + +impl<A> crate::shell::multi_window::Application for Instance<A> +where + A: Application, +{ + type Flags = A::Flags; fn new(flags: Self::Flags) -> (Self, Command<A::Message>) { let (app, command) = A::new(flags); @@ -245,12 +241,4 @@ where fn scale_factor(&self, window: window::Id) -> f64 { self.0.scale_factor(window) } - - fn should_exit(&self) -> bool { - self.0.should_exit() - } - - fn close_requested(&self, window: window::Id) -> Self::Message { - self.0.close_requested(window) - } } diff --git a/src/settings.rs b/src/settings.rs index 0dd46584..4ce2d135 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -91,7 +91,7 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> { fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> { iced_winit::Settings { id: settings.id, - window: settings.window.into(), + window: settings.window, flags: settings.flags, exit_on_close_request: settings.exit_on_close_request, } diff --git a/src/window.rs b/src/window.rs index e4601575..9f96da52 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,12 +1,8 @@ //! Configure the window of your application in native platforms. -mod position; -mod settings; pub mod icon; pub use icon::Icon; -pub use position::Position; -pub use settings::{PlatformSpecific, Settings}; pub use crate::core::window::*; pub use crate::runtime::window::*; diff --git a/src/window/icon.rs b/src/window/icon.rs new file mode 100644 index 00000000..0fe010ca --- /dev/null +++ b/src/window/icon.rs @@ -0,0 +1,63 @@ +//! Attach an icon to the window of your application. +pub use crate::core::window::icon::*; + +use crate::core::window::icon; + +use std::io; + +#[cfg(feature = "image")] +use std::path::Path; + +/// Creates an icon from an image file. +/// +/// This will return an error in case the file is missing at run-time. You may prefer [`Self::from_file_data`] instead. +#[cfg(feature = "image")] +pub fn from_file<P: AsRef<Path>>(icon_path: P) -> Result<Icon, Error> { + let icon = image_rs::io::Reader::open(icon_path)?.decode()?.to_rgba8(); + + Ok(icon::from_rgba(icon.to_vec(), icon.width(), icon.height())?) +} + +/// Creates an icon from the content of an image file. +/// +/// This content can be included in your application at compile-time, e.g. using the `include_bytes!` macro. +/// You can pass an explicit file format. Otherwise, the file format will be guessed at runtime. +#[cfg(feature = "image")] +pub fn from_file_data( + data: &[u8], + explicit_format: Option<image_rs::ImageFormat>, +) -> Result<Icon, Error> { + let mut icon = image_rs::io::Reader::new(std::io::Cursor::new(data)); + let icon_with_format = match explicit_format { + Some(format) => { + icon.set_format(format); + icon + } + None => icon.with_guessed_format()?, + }; + + let pixels = icon_with_format.decode()?.to_rgba8(); + + Ok(icon::from_rgba( + pixels.to_vec(), + pixels.width(), + pixels.height(), + )?) +} + +/// An error produced when creating an [`Icon`]. +#[derive(Debug, thiserror::Error)] +pub enum Error { + /// The [`Icon`] is not valid. + #[error("The icon is invalid: {0}")] + InvalidError(#[from] icon::Error), + + /// The underlying OS failed to create the icon. + #[error("The underlying OS failted to create the window icon: {0}")] + OsError(#[from] io::Error), + + /// The `image` crate reported an error. + #[cfg(feature = "image")] + #[error("Unable to create icon from a file: {0}")] + ImageError(#[from] image_rs::error::ImageError), +} -- cgit From 83c7870c569a2976923ee6243a19813094d44673 Mon Sep 17 00:00:00 2001 From: Bingus <shankern@protonmail.com> Date: Mon, 24 Jul 2023 14:32:59 -0700 Subject: Moved `exit_on_close_request` to window settings. This now controls whether each INDIVIDUAL window should close on CloseRequested events. --- src/settings.rs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/settings.rs b/src/settings.rs index 4ce2d135..e2a43581 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -41,14 +41,6 @@ pub struct Settings<Flags> { /// /// [`Canvas`]: crate::widget::Canvas pub antialiasing: bool, - - /// Whether the [`Application`] should exit when the user requests the - /// window to close (e.g. the user presses the close button). - /// - /// By default, it is enabled. - /// - /// [`Application`]: crate::Application - pub exit_on_close_request: bool, } impl<Flags> Settings<Flags> { @@ -65,7 +57,6 @@ impl<Flags> Settings<Flags> { default_font: default_settings.default_font, default_text_size: default_settings.default_text_size, antialiasing: default_settings.antialiasing, - exit_on_close_request: default_settings.exit_on_close_request, } } } @@ -82,7 +73,6 @@ where default_font: Default::default(), default_text_size: 16.0, antialiasing: false, - exit_on_close_request: true, } } } @@ -93,7 +83,6 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> { id: settings.id, window: settings.window, flags: settings.flags, - exit_on_close_request: settings.exit_on_close_request, } } } -- cgit From e7326f0af6f16cf2ff04fbac93bf296a044923f4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Mon, 18 Sep 2023 19:07:41 +0200 Subject: Flesh out the `editor` example a bit more --- src/settings.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/settings.rs b/src/settings.rs index d9778d7e..6b9ce095 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -2,6 +2,8 @@ use crate::window; use crate::{Font, Pixels}; +use std::borrow::Cow; + /// The settings of an application. #[derive(Debug, Clone)] pub struct Settings<Flags> { @@ -21,6 +23,9 @@ pub struct Settings<Flags> { /// [`Application`]: crate::Application pub flags: Flags, + /// The fonts to load on boot. + pub fonts: Vec<Cow<'static, [u8]>>, + /// The default [`Font`] to be used. /// /// By default, it uses [`Family::SansSerif`](crate::font::Family::SansSerif). @@ -62,6 +67,7 @@ impl<Flags> Settings<Flags> { flags, id: default_settings.id, window: default_settings.window, + fonts: default_settings.fonts, default_font: default_settings.default_font, default_text_size: default_settings.default_text_size, antialiasing: default_settings.antialiasing, @@ -79,6 +85,7 @@ where id: None, window: Default::default(), flags: Default::default(), + fonts: Default::default(), default_font: Default::default(), default_text_size: Pixels(16.0), antialiasing: false, @@ -93,6 +100,7 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> { id: settings.id, window: settings.window.into(), flags: settings.flags, + fonts: settings.fonts, exit_on_close_request: settings.exit_on_close_request, } } -- cgit From f806d001e6fb44b5a45029ca257261e6e0d4d4b2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Tue, 19 Sep 2023 20:48:50 +0200 Subject: Introduce new `iced_highlighter` subcrate --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 3cbe716a..e435a041 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,6 +174,9 @@ use iced_winit::runtime; pub use iced_futures::futures; +#[cfg(feature = "highlighter")] +pub use iced_highlighter as highlighter; + mod error; mod sandbox; -- cgit From a761448858521d11dc646e2ef5217e9e06628932 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Wed, 29 Nov 2023 00:14:27 +0100 Subject: Implement `command::channel` helper It is analogous to `subscription::channel`. --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index f9f3952c..47766e6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -190,7 +190,6 @@ pub use crate::core::{ color, Alignment, Background, BorderRadius, Color, ContentFit, Degrees, Gradient, Length, Padding, Pixels, Point, Radians, Rectangle, Size, Vector, }; -pub use crate::runtime::Command; pub mod clipboard { //! Access the clipboard. @@ -239,6 +238,11 @@ pub mod mouse { }; } +pub mod command { + //! Run asynchronous actions. + pub use crate::runtime::command::{channel, Command}; +} + pub mod subscription { //! Listen to external events in your application. pub use iced_futures::subscription::{ @@ -287,6 +291,7 @@ pub mod widget { } pub use application::Application; +pub use command::Command; pub use error::Error; pub use event::Event; pub use executor::Executor; -- cgit From 6740c2c5d6b24399dab1343abdfec5daf4b03c98 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Wed, 29 Nov 2023 22:46:47 +0100 Subject: Fix broken intra-doc links --- src/multi_window/application.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 0486159e..b6f15149 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -62,6 +62,8 @@ pub use crate::style::application::{Appearance, StyleSheet}; /// } /// } /// ``` +/// +/// [`Sandbox`]: crate::Sandbox pub trait Application: Sized { /// The [`Executor`] that will run commands and subscriptions. /// -- cgit From 3b39ba7029832cab5235fb5538b46148d599daa7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Wed, 29 Nov 2023 22:52:46 +0100 Subject: Fix unused import in `multi_window::application` --- src/multi_window/application.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index b6f15149..4a91bdf4 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -1,8 +1,7 @@ +use crate::style::application::StyleSheet; use crate::window; use crate::{Command, Element, Executor, Settings, Subscription}; -pub use crate::style::application::{Appearance, StyleSheet}; - /// An interactive cross-platform multi-window application. /// /// This trait is the main entrypoint of Iced. Once implemented, you can run -- cgit From 0322e820eb40d36a7425246278b7bcb22b7010aa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector0193@gmail.com> Date: Mon, 27 Mar 2023 15:43:52 +0200 Subject: Create `layout` example --- src/time.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/time.rs b/src/time.rs index 37d454ed..f10f7a5e 100644 --- a/src/time.rs +++ b/src/time.rs @@ -1,4 +1,5 @@ //! Listen and react to time. pub use iced_core::time::{Duration, Instant}; +#[allow(unused_imports)] pub use iced_futures::backend::default::time::*; -- cgit From 64d1ce5532f55d152fa5819532a138da2dca1a39 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez <hector@hecrj.dev> Date: Tue, 16 Jan 2024 13:28:00 +0100 Subject: Refactor `KeyCode` into `Key` and `Location` --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 002d2a79..446590ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -230,7 +230,8 @@ pub mod event { pub mod keyboard { //! Listen and react to keyboard events. - pub use crate::core::keyboard::{Event, KeyCode, Modifiers}; + pub use crate::core::keyboard::key; + pub use crate::core::keyboard::{Event, Key, Location, Modifiers}; pub use iced_futures::keyboard::{on_key_press, on_key_release}; } -- cgit