diff options
author | 2023-03-04 05:37:11 +0100 | |
---|---|---|
committer | 2023-03-04 05:37:11 +0100 | |
commit | 3a0d34c0240f4421737a6a08761f99d6f8140d02 (patch) | |
tree | c9a4a6b8e9c1db1b8fcd05bc98e3f131d5ef4bd5 /src/lib.rs | |
parent | c54409d1711e1f615c7ea4b02c082954e340632a (diff) | |
download | iced-3a0d34c0240f4421737a6a08761f99d6f8140d02.tar.gz iced-3a0d34c0240f4421737a6a08761f99d6f8140d02.tar.bz2 iced-3a0d34c0240f4421737a6a08761f99d6f8140d02.zip |
Create `iced_widget` subcrate and re-organize the whole codebase
Diffstat (limited to '')
-rw-r--r-- | src/lib.rs | 134 |
1 files changed, 108 insertions, 26 deletions
@@ -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<Theme = style::Theme> = renderer::Renderer<Theme>; -#[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>; |