From 5100b5d0a1f654ec1254b7765ceadfb9091d6939 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 24 Feb 2023 23:24:48 +0100 Subject: Introduce `iced_renderer` subcrate featuring runtime renderer fallback --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 31ec4f48..bb162f2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,7 +182,7 @@ pub mod touch; pub mod widget; pub mod window; -use iced_wgpu as renderer; +use iced_renderer as renderer; use iced_winit as runtime; pub use iced_native::theme; -- cgit From 3a0d34c0240f4421737a6a08761f99d6f8140d02 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 4 Mar 2023 05:37:11 +0100 Subject: Create `iced_widget` subcrate and re-organize the whole codebase --- src/lib.rs | 134 +++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 108 insertions(+), 26 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index bb162f2d..b71b7781 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -164,51 +164,133 @@ #![forbid(rust_2018_idioms, unsafe_code)] #![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_cfg))] +use iced_widget::graphics; +use iced_widget::renderer; +use iced_widget::style; +use iced_winit as shell; +use iced_winit::core; +use iced_winit::native; + +pub use iced_futures::futures; -mod element; mod error; -mod result; mod sandbox; pub mod application; -pub mod clipboard; -pub mod executor; -pub mod keyboard; -pub mod mouse; -pub mod overlay; pub mod settings; pub mod time; -pub mod touch; -pub mod widget; pub mod window; -use iced_renderer as renderer; -use iced_winit as runtime; +#[cfg(feature = "advanced")] +pub mod advanced; + +pub use style::theme; + +pub use crate::core::alignment; +pub use crate::core::event; +pub use crate::core::{ + color, Alignment, Background, Color, ContentFit, Length, Padding, Point, + Rectangle, Size, Vector, +}; +pub use crate::native::Command; +pub use native::subscription; + +pub mod clipboard { + //! Access the clipboard. + pub use crate::shell::clipboard::{read, write}; +} + +pub mod executor { + //! Choose your preferred executor to power your application. + pub use iced_futures::Executor; + + /// A default cross-platform executor. + /// + /// - On native platforms, it will use: + /// - `iced_futures::backend::native::tokio` when the `tokio` feature is enabled. + /// - `iced_futures::backend::native::async-std` when the `async-std` feature is + /// enabled. + /// - `iced_futures::backend::native::smol` when the `smol` feature is enabled. + /// - `iced_futures::backend::native::thread_pool` otherwise. + /// + /// - On Wasm, it will use `iced_futures::backend::wasm::wasm_bindgen`. + pub type Default = iced_futures::backend::default::Executor; +} + +pub mod font { + //! Load and use fonts. + pub use crate::core::font::*; + pub use crate::native::font::*; +} + +pub mod keyboard { + //! Listen and react to keyboard events. + pub use crate::core::keyboard::{Event, KeyCode, Modifiers}; +} + +pub mod mouse { + //! Listen and react to mouse events. + pub use crate::core::mouse::{Button, Event, Interaction, ScrollDelta}; +} -pub use iced_native::theme; -pub use runtime::event; -pub use runtime::font; -pub use runtime::subscription; +#[cfg(feature = "system")] +pub mod system { + //! Retrieve system information. + pub use crate::native::system::Information; + pub use crate::shell::system::*; +} + +pub mod overlay { + //! Display interactive elements on top of other widgets. + + /// A generic [`Overlay`]. + /// + /// This is an alias of an `iced_native` element with a default `Renderer`. + /// + /// [`Overlay`]: iced_native::Overlay + pub type Element<'a, Message, Renderer = crate::Renderer> = + crate::core::overlay::Element<'a, Message, Renderer>; + + pub use iced_widget::overlay::*; +} + +pub mod touch { + //! Listen and react to touch events. + pub use crate::core::touch::{Event, Finger}; +} + +pub mod widget { + //! Use the built-in widgets or create your own. + pub use iced_widget::*; + + // We hide the re-exported modules by `iced_widget` + mod core {} + mod graphics {} + mod native {} + mod renderer {} + mod style {} +} pub use application::Application; -pub use element::Element; pub use error::Error; pub use event::Event; pub use executor::Executor; pub use font::Font; -pub use renderer::Renderer; -pub use result::Result; pub use sandbox::Sandbox; pub use settings::Settings; pub use subscription::Subscription; pub use theme::Theme; -pub use runtime::alignment; -pub use runtime::futures; -pub use runtime::{ - color, Alignment, Background, Color, Command, ContentFit, Length, Padding, - Point, Rectangle, Size, Vector, -}; +/// The default renderer. +pub type Renderer = renderer::Renderer; -#[cfg(feature = "system")] -pub use runtime::system; +/// A generic widget. +/// +/// This is an alias of an `iced_native` element with a default `Renderer`. +pub type Element<'a, Message, Renderer = crate::Renderer> = + crate::core::Element<'a, Message, Renderer>; + +/// The result of running an [`Application`]. +/// +/// [`Application`]: crate::Application +pub type Result = std::result::Result<(), Error>; -- cgit From f4cf488e0b083b5d7b7612c650917233163ee9cb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Mar 2023 04:15:10 +0100 Subject: Remove generic `Hasher` and `Event` from `subscription::Recipe` --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index b71b7781..b9f87d5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,7 +193,6 @@ pub use crate::core::{ Rectangle, Size, Vector, }; pub use crate::native::Command; -pub use native::subscription; pub mod clipboard { //! Access the clipboard. @@ -233,6 +232,13 @@ pub mod mouse { pub use crate::core::mouse::{Button, Event, Interaction, ScrollDelta}; } +pub mod subscription { + //! Listen to external events in your application. + pub use iced_futures::subscription::{ + events, events_with, run, run_with_id, unfold, Subscription, + }; +} + #[cfg(feature = "system")] pub mod system { //! Retrieve system information. -- cgit From 99e0a71504456976ba88040f5d1d3bbc347694ea Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Mar 2023 06:35:20 +0100 Subject: Rename `iced_native` to `iced_runtime` --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index b9f87d5d..c59d5058 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,7 +169,7 @@ use iced_widget::renderer; use iced_widget::style; use iced_winit as shell; use iced_winit::core; -use iced_winit::native; +use iced_winit::runtime; pub use iced_futures::futures; @@ -192,11 +192,11 @@ pub use crate::core::{ color, Alignment, Background, Color, ContentFit, Length, Padding, Point, Rectangle, Size, Vector, }; -pub use crate::native::Command; +pub use crate::runtime::Command; pub mod clipboard { //! Access the clipboard. - pub use crate::shell::clipboard::{read, write}; + pub use crate::runtime::clipboard::{read, write}; } pub mod executor { @@ -219,7 +219,7 @@ pub mod executor { pub mod font { //! Load and use fonts. pub use crate::core::font::*; - pub use crate::native::font::*; + pub use crate::runtime::font::*; } pub mod keyboard { @@ -242,7 +242,7 @@ pub mod subscription { #[cfg(feature = "system")] pub mod system { //! Retrieve system information. - pub use crate::native::system::Information; + pub use crate::runtime::system::Information; pub use crate::shell::system::*; } -- cgit