summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml29
-rw-r--r--core/Cargo.toml1
-rw-r--r--core/src/clipboard.rs23
-rw-r--r--core/src/element.rs (renamed from native/src/element.rs)67
-rw-r--r--core/src/event.rs (renamed from native/src/event.rs)2
-rw-r--r--core/src/hasher.rs (renamed from native/src/hasher.rs)0
-rw-r--r--core/src/image.rs (renamed from native/src/image.rs)0
-rw-r--r--core/src/layout.rs (renamed from native/src/layout.rs)0
-rw-r--r--core/src/layout/DRUID_LICENSE (renamed from native/src/layout/DRUID_LICENSE)0
-rw-r--r--core/src/layout/flex.rs (renamed from native/src/layout/flex.rs)0
-rw-r--r--core/src/layout/limits.rs (renamed from native/src/layout/limits.rs)0
-rw-r--r--core/src/layout/node.rs (renamed from native/src/layout/node.rs)0
-rw-r--r--core/src/lib.rs24
-rw-r--r--core/src/mouse.rs3
-rw-r--r--core/src/mouse/click.rs (renamed from native/src/mouse/click.rs)0
-rw-r--r--core/src/overlay.rs (renamed from native/src/overlay.rs)3
-rw-r--r--core/src/overlay/element.rs (renamed from native/src/overlay/element.rs)0
-rw-r--r--core/src/overlay/group.rs (renamed from native/src/overlay/group.rs)4
-rw-r--r--core/src/renderer.rs (renamed from native/src/renderer.rs)1
-rw-r--r--core/src/renderer/null.rs (renamed from native/src/renderer/null.rs)4
-rw-r--r--core/src/shell.rs (renamed from native/src/shell.rs)0
-rw-r--r--core/src/svg.rs (renamed from native/src/svg.rs)0
-rw-r--r--core/src/text.rs (renamed from native/src/text.rs)0
-rw-r--r--core/src/touch.rs (renamed from native/src/touch.rs)0
-rw-r--r--core/src/widget.rs145
-rw-r--r--core/src/widget/id.rs (renamed from native/src/widget/id.rs)2
-rw-r--r--core/src/widget/operation.rs (renamed from native/src/widget/operation.rs)0
-rw-r--r--core/src/widget/operation/focusable.rs (renamed from native/src/widget/operation/focusable.rs)0
-rw-r--r--core/src/widget/operation/scrollable.rs (renamed from native/src/widget/operation/scrollable.rs)0
-rw-r--r--core/src/widget/operation/text_input.rs (renamed from native/src/widget/operation/text_input.rs)0
-rw-r--r--core/src/widget/text.rs (renamed from native/src/widget/text.rs)54
-rw-r--r--core/src/widget/tree.rs (renamed from native/src/widget/tree.rs)0
-rw-r--r--core/src/window.rs10
-rw-r--r--core/src/window/event.rs (renamed from native/src/window/event.rs)0
-rw-r--r--core/src/window/mode.rs (renamed from native/src/window/mode.rs)0
-rw-r--r--core/src/window/redraw_request.rs (renamed from native/src/window/redraw_request.rs)0
-rw-r--r--core/src/window/user_attention.rs (renamed from native/src/window/user_attention.rs)0
-rw-r--r--examples/component/Cargo.toml4
-rw-r--r--examples/component/src/main.rs22
-rw-r--r--examples/custom_quad/Cargo.toml3
-rw-r--r--examples/custom_quad/src/main.rs8
-rw-r--r--examples/custom_widget/Cargo.toml3
-rw-r--r--examples/custom_widget/src/main.rs8
-rw-r--r--examples/events/Cargo.toml1
-rw-r--r--examples/events/src/main.rs9
-rw-r--r--examples/geometry/Cargo.toml3
-rw-r--r--examples/geometry/src/main.rs38
-rw-r--r--examples/integration/Cargo.toml1
-rw-r--r--examples/integration/src/controls.rs10
-rw-r--r--examples/integration/src/main.rs91
-rw-r--r--examples/integration/src/scene.rs2
-rw-r--r--examples/lazy/Cargo.toml3
-rw-r--r--examples/lazy/src/main.rs3
-rw-r--r--examples/modal/Cargo.toml3
-rw-r--r--examples/modal/src/main.rs44
-rw-r--r--examples/pane_grid/Cargo.toml4
-rw-r--r--examples/pane_grid/src/main.rs8
-rw-r--r--examples/toast/Cargo.toml3
-rw-r--r--examples/toast/src/main.rs24
-rw-r--r--examples/url_handler/Cargo.toml1
-rw-r--r--examples/url_handler/src/main.rs10
-rw-r--r--graphics/Cargo.toml10
-rw-r--r--graphics/src/backend.rs8
-rw-r--r--graphics/src/compositor.rs (renamed from graphics/src/window/compositor.rs)6
-rw-r--r--graphics/src/geometry.rs4
-rw-r--r--graphics/src/geometry/fill.rs2
-rw-r--r--graphics/src/geometry/path.rs2
-rw-r--r--graphics/src/geometry/path/arc.rs2
-rw-r--r--graphics/src/geometry/path/builder.rs3
-rw-r--r--graphics/src/geometry/stroke.rs2
-rw-r--r--graphics/src/geometry/style.rs2
-rw-r--r--graphics/src/geometry/text.rs4
-rw-r--r--graphics/src/image/raster.rs4
-rw-r--r--graphics/src/image/storage.rs2
-rw-r--r--graphics/src/image/vector.rs5
-rw-r--r--graphics/src/lib.rs11
-rw-r--r--graphics/src/overlay.rs2
-rw-r--r--graphics/src/overlay/menu.rs3
-rw-r--r--graphics/src/primitive.rs9
-rw-r--r--graphics/src/renderer.rs20
-rw-r--r--graphics/src/viewport.rs4
-rw-r--r--graphics/src/window.rs10
-rw-r--r--graphics/src/window/gl_compositor.rs71
-rw-r--r--lazy/Cargo.toml18
-rw-r--r--native/Cargo.toml7
-rw-r--r--native/src/clipboard.rs22
-rw-r--r--native/src/command.rs4
-rw-r--r--native/src/debug/basic.rs2
-rw-r--r--native/src/lib.rs39
-rw-r--r--native/src/mouse.rs6
-rw-r--r--native/src/program.rs6
-rw-r--r--native/src/program/state.rs18
-rw-r--r--native/src/runtime.rs4
-rw-r--r--native/src/subscription.rs17
-rw-r--r--native/src/user_interface.rs82
-rw-r--r--native/src/widget.rs206
-rw-r--r--native/src/widget/action.rs5
-rw-r--r--native/src/widget/helpers.rs317
-rw-r--r--native/src/window.rs13
-rw-r--r--native/src/window/action.rs4
-rw-r--r--renderer/Cargo.toml4
-rw-r--r--renderer/src/backend.rs11
-rw-r--r--renderer/src/compositor.rs (renamed from renderer/src/window/compositor.rs)9
-rw-r--r--renderer/src/geometry.rs6
-rw-r--r--renderer/src/geometry/cache.rs4
-rw-r--r--renderer/src/lib.rs14
-rw-r--r--renderer/src/settings.rs3
-rw-r--r--renderer/src/window.rs3
-rw-r--r--src/advanced.rs9
-rw-r--r--src/application.rs12
-rw-r--r--src/clipboard.rs3
-rw-r--r--src/element.rs5
-rw-r--r--src/error.rs16
-rw-r--r--src/executor.rs14
-rw-r--r--src/keyboard.rs2
-rw-r--r--src/lib.rs134
-rw-r--r--src/mouse.rs2
-rw-r--r--src/overlay.rs18
-rw-r--r--src/result.rs6
-rw-r--r--src/touch.rs2
-rw-r--r--src/widget.rs239
-rw-r--r--src/window.rs5
-rw-r--r--style/src/lib.rs3
-rw-r--r--style/src/text.rs2
-rw-r--r--style/src/theme.rs2
-rw-r--r--tiny_skia/src/backend.rs18
-rw-r--r--tiny_skia/src/geometry.rs12
-rw-r--r--tiny_skia/src/lib.rs11
-rw-r--r--tiny_skia/src/settings.rs2
-rw-r--r--tiny_skia/src/text.rs11
-rw-r--r--tiny_skia/src/window/compositor.rs9
-rw-r--r--wgpu/Cargo.toml4
-rw-r--r--wgpu/src/backend.rs20
-rw-r--r--wgpu/src/geometry.rs8
-rw-r--r--wgpu/src/image.rs21
-rw-r--r--wgpu/src/image/atlas.rs4
-rw-r--r--wgpu/src/image/atlas/allocation.rs3
-rw-r--r--wgpu/src/image/atlas/allocator.rs4
-rw-r--r--wgpu/src/image/atlas/entry.rs5
-rw-r--r--wgpu/src/layer.rs9
-rw-r--r--wgpu/src/layer/image.rs6
-rw-r--r--wgpu/src/layer/mesh.rs4
-rw-r--r--wgpu/src/layer/text.rs3
-rw-r--r--wgpu/src/lib.rs15
-rw-r--r--wgpu/src/quad.rs6
-rw-r--r--wgpu/src/settings.rs5
-rw-r--r--wgpu/src/text.rs14
-rw-r--r--wgpu/src/triangle.rs24
-rw-r--r--wgpu/src/triangle/msaa.rs4
-rw-r--r--wgpu/src/window/compositor.rs10
-rw-r--r--widget/Cargo.toml37
-rw-r--r--widget/src/button.rs (renamed from native/src/widget/button.rs)34
-rw-r--r--widget/src/canvas.rs (renamed from src/widget/canvas.rs)48
-rw-r--r--widget/src/canvas/cursor.rs (renamed from src/widget/canvas/cursor.rs)2
-rw-r--r--widget/src/canvas/event.rs (renamed from src/widget/canvas/event.rs)8
-rw-r--r--widget/src/canvas/program.rs (renamed from src/widget/canvas/program.rs)13
-rw-r--r--widget/src/checkbox.rs (renamed from native/src/widget/checkbox.rs)36
-rw-r--r--widget/src/column.rs (renamed from native/src/widget/column.rs)20
-rw-r--r--widget/src/container.rs (renamed from native/src/widget/container.rs)28
-rw-r--r--widget/src/helpers.rs362
-rw-r--r--widget/src/image.rs (renamed from native/src/widget/image.rs)15
-rw-r--r--widget/src/image/viewer.rs (renamed from native/src/widget/image/viewer.rs)14
-rw-r--r--widget/src/lazy.rs (renamed from lazy/src/lazy.rs)47
-rw-r--r--widget/src/lazy/cache.rs (renamed from lazy/src/cache.rs)4
-rw-r--r--widget/src/lazy/component.rs (renamed from lazy/src/component.rs)32
-rw-r--r--widget/src/lazy/helpers.rs (renamed from lazy/src/lib.rs)37
-rw-r--r--widget/src/lazy/responsive.rs (renamed from lazy/src/responsive.rs)40
-rw-r--r--widget/src/lib.rs122
-rw-r--r--widget/src/overlay.rs1
-rw-r--r--widget/src/overlay/menu.rs (renamed from native/src/overlay/menu.rs)34
-rw-r--r--widget/src/pane_grid.rs (renamed from native/src/widget/pane_grid.rs)40
-rw-r--r--widget/src/pane_grid/axis.rs (renamed from native/src/widget/pane_grid/axis.rs)2
-rw-r--r--widget/src/pane_grid/configuration.rs (renamed from native/src/widget/pane_grid/configuration.rs)2
-rw-r--r--widget/src/pane_grid/content.rs (renamed from native/src/widget/pane_grid/content.rs)30
-rw-r--r--widget/src/pane_grid/direction.rs (renamed from native/src/widget/pane_grid/direction.rs)0
-rw-r--r--widget/src/pane_grid/draggable.rs (renamed from native/src/widget/pane_grid/draggable.rs)2
-rw-r--r--widget/src/pane_grid/node.rs (renamed from native/src/widget/pane_grid/node.rs)4
-rw-r--r--widget/src/pane_grid/pane.rs (renamed from native/src/widget/pane_grid/pane.rs)0
-rw-r--r--widget/src/pane_grid/split.rs (renamed from native/src/widget/pane_grid/split.rs)0
-rw-r--r--widget/src/pane_grid/state.rs (renamed from native/src/widget/pane_grid/state.rs)6
-rw-r--r--widget/src/pane_grid/title_bar.rs (renamed from native/src/widget/pane_grid/title_bar.rs)24
-rw-r--r--widget/src/pick_list.rs (renamed from native/src/widget/pick_list.rs)33
-rw-r--r--widget/src/progress_bar.rs (renamed from native/src/widget/progress_bar.rs)24
-rw-r--r--widget/src/qr_code.rs (renamed from src/widget/qr_code.rs)15
-rw-r--r--widget/src/radio.rs (renamed from native/src/widget/radio.rs)31
-rw-r--r--widget/src/row.rs (renamed from native/src/widget/row.rs)20
-rw-r--r--widget/src/rule.rs (renamed from native/src/widget/rule.rs)20
-rw-r--r--widget/src/scrollable.rs (renamed from native/src/widget/scrollable.rs)168
-rw-r--r--widget/src/slider.rs (renamed from native/src/widget/slider.rs)32
-rw-r--r--widget/src/space.rs (renamed from native/src/widget/space.rs)13
-rw-r--r--widget/src/svg.rs (renamed from native/src/widget/svg.rs)14
-rw-r--r--widget/src/text.rs4
-rw-r--r--widget/src/text_input.rs (renamed from native/src/widget/text_input.rs)39
-rw-r--r--widget/src/text_input/cursor.rs (renamed from native/src/widget/text_input/cursor.rs)2
-rw-r--r--widget/src/text_input/editor.rs (renamed from native/src/widget/text_input/editor.rs)2
-rw-r--r--widget/src/text_input/value.rs (renamed from native/src/widget/text_input/value.rs)0
-rw-r--r--widget/src/toggler.rs (renamed from native/src/widget/toggler.rs)30
-rw-r--r--widget/src/tooltip.rs (renamed from native/src/widget/tooltip.rs)37
-rw-r--r--widget/src/vertical_slider.rs (renamed from native/src/widget/vertical_slider.rs)37
-rw-r--r--winit/Cargo.toml6
-rw-r--r--winit/src/application.rs77
-rw-r--r--winit/src/application/state.rs14
-rw-r--r--winit/src/clipboard.rs7
-rw-r--r--winit/src/conversion.rs11
-rw-r--r--winit/src/error.rs7
-rw-r--r--winit/src/lib.rs8
-rw-r--r--winit/src/proxy.rs2
-rw-r--r--winit/src/system.rs7
-rw-r--r--winit/src/window.rs52
209 files changed, 1963 insertions, 2187 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 28938df9..49a52311 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,13 +13,15 @@ categories = ["gui"]
[features]
# Enables the `Image` widget
-image = ["iced_renderer/image", "image_rs"]
+image = ["iced_widget/image", "image_rs"]
# Enables the `Svg` widget
-svg = ["iced_renderer/svg"]
+svg = ["iced_widget/svg"]
# Enables the `Canvas` widget
-canvas = ["iced_renderer/geometry"]
+canvas = ["iced_widget/canvas"]
# Enables the `QRCode` widget
-qr_code = ["canvas", "qrcode"]
+qr_code = ["iced_widget/qr_code"]
+# Enables lazy widgets
+lazy = ["iced_widget/lazy"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
@@ -32,11 +34,8 @@ smol = ["iced_futures/smol"]
palette = ["iced_core/palette"]
# Enables querying system information
system = ["iced_winit/system"]
-# Enables chrome traces
-chrome-trace = [
- "iced_winit/chrome-trace",
- "iced_renderer/tracing",
-]
+# Enables the advanced module
+advanced = []
[badges]
maintenance = { status = "actively-developed" }
@@ -46,12 +45,12 @@ members = [
"core",
"futures",
"graphics",
- "lazy",
"native",
"renderer",
"style",
"tiny_skia",
"wgpu",
+ "widget",
"winit",
"examples/*",
]
@@ -59,21 +58,15 @@ members = [
[dependencies]
iced_core = { version = "0.8", path = "core" }
iced_futures = { version = "0.6", path = "futures" }
-iced_native = { version = "0.9", path = "native" }
-iced_renderer = { version = "0.1", path = "renderer" }
+iced_widget = { version = "0.1", path = "widget" }
iced_winit = { version = "0.8", path = "winit", features = ["application"] }
-thiserror = "1.0"
+thiserror = "1"
[dependencies.image_rs]
version = "0.24"
package = "image"
optional = true
-[dependencies.qrcode]
-version = "0.12"
-optional = true
-default-features = false
-
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = ["image", "svg", "canvas", "qr_code"]
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 7ccb7b7a..9edc20f6 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -10,6 +10,7 @@ repository = "https://github.com/iced-rs/iced"
[dependencies]
bitflags = "1.2"
thiserror = "1"
+twox-hash = { version = "1.5", default-features = false }
[dependencies.palette]
version = "0.6"
diff --git a/core/src/clipboard.rs b/core/src/clipboard.rs
new file mode 100644
index 00000000..081b4004
--- /dev/null
+++ b/core/src/clipboard.rs
@@ -0,0 +1,23 @@
+//! Access the clipboard.
+
+/// A buffer for short-term storage and transfer within and between
+/// applications.
+pub trait Clipboard {
+ /// Reads the current content of the [`Clipboard`] as text.
+ fn read(&self) -> Option<String>;
+
+ /// Writes the given text contents to the [`Clipboard`].
+ fn write(&mut self, contents: String);
+}
+
+/// A null implementation of the [`Clipboard`] trait.
+#[derive(Debug, Clone, Copy)]
+pub struct Null;
+
+impl Clipboard for Null {
+ fn read(&self) -> Option<String> {
+ None
+ }
+
+ fn write(&mut self, _contents: String) {}
+}
diff --git a/native/src/element.rs b/core/src/element.rs
index 0a677d20..98c53737 100644
--- a/native/src/element.rs
+++ b/core/src/element.rs
@@ -90,41 +90,65 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
/// We compose the previous __messages__ with the index of the counter
/// producing them. Let's implement our __view logic__ now:
///
- /// ```
+ /// ```no_run
/// # mod counter {
- /// # type Text<'a> = iced_native::widget::Text<'a, iced_native::renderer::Null>;
- /// #
/// # #[derive(Debug, Clone, Copy)]
/// # pub enum Message {}
/// # pub struct Counter;
/// #
/// # impl Counter {
- /// # pub fn view(&mut self) -> Text {
- /// # Text::new("")
+ /// # pub fn view(
+ /// # &self,
+ /// # ) -> iced_core::Element<Message, iced_core::renderer::Null> {
+ /// # unimplemented!()
/// # }
/// # }
/// # }
/// #
- /// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
- /// # }
+ /// # mod iced {
+ /// # pub use iced_core::renderer::Null as Renderer;
+ /// # pub use iced_core::Element;
/// #
- /// # use counter::Counter;
+ /// # pub mod widget {
+ /// # pub struct Row<Message> {
+ /// # _t: std::marker::PhantomData<Message>,
+ /// # }
/// #
- /// # struct ManyCounters {
- /// # counters: Vec<Counter>,
- /// # }
+ /// # impl<Message> Row<Message> {
+ /// # pub fn new() -> Self {
+ /// # unimplemented!()
+ /// # }
/// #
- /// # #[derive(Debug, Clone, Copy)]
- /// # pub enum Message {
- /// # Counter(usize, counter::Message)
+ /// # pub fn spacing(mut self, _: u32) -> Self {
+ /// # unimplemented!()
+ /// # }
+ /// #
+ /// # pub fn push(
+ /// # mut self,
+ /// # _: iced_core::Element<Message, iced_core::renderer::Null>,
+ /// # ) -> Self {
+ /// # unimplemented!()
+ /// # }
+ /// # }
+ /// # }
/// # }
- /// use iced_native::Element;
- /// use iced_native::widget::Row;
- /// use iced_wgpu::Renderer;
+ /// #
+ /// use counter::Counter;
+ ///
+ /// use iced::widget::Row;
+ /// use iced::{Element, Renderer};
+ ///
+ /// struct ManyCounters {
+ /// counters: Vec<Counter>,
+ /// }
+ ///
+ /// #[derive(Debug, Clone, Copy)]
+ /// pub enum Message {
+ /// Counter(usize, counter::Message),
+ /// }
///
/// impl ManyCounters {
- /// pub fn view(&mut self) -> Row<Message, Renderer> {
+ /// pub fn view(&mut self) -> Row<Message> {
/// // We can quickly populate a `Row` by folding over our counters
/// self.counters.iter_mut().enumerate().fold(
/// Row::new().spacing(20),
@@ -137,9 +161,10 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
/// // Here we turn our `Element<counter::Message>` into
/// // an `Element<Message>` by combining the `index` and the
/// // message of the `element`.
- /// element.map(move |message| Message::Counter(index, message))
+ /// element
+ /// .map(move |message| Message::Counter(index, message)),
/// )
- /// }
+ /// },
/// )
/// }
/// }
diff --git a/native/src/event.rs b/core/src/event.rs
index bcfaf891..953cd73f 100644
--- a/native/src/event.rs
+++ b/core/src/event.rs
@@ -62,7 +62,7 @@ impl Status {
/// `Captured` takes precedence over `Ignored`:
///
/// ```
- /// use iced_native::event::Status;
+ /// use iced_core::event::Status;
///
/// assert_eq!(Status::Ignored.merge(Status::Ignored), Status::Ignored);
/// assert_eq!(Status::Ignored.merge(Status::Captured), Status::Captured);
diff --git a/native/src/hasher.rs b/core/src/hasher.rs
index fa52f16d..fa52f16d 100644
--- a/native/src/hasher.rs
+++ b/core/src/hasher.rs
diff --git a/native/src/image.rs b/core/src/image.rs
index 70fbade0..70fbade0 100644
--- a/native/src/image.rs
+++ b/core/src/image.rs
diff --git a/native/src/layout.rs b/core/src/layout.rs
index 04954fb9..04954fb9 100644
--- a/native/src/layout.rs
+++ b/core/src/layout.rs
diff --git a/native/src/layout/DRUID_LICENSE b/core/src/layout/DRUID_LICENSE
index d6456956..d6456956 100644
--- a/native/src/layout/DRUID_LICENSE
+++ b/core/src/layout/DRUID_LICENSE
diff --git a/native/src/layout/flex.rs b/core/src/layout/flex.rs
index 5d70c2fc..5d70c2fc 100644
--- a/native/src/layout/flex.rs
+++ b/core/src/layout/flex.rs
diff --git a/native/src/layout/limits.rs b/core/src/layout/limits.rs
index 5d3c1556..5d3c1556 100644
--- a/native/src/layout/limits.rs
+++ b/core/src/layout/limits.rs
diff --git a/native/src/layout/node.rs b/core/src/layout/node.rs
index e0c7dcb2..e0c7dcb2 100644
--- a/native/src/layout/node.rs
+++ b/core/src/layout/node.rs
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 1e4f0411..5bdcee6a 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -25,33 +25,57 @@
#![forbid(unsafe_code, rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
pub mod alignment;
+pub mod clipboard;
+pub mod event;
pub mod font;
pub mod gradient;
+pub mod image;
pub mod keyboard;
+pub mod layout;
pub mod mouse;
+pub mod overlay;
+pub mod renderer;
+pub mod svg;
+pub mod text;
pub mod time;
+pub mod touch;
+pub mod widget;
+pub mod window;
mod background;
mod color;
mod content_fit;
+mod element;
+mod hasher;
mod length;
mod padding;
mod pixels;
mod point;
mod rectangle;
+mod shell;
mod size;
mod vector;
pub use alignment::Alignment;
pub use background::Background;
+pub use clipboard::Clipboard;
pub use color::Color;
pub use content_fit::ContentFit;
+pub use element::Element;
+pub use event::Event;
pub use font::Font;
pub use gradient::Gradient;
+pub use hasher::Hasher;
+pub use layout::Layout;
pub use length::Length;
+pub use overlay::Overlay;
pub use padding::Padding;
pub use pixels::Pixels;
pub use point::Point;
pub use rectangle::Rectangle;
+pub use renderer::Renderer;
+pub use shell::Shell;
pub use size::Size;
+pub use text::Text;
pub use vector::Vector;
+pub use widget::Widget;
diff --git a/core/src/mouse.rs b/core/src/mouse.rs
index 48214f65..0c405ce6 100644
--- a/core/src/mouse.rs
+++ b/core/src/mouse.rs
@@ -1,8 +1,11 @@
//! Handle mouse events.
+pub mod click;
+
mod button;
mod event;
mod interaction;
pub use button::Button;
+pub use click::Click;
pub use event::{Event, ScrollDelta};
pub use interaction::Interaction;
diff --git a/native/src/mouse/click.rs b/core/src/mouse/click.rs
index 4a7d796c..4a7d796c 100644
--- a/native/src/mouse/click.rs
+++ b/core/src/mouse/click.rs
diff --git a/native/src/overlay.rs b/core/src/overlay.rs
index 6cada416..b9f3c735 100644
--- a/native/src/overlay.rs
+++ b/core/src/overlay.rs
@@ -2,11 +2,8 @@
mod element;
mod group;
-pub mod menu;
-
pub use element::Element;
pub use group::Group;
-pub use menu::Menu;
use crate::event::{self, Event};
use crate::layout;
diff --git a/native/src/overlay/element.rs b/core/src/overlay/element.rs
index 237d25d1..237d25d1 100644
--- a/native/src/overlay/element.rs
+++ b/core/src/overlay/element.rs
diff --git a/native/src/overlay/group.rs b/core/src/overlay/group.rs
index 1126f0cf..0c48df34 100644
--- a/native/src/overlay/group.rs
+++ b/core/src/overlay/group.rs
@@ -1,12 +1,10 @@
-use iced_core::{Point, Rectangle, Size};
-
use crate::event;
use crate::layout;
use crate::mouse;
use crate::overlay;
use crate::renderer;
use crate::widget;
-use crate::{Clipboard, Event, Layout, Overlay, Shell};
+use crate::{Clipboard, Event, Layout, Overlay, Point, Rectangle, Shell, Size};
/// An [`Overlay`] container that displays multiple overlay [`overlay::Element`]
/// children.
diff --git a/native/src/renderer.rs b/core/src/renderer.rs
index 2ac78982..d6247e39 100644
--- a/native/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -1,6 +1,7 @@
//! Write your own renderer.
#[cfg(debug_assertions)]
mod null;
+
#[cfg(debug_assertions)]
pub use null::Null;
diff --git a/native/src/renderer/null.rs b/core/src/renderer/null.rs
index 150ee786..d93338ae 100644
--- a/native/src/renderer/null.rs
+++ b/core/src/renderer/null.rs
@@ -1,6 +1,6 @@
use crate::renderer::{self, Renderer};
use crate::text::{self, Text};
-use crate::{Background, Font, Point, Rectangle, Size, Theme, Vector};
+use crate::{Background, Font, Point, Rectangle, Size, Vector};
use std::borrow::Cow;
@@ -18,7 +18,7 @@ impl Null {
}
impl Renderer for Null {
- type Theme = Theme;
+ type Theme = ();
fn with_layer(&mut self, _bounds: Rectangle, _f: impl FnOnce(&mut Self)) {}
diff --git a/native/src/shell.rs b/core/src/shell.rs
index 74a5c616..74a5c616 100644
--- a/native/src/shell.rs
+++ b/core/src/shell.rs
diff --git a/native/src/svg.rs b/core/src/svg.rs
index 9b98877a..9b98877a 100644
--- a/native/src/svg.rs
+++ b/core/src/svg.rs
diff --git a/native/src/text.rs b/core/src/text.rs
index 4c72abc3..4c72abc3 100644
--- a/native/src/text.rs
+++ b/core/src/text.rs
diff --git a/native/src/touch.rs b/core/src/touch.rs
index 18120644..18120644 100644
--- a/native/src/touch.rs
+++ b/core/src/touch.rs
diff --git a/core/src/widget.rs b/core/src/widget.rs
new file mode 100644
index 00000000..70e2c2d9
--- /dev/null
+++ b/core/src/widget.rs
@@ -0,0 +1,145 @@
+//! Create custom widgets and operate on them.
+pub mod operation;
+pub mod text;
+pub mod tree;
+
+mod id;
+
+pub use id::Id;
+pub use operation::Operation;
+pub use text::Text;
+pub use tree::Tree;
+
+use crate::event::{self, Event};
+use crate::layout::{self, Layout};
+use crate::mouse;
+use crate::overlay;
+use crate::renderer;
+use crate::{Clipboard, Length, Point, Rectangle, Shell};
+
+/// A component that displays information and allows interaction.
+///
+/// If you want to build your own widgets, you will need to implement this
+/// trait.
+///
+/// # Examples
+/// The repository has some [examples] showcasing how to implement a custom
+/// widget:
+///
+/// - [`bezier_tool`], a Paint-like tool for drawing Bézier curves using
+/// [`lyon`].
+/// - [`custom_widget`], a demonstration of how to build a custom widget that
+/// draws a circle.
+/// - [`geometry`], a custom widget showcasing how to draw geometry with the
+/// `Mesh2D` primitive in [`iced_wgpu`].
+///
+/// [examples]: https://github.com/iced-rs/iced/tree/0.8/examples
+/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.8/examples/bezier_tool
+/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.8/examples/custom_widget
+/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.8/examples/geometry
+/// [`lyon`]: https://github.com/nical/lyon
+/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.8/wgpu
+pub trait Widget<Message, Renderer>
+where
+ Renderer: crate::Renderer,
+{
+ /// Returns the width of the [`Widget`].
+ fn width(&self) -> Length;
+
+ /// Returns the height of the [`Widget`].
+ fn height(&self) -> Length;
+
+ /// Returns the [`layout::Node`] of the [`Widget`].
+ ///
+ /// This [`layout::Node`] is used by the runtime to compute the [`Layout`] of the
+ /// user interface.
+ fn layout(
+ &self,
+ renderer: &Renderer,
+ limits: &layout::Limits,
+ ) -> layout::Node;
+
+ /// Draws the [`Widget`] using the associated `Renderer`.
+ fn draw(
+ &self,
+ state: &Tree,
+ renderer: &mut Renderer,
+ theme: &Renderer::Theme,
+ style: &renderer::Style,
+ layout: Layout<'_>,
+ cursor_position: Point,
+ viewport: &Rectangle,
+ );
+
+ /// Returns the [`Tag`] of the [`Widget`].
+ ///
+ /// [`Tag`]: tree::Tag
+ fn tag(&self) -> tree::Tag {
+ tree::Tag::stateless()
+ }
+
+ /// Returns the [`State`] of the [`Widget`].
+ ///
+ /// [`State`]: tree::State
+ fn state(&self) -> tree::State {
+ tree::State::None
+ }
+
+ /// Returns the state [`Tree`] of the children of the [`Widget`].
+ fn children(&self) -> Vec<Tree> {
+ Vec::new()
+ }
+
+ /// Reconciliates the [`Widget`] with the provided [`Tree`].
+ fn diff(&self, _tree: &mut Tree) {}
+
+ /// Applies an [`Operation`] to the [`Widget`].
+ fn operate(
+ &self,
+ _state: &mut Tree,
+ _layout: Layout<'_>,
+ _renderer: &Renderer,
+ _operation: &mut dyn Operation<Message>,
+ ) {
+ }
+
+ /// Processes a runtime [`Event`].
+ ///
+ /// By default, it does nothing.
+ fn on_event(
+ &mut self,
+ _state: &mut Tree,
+ _event: Event,
+ _layout: Layout<'_>,
+ _cursor_position: Point,
+ _renderer: &Renderer,
+ _clipboard: &mut dyn Clipboard,
+ _shell: &mut Shell<'_, Message>,
+ ) -> event::Status {
+ event::Status::Ignored
+ }
+
+ /// Returns the current [`mouse::Interaction`] of the [`Widget`].
+ ///
+ /// By default, it returns [`mouse::Interaction::Idle`].
+ fn mouse_interaction(
+ &self,
+ _state: &Tree,
+ _layout: Layout<'_>,
+ _cursor_position: Point,
+ _viewport: &Rectangle,
+ _renderer: &Renderer,
+ ) -> mouse::Interaction {
+ mouse::Interaction::Idle
+ }
+
+ /// Returns the overlay of the [`Widget`], if there is any.
+ fn overlay<'a>(
+ &'a mut self,
+ _state: &'a mut Tree,
+ _layout: Layout<'_>,
+ _renderer: &Renderer,
+ ) -> Option<overlay::Element<'a, Message, Renderer>> {
+ None
+ }
+}
diff --git a/native/src/widget/id.rs b/core/src/widget/id.rs
index 4b8fedf1..ae739bb7 100644
--- a/native/src/widget/id.rs
+++ b/core/src/widget/id.rs
@@ -24,7 +24,7 @@ impl Id {
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
-pub enum Internal {
+enum Internal {
Unique(usize),
Custom(borrow::Cow<'static, str>),
}
diff --git a/native/src/widget/operation.rs b/core/src/widget/operation.rs
index 53688a21..53688a21 100644
--- a/native/src/widget/operation.rs
+++ b/core/src/widget/operation.rs
diff --git a/native/src/widget/operation/focusable.rs b/core/src/widget/operation/focusable.rs
index 312e4894..312e4894 100644
--- a/native/src/widget/operation/focusable.rs
+++ b/core/src/widget/operation/focusable.rs
diff --git a/native/src/widget/operation/scrollable.rs b/core/src/widget/operation/scrollable.rs
index 3b20631f..3b20631f 100644
--- a/native/src/widget/operation/scrollable.rs
+++ b/core/src/widget/operation/scrollable.rs
diff --git a/native/src/widget/operation/text_input.rs b/core/src/widget/operation/text_input.rs
index 4c773e99..4c773e99 100644
--- a/native/src/widget/operation/text_input.rs
+++ b/core/src/widget/operation/text_input.rs
diff --git a/native/src/widget/text.rs b/core/src/widget/text.rs
index aede754a..485bb542 100644
--- a/native/src/widget/text.rs
+++ b/core/src/widget/text.rs
@@ -4,27 +4,13 @@ use crate::layout;
use crate::renderer;
use crate::text;
use crate::widget::Tree;
-use crate::{Element, Layout, Length, Pixels, Point, Rectangle, Size, Widget};
+use crate::{
+ Color, Element, Layout, Length, Pixels, Point, Rectangle, Size, Widget,
+};
use std::borrow::Cow;
-pub use iced_style::text::{Appearance, StyleSheet};
-
/// A paragraph of text.
-///
-/// # Example
-///
-/// ```
-/// # use iced_native::Color;
-/// #
-/// # type Text<'a> = iced_native::widget::Text<'a, iced_native::renderer::Null>;
-/// #
-/// Text::new("I <3 iced!")
-/// .size(40)
-/// .style(Color::from([0.0, 0.0, 1.0]));
-/// ```
-///
-/// ![Text drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/text.png?raw=true)
#[allow(missing_debug_implementations)]
pub struct Text<'a, Renderer>
where
@@ -211,7 +197,7 @@ pub fn draw<Renderer>(
alignment::Vertical::Bottom => bounds.y + bounds.height,
};
- renderer.fill_text(crate::text::Text {
+ renderer.fill_text(crate::Text {
content,
size: size.unwrap_or_else(|| renderer.default_size()),
bounds: Rectangle { x, y, ..bounds },
@@ -252,12 +238,40 @@ where
}
}
+impl<'a, Renderer> From<&'a str> for Text<'a, Renderer>
+where
+ Renderer: text::Renderer,
+ Renderer::Theme: StyleSheet,
+{
+ fn from(content: &'a str) -> Self {
+ Self::new(content)
+ }
+}
+
impl<'a, Message, Renderer> From<&'a str> for Element<'a, Message, Renderer>
where
Renderer: text::Renderer + 'a,
Renderer::Theme: StyleSheet,
{
- fn from(contents: &'a str) -> Self {
- Text::new(contents).into()
+ fn from(content: &'a str) -> Self {
+ Text::from(content).into()
}
}
+
+/// The style sheet of some text.
+pub trait StyleSheet {
+ /// The supported style of the [`StyleSheet`].
+ type Style: Default + Copy;
+
+ /// Produces the [`Appearance`] of some text.
+ fn appearance(&self, style: Self::Style) -> Appearance;
+}
+
+/// The apperance of some text.
+#[derive(Debug, Clone, Copy, Default)]
+pub struct Appearance {
+ /// The [`Color`] of the text.
+ ///
+ /// The default, `None`, means using the inherited color.
+ pub color: Option<Color>,
+}
diff --git a/native/src/widget/tree.rs b/core/src/widget/tree.rs
index 0af40c33..0af40c33 100644
--- a/native/src/widget/tree.rs
+++ b/core/src/widget/tree.rs
diff --git a/core/src/window.rs b/core/src/window.rs
new file mode 100644
index 00000000..d829a4b4
--- /dev/null
+++ b/core/src/window.rs
@@ -0,0 +1,10 @@
+//! Build window-based GUI applications.
+mod event;
+mod mode;
+mod redraw_request;
+mod user_attention;
+
+pub use event::Event;
+pub use mode::Mode;
+pub use redraw_request::RedrawRequest;
+pub use user_attention::UserAttention;
diff --git a/native/src/window/event.rs b/core/src/window/event.rs
index e2fb5e66..e2fb5e66 100644
--- a/native/src/window/event.rs
+++ b/core/src/window/event.rs
diff --git a/native/src/window/mode.rs b/core/src/window/mode.rs
index fdce8e23..fdce8e23 100644
--- a/native/src/window/mode.rs
+++ b/core/src/window/mode.rs
diff --git a/native/src/window/redraw_request.rs b/core/src/window/redraw_request.rs
index 3b4f0fd3..3b4f0fd3 100644
--- a/native/src/window/redraw_request.rs
+++ b/core/src/window/redraw_request.rs
diff --git a/native/src/window/user_attention.rs b/core/src/window/user_attention.rs
index b03dfeef..b03dfeef 100644
--- a/native/src/window/user_attention.rs
+++ b/core/src/window/user_attention.rs
diff --git a/examples/component/Cargo.toml b/examples/component/Cargo.toml
index dd435201..9db1e6b4 100644
--- a/examples/component/Cargo.toml
+++ b/examples/component/Cargo.toml
@@ -6,6 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../..", features = ["debug"] }
-iced_native = { path = "../../native" }
-iced_lazy = { path = "../../lazy" }
+iced = { path = "../..", features = ["debug", "lazy"] }
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index c407bb06..e59588b1 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -47,9 +47,8 @@ impl Sandbox for Component {
mod numeric_input {
use iced::alignment::{self, Alignment};
- use iced::widget::{self, button, row, text, text_input};
- use iced::{Element, Length};
- use iced_lazy::{self, Component};
+ use iced::widget::{button, component, row, text, text_input, Component};
+ use iced::{Element, Length, Renderer};
pub struct NumericInput<Message> {
value: Option<u32>,
@@ -82,13 +81,7 @@ mod numeric_input {
}
}
- impl<Message, Renderer> Component<Message, Renderer> for NumericInput<Message>
- where
- Renderer: iced_native::text::Renderer + 'static,
- Renderer::Theme: widget::button::StyleSheet
- + widget::text_input::StyleSheet
- + widget::text::StyleSheet,
- {
+ impl<Message> Component<Message, Renderer> for NumericInput<Message> {
type State = ();
type Event = Event;
@@ -151,17 +144,12 @@ mod numeric_input {
}
}
- impl<'a, Message, Renderer> From<NumericInput<Message>>
- for Element<'a, Message, Renderer>
+ impl<'a, Message> From<NumericInput<Message>> for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'static + iced_native::text::Renderer,
- Renderer::Theme: widget::button::StyleSheet
- + widget::text_input::StyleSheet
- + widget::text::StyleSheet,
{
fn from(numeric_input: NumericInput<Message>) -> Self {
- iced_lazy::component(numeric_input)
+ component(numeric_input)
}
}
}
diff --git a/examples/custom_quad/Cargo.toml b/examples/custom_quad/Cargo.toml
index 39154786..f097c2dd 100644
--- a/examples/custom_quad/Cargo.toml
+++ b/examples/custom_quad/Cargo.toml
@@ -6,5 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../.." }
-iced_native = { path = "../../native" }
+iced = { path = "../..", features = ["advanced"] }
diff --git a/examples/custom_quad/src/main.rs b/examples/custom_quad/src/main.rs
index 6509887c..b07f42ce 100644
--- a/examples/custom_quad/src/main.rs
+++ b/examples/custom_quad/src/main.rs
@@ -1,9 +1,9 @@
//! This example showcases a drawing a quad.
mod quad {
- use iced_native::layout::{self, Layout};
- use iced_native::renderer;
- use iced_native::widget::{self, Widget};
- use iced_native::{Color, Element, Length, Point, Rectangle, Size};
+ use iced::advanced::layout::{self, Layout};
+ use iced::advanced::renderer;
+ use iced::advanced::widget::{self, Widget};
+ use iced::{Color, Element, Length, Point, Rectangle, Size};
pub struct CustomQuad {
size: f32,
diff --git a/examples/custom_widget/Cargo.toml b/examples/custom_widget/Cargo.toml
index 067aab4a..dda0efe8 100644
--- a/examples/custom_widget/Cargo.toml
+++ b/examples/custom_widget/Cargo.toml
@@ -6,5 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../.." }
-iced_native = { path = "../../native" }
+iced = { path = "../..", features = ["advanced"] }
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index f6bb3b1e..7854548c 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -9,10 +9,10 @@ mod circle {
// Of course, you can choose to make the implementation renderer-agnostic,
// if you wish to, by creating your own `Renderer` trait, which could be
// implemented by `iced_wgpu` and other renderers.
- use iced_native::layout::{self, Layout};
- use iced_native::renderer;
- use iced_native::widget::{self, Widget};
- use iced_native::{Color, Element, Length, Point, Rectangle, Size};
+ use iced::advanced::layout::{self, Layout};
+ use iced::advanced::renderer;
+ use iced::advanced::widget::{self, Widget};
+ use iced::{Color, Element, Length, Point, Rectangle, Size};
pub struct Circle {
radius: f32,
diff --git a/examples/events/Cargo.toml b/examples/events/Cargo.toml
index 8c56e471..15ffc0af 100644
--- a/examples/events/Cargo.toml
+++ b/examples/events/Cargo.toml
@@ -7,4 +7,3 @@ publish = false
[dependencies]
iced = { path = "../..", features = ["debug"] }
-iced_native = { path = "../../native" }
diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs
index 1b97018e..7f3a5e1d 100644
--- a/examples/events/src/main.rs
+++ b/examples/events/src/main.rs
@@ -1,12 +1,13 @@
use iced::alignment;
use iced::executor;
+use iced::subscription;
use iced::widget::{button, checkbox, container, text, Column};
use iced::window;
+use iced::Event;
use iced::{
Alignment, Application, Command, Element, Length, Settings, Subscription,
Theme,
};
-use iced_native::Event;
pub fn main() -> iced::Result {
Events::run(Settings {
@@ -17,13 +18,13 @@ pub fn main() -> iced::Result {
#[derive(Debug, Default)]
struct Events {
- last: Vec<iced_native::Event>,
+ last: Vec<Event>,
enabled: bool,
}
#[derive(Debug, Clone)]
enum Message {
- EventOccurred(iced_native::Event),
+ EventOccurred(Event),
Toggled(bool),
Exit,
}
@@ -70,7 +71,7 @@ impl Application for Events {
}
fn subscription(&self) -> Subscription<Message> {
- iced_native::subscription::events().map(Message::EventOccurred)
+ subscription::events().map(Message::EventOccurred)
}
fn view(&self) -> Element<Message> {
diff --git a/examples/geometry/Cargo.toml b/examples/geometry/Cargo.toml
index 22ede0e0..79fe52d5 100644
--- a/examples/geometry/Cargo.toml
+++ b/examples/geometry/Cargo.toml
@@ -6,6 +6,5 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../.." }
-iced_native = { path = "../../native" }
+iced = { path = "../..", features = ["advanced"] }
iced_graphics = { path = "../../graphics" }
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index a77772d5..5cb41184 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -1,23 +1,13 @@
//! This example showcases a simple native custom widget that renders using
//! arbitrary low-level geometry.
mod rainbow {
- // For now, to implement a custom native widget you will need to add
- // `iced_native` and `iced_wgpu` to your dependencies.
- //
- // Then, you simply need to define your widget type and implement the
- // `iced_native::Widget` trait with the `iced_wgpu::Renderer`.
- //
- // Of course, you can choose to make the implementation renderer-agnostic,
- // if you wish to, by creating your own `Renderer` trait, which could be
- // implemented by `iced_wgpu` and other renderers.
use iced_graphics::primitive::{ColoredVertex2D, Primitive};
- use iced_graphics::renderer::{self, Renderer};
- use iced_graphics::Backend;
- use iced_native::layout;
- use iced_native::widget::{self, Widget};
- use iced_native::{
- Element, Layout, Length, Point, Rectangle, Size, Vector,
+ use iced::advanced::layout::{self, Layout};
+ use iced::advanced::renderer;
+ use iced::advanced::widget::{self, Widget};
+ use iced::{
+ Element, Length, Point, Rectangle, Renderer, Size, Theme, Vector,
};
#[derive(Debug, Clone, Copy, Default)]
@@ -27,10 +17,7 @@ mod rainbow {
Rainbow
}
- impl<Message, B, T> Widget<Message, Renderer<B, T>> for Rainbow
- where
- B: Backend,
- {
+ impl<Message> Widget<Message, Renderer> for Rainbow {
fn width(&self) -> Length {
Length::Fill
}
@@ -41,7 +28,7 @@ mod rainbow {
fn layout(
&self,
- _renderer: &Renderer<B, T>,
+ _renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
let size = limits.width(Length::Fill).resolve(Size::ZERO);
@@ -52,15 +39,15 @@ mod rainbow {
fn draw(
&self,
_tree: &widget::Tree,
- renderer: &mut Renderer<B, T>,
- _theme: &T,
+ renderer: &mut Renderer,
+ _theme: &Theme,
_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle,
) {
+ use iced::advanced::Renderer as _;
use iced_graphics::primitive::Mesh2D;
- use iced_native::Renderer as _;
let b = layout.bounds();
@@ -151,10 +138,7 @@ mod rainbow {
}
}
- impl<'a, Message, B, T> From<Rainbow> for Element<'a, Message, Renderer<B, T>>
- where
- B: Backend,
- {
+ impl<'a, Message> From<Rainbow> for Element<'a, Message, Renderer> {
fn from(rainbow: Rainbow) -> Self {
Self::new(rainbow)
}
diff --git a/examples/integration/Cargo.toml b/examples/integration/Cargo.toml
index 200306aa..60390242 100644
--- a/examples/integration/Cargo.toml
+++ b/examples/integration/Cargo.toml
@@ -8,6 +8,7 @@ publish = false
[dependencies]
iced_winit = { path = "../../winit" }
iced_wgpu = { path = "../../wgpu", features = ["webgl"] }
+iced_widget = { path = "../../widget" }
env_logger = "0.8"
[target.'cfg(target_arch = "wasm32")'.dependencies]
diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs
index 533cb6e2..16e21709 100644
--- a/examples/integration/src/controls.rs
+++ b/examples/integration/src/controls.rs
@@ -1,6 +1,8 @@
use iced_wgpu::Renderer;
-use iced_winit::widget::{slider, text_input, Column, Row, Text};
-use iced_winit::{Alignment, Color, Command, Element, Length, Program};
+use iced_widget::{slider, text_input, Column, Row, Text};
+use iced_winit::core::{Alignment, Color, Element, Length};
+use iced_winit::native::{Command, Program};
+use iced_winit::style::Theme;
pub struct Controls {
background_color: Color,
@@ -27,7 +29,7 @@ impl Controls {
}
impl Program for Controls {
- type Renderer = Renderer;
+ type Renderer = Renderer<Theme>;
type Message = Message;
fn update(&mut self, message: Message) -> Command<Message> {
@@ -43,7 +45,7 @@ impl Program for Controls {
Command::none()
}
- fn view(&self) -> Element<Message, Renderer> {
+ fn view(&self) -> Element<Message, Renderer<Theme>> {
let background_color = self.background_color;
let text = &self.text;
diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs
index a7a90ced..c1f1f076 100644
--- a/examples/integration/src/main.rs
+++ b/examples/integration/src/main.rs
@@ -4,11 +4,14 @@ mod scene;
use controls::Controls;
use scene::Scene;
-use iced_wgpu::{wgpu, Backend, Renderer, Settings, Viewport};
-use iced_winit::{
- conversion, futures, program, renderer, winit, Clipboard, Color, Debug,
- Size,
-};
+use iced_wgpu::graphics::Viewport;
+use iced_wgpu::{wgpu, Backend, Renderer, Settings};
+use iced_winit::core::renderer;
+use iced_winit::core::{Color, Size};
+use iced_winit::native::program;
+use iced_winit::native::Debug;
+use iced_winit::style::Theme;
+use iced_winit::{conversion, futures, winit, Clipboard};
use winit::{
dpi::PhysicalPosition,
@@ -73,43 +76,45 @@ pub fn main() {
let instance = wgpu::Instance::new(backend);
let surface = unsafe { instance.create_surface(&window) };
- let (format, (device, queue)) = futures::executor::block_on(async {
- let adapter = wgpu::util::initialize_adapter_from_env_or_default(
- &instance,
- backend,
- Some(&surface),
- )
- .await
- .expect("No suitable GPU adapters found on the system!");
-
- let adapter_features = adapter.features();
-
- #[cfg(target_arch = "wasm32")]
- let needed_limits = wgpu::Limits::downlevel_webgl2_defaults()
- .using_resolution(adapter.limits());
-
- #[cfg(not(target_arch = "wasm32"))]
- let needed_limits = wgpu::Limits::default();
-
- (
- surface
- .get_supported_formats(&adapter)
- .first()
- .copied()
- .expect("Get preferred format"),
- adapter
- .request_device(
- &wgpu::DeviceDescriptor {
- label: None,
- features: adapter_features & wgpu::Features::default(),
- limits: needed_limits,
- },
- None,
- )
- .await
- .expect("Request device"),
- )
- });
+ let (format, (device, queue)) =
+ futures::futures::executor::block_on(async {
+ let adapter = wgpu::util::initialize_adapter_from_env_or_default(
+ &instance,
+ backend,
+ Some(&surface),
+ )
+ .await
+ .expect("No suitable GPU adapters found on the system!");
+
+ let adapter_features = adapter.features();
+
+ #[cfg(target_arch = "wasm32")]
+ let needed_limits = wgpu::Limits::downlevel_webgl2_defaults()
+ .using_resolution(adapter.limits());
+
+ #[cfg(not(target_arch = "wasm32"))]
+ let needed_limits = wgpu::Limits::default();
+
+ (
+ surface
+ .get_supported_formats(&adapter)
+ .first()
+ .copied()
+ .expect("Get preferred format"),
+ adapter
+ .request_device(
+ &wgpu::DeviceDescriptor {
+ label: None,
+ features: adapter_features
+ & wgpu::Features::default(),
+ limits: needed_limits,
+ },
+ None,
+ )
+ .await
+ .expect("Request device"),
+ )
+ });
surface.configure(
&device,
@@ -188,7 +193,7 @@ pub fn main() {
viewport.scale_factor(),
),
&mut renderer,
- &iced_wgpu::Theme::Dark,
+ &Theme::Dark,
&renderer::Style { text_color: Color::WHITE },
&mut clipboard,
&mut debug,
diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs
index 3e41fbda..90c7efbf 100644
--- a/examples/integration/src/scene.rs
+++ b/examples/integration/src/scene.rs
@@ -1,5 +1,5 @@
use iced_wgpu::wgpu;
-use iced_winit::Color;
+use iced_winit::core::Color;
pub struct Scene {
pipeline: wgpu::RenderPipeline,
diff --git a/examples/lazy/Cargo.toml b/examples/lazy/Cargo.toml
index 79255c25..e03e89a9 100644
--- a/examples/lazy/Cargo.toml
+++ b/examples/lazy/Cargo.toml
@@ -6,5 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../..", features = ["debug"] }
-iced_lazy = { path = "../../lazy" }
+iced = { path = "../..", features = ["debug", "lazy"] }
diff --git a/examples/lazy/src/main.rs b/examples/lazy/src/main.rs
index 6512106f..e1cdaefe 100644
--- a/examples/lazy/src/main.rs
+++ b/examples/lazy/src/main.rs
@@ -1,10 +1,9 @@
use iced::theme;
use iced::widget::{
- button, column, horizontal_space, pick_list, row, scrollable, text,
+ button, column, horizontal_space, lazy, pick_list, row, scrollable, text,
text_input,
};
use iced::{Element, Length, Sandbox, Settings};
-use iced_lazy::lazy;
use std::collections::HashSet;
use std::hash::Hash;
diff --git a/examples/modal/Cargo.toml b/examples/modal/Cargo.toml
index 8770acac..3ac61e6a 100644
--- a/examples/modal/Cargo.toml
+++ b/examples/modal/Cargo.toml
@@ -6,5 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../..", features = [] }
-iced_native = { path = "../../native" }
+iced = { path = "../..", features = ["advanced"] }
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs
index 54555684..214ec97e 100644
--- a/examples/modal/src/main.rs
+++ b/examples/modal/src/main.rs
@@ -178,12 +178,15 @@ impl App {
}
mod modal {
- use iced_native::alignment::Alignment;
- use iced_native::widget::{self, Tree};
- use iced_native::{
- event, layout, mouse, overlay, renderer, Clipboard, Color, Element,
- Event, Layout, Length, Point, Rectangle, Shell, Size, Widget,
- };
+ use iced::advanced::layout::{self, Layout};
+ use iced::advanced::overlay;
+ use iced::advanced::renderer;
+ use iced::advanced::widget::{self, Widget};
+ use iced::advanced::{self, Clipboard, Shell};
+ use iced::alignment::Alignment;
+ use iced::event;
+ use iced::mouse;
+ use iced::{Color, Element, Event, Length, Point, Rectangle, Size};
/// A widget that centers a modal element over some base element
pub struct Modal<'a, Message, Renderer> {
@@ -218,14 +221,17 @@ mod modal {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Modal<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: advanced::Renderer,
Message: Clone,
{
- fn children(&self) -> Vec<Tree> {
- vec![Tree::new(&self.base), Tree::new(&self.modal)]
+ fn children(&self) -> Vec<widget::Tree> {
+ vec![
+ widget::Tree::new(&self.base),
+ widget::Tree::new(&self.modal),
+ ]
}
- fn diff(&self, tree: &mut Tree) {
+ fn diff(&self, tree: &mut widget::Tree) {
tree.diff_children(&[&self.base, &self.modal]);
}
@@ -247,7 +253,7 @@ mod modal {
fn on_event(
&mut self,
- state: &mut Tree,
+ state: &mut widget::Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
@@ -268,9 +274,9 @@ mod modal {
fn draw(
&self,
- state: &Tree,
+ state: &widget::Tree,
renderer: &mut Renderer,
- theme: &<Renderer as iced_native::Renderer>::Theme,
+ theme: &<Renderer as advanced::Renderer>::Theme,
style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
@@ -289,7 +295,7 @@ mod modal {
fn overlay<'b>(
&'b mut self,
- state: &'b mut Tree,
+ state: &'b mut widget::Tree,
layout: Layout<'_>,
_renderer: &Renderer,
) -> Option<overlay::Element<'b, Message, Renderer>> {
@@ -306,7 +312,7 @@ mod modal {
fn mouse_interaction(
&self,
- state: &Tree,
+ state: &widget::Tree,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
@@ -323,7 +329,7 @@ mod modal {
fn operate(
&self,
- state: &mut Tree,
+ state: &mut widget::Tree,
layout: Layout<'_>,
renderer: &Renderer,
operation: &mut dyn widget::Operation<Message>,
@@ -339,7 +345,7 @@ mod modal {
struct Overlay<'a, 'b, Message, Renderer> {
content: &'b mut Element<'a, Message, Renderer>,
- tree: &'b mut Tree,
+ tree: &'b mut widget::Tree,
size: Size,
on_blur: Option<Message>,
}
@@ -347,7 +353,7 @@ mod modal {
impl<'a, 'b, Message, Renderer> overlay::Overlay<Message, Renderer>
for Overlay<'a, 'b, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: advanced::Renderer,
Message: Clone,
{
fn layout(
@@ -469,7 +475,7 @@ mod modal {
impl<'a, Message, Renderer> From<Modal<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
- Renderer: 'a + iced_native::Renderer,
+ Renderer: 'a + advanced::Renderer,
Message: 'a + Clone,
{
fn from(modal: Modal<'a, Message, Renderer>) -> Self {
diff --git a/examples/pane_grid/Cargo.toml b/examples/pane_grid/Cargo.toml
index dfd6dfa9..4c0bf072 100644
--- a/examples/pane_grid/Cargo.toml
+++ b/examples/pane_grid/Cargo.toml
@@ -6,6 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../..", features = ["debug"] }
-iced_native = { path = "../../native" }
-iced_lazy = { path = "../../lazy" }
+iced = { path = "../..", features = ["debug", "lazy"] }
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index c9f1376c..dfb80853 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -1,14 +1,16 @@
use iced::alignment::{self, Alignment};
+use iced::event::{self, Event};
use iced::executor;
use iced::keyboard;
+use iced::subscription;
use iced::theme::{self, Theme};
use iced::widget::pane_grid::{self, PaneGrid};
-use iced::widget::{button, column, container, row, scrollable, text};
+use iced::widget::{
+ button, column, container, responsive, row, scrollable, text,
+};
use iced::{
Application, Color, Command, Element, Length, Settings, Size, Subscription,
};
-use iced_lazy::responsive;
-use iced_native::{event, subscription, Event};
pub fn main() -> iced::Result {
Example::run(Settings::default())
diff --git a/examples/toast/Cargo.toml b/examples/toast/Cargo.toml
index f1f986aa..f703572c 100644
--- a/examples/toast/Cargo.toml
+++ b/examples/toast/Cargo.toml
@@ -6,5 +6,4 @@ edition = "2021"
publish = false
[dependencies]
-iced = { path = "../..", features = [] }
-iced_native = { path = "../../native" }
+iced = { path = "../..", features = ["advanced"] }
diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs
index e74b3ee6..78fb9de1 100644
--- a/examples/toast/src/main.rs
+++ b/examples/toast/src/main.rs
@@ -176,17 +176,23 @@ mod toast {
use std::fmt;
use std::time::{Duration, Instant};
+ use iced::advanced;
+ use iced::advanced::layout::{self, Layout};
+ use iced::advanced::overlay;
+ use iced::advanced::renderer;
+ use iced::advanced::widget::{self, Operation, Tree};
+ use iced::advanced::{Clipboard, Shell, Widget};
+ use iced::event::{self, Event};
+ use iced::mouse;
use iced::theme;
use iced::widget::{
button, column, container, horizontal_rule, horizontal_space, row, text,
};
+ use iced::window;
use iced::{
Alignment, Element, Length, Point, Rectangle, Renderer, Size, Theme,
Vector,
};
- use iced_native::widget::{tree, Operation, Tree};
- use iced_native::{event, layout, mouse, overlay, renderer, window};
- use iced_native::{Clipboard, Event, Layout, Shell, Widget};
pub const DEFAULT_TIMEOUT: u64 = 5;
@@ -324,13 +330,13 @@ mod toast {
self.content.as_widget().layout(renderer, limits)
}
- fn tag(&self) -> tree::Tag {
+ fn tag(&self) -> widget::tree::Tag {
struct Marker(Vec<Instant>);
- iced_native::widget::tree::Tag::of::<Marker>()
+ widget::tree::Tag::of::<Marker>()
}
- fn state(&self) -> tree::State {
- iced_native::widget::tree::State::new(Vec::<Option<Instant>>::new())
+ fn state(&self) -> widget::tree::State {
+ widget::tree::State::new(Vec::<Option<Instant>>::new())
}
fn children(&self) -> Vec<Tree> {
@@ -584,7 +590,7 @@ mod toast {
fn draw(
&self,
renderer: &mut Renderer,
- theme: &<Renderer as iced_native::Renderer>::Theme,
+ theme: &<Renderer as advanced::Renderer>::Theme,
style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
@@ -613,7 +619,7 @@ mod toast {
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn iced_native::widget::Operation<Message>,
+ operation: &mut dyn widget::Operation<Message>,
) {
operation.container(None, &mut |operation| {
self.toasts
diff --git a/examples/url_handler/Cargo.toml b/examples/url_handler/Cargo.toml
index 63c7ec27..4dcff92d 100644
--- a/examples/url_handler/Cargo.toml
+++ b/examples/url_handler/Cargo.toml
@@ -7,4 +7,3 @@ publish = false
[dependencies]
iced = { path = "../.." }
-iced_native = { path = "../../native" }
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs
index 3257b519..f63fa06a 100644
--- a/examples/url_handler/src/main.rs
+++ b/examples/url_handler/src/main.rs
@@ -1,12 +1,10 @@
+use iced::event::{Event, MacOS, PlatformSpecific};
use iced::executor;
+use iced::subscription;
use iced::widget::{container, text};
use iced::{
Application, Command, Element, Length, Settings, Subscription, Theme,
};
-use iced_native::{
- event::{MacOS, PlatformSpecific},
- Event,
-};
pub fn main() -> iced::Result {
App::run(Settings::default())
@@ -19,7 +17,7 @@ struct App {
#[derive(Debug, Clone)]
enum Message {
- EventOccurred(iced_native::Event),
+ EventOccurred(Event),
}
impl Application for App {
@@ -52,7 +50,7 @@ impl Application for App {
}
fn subscription(&self) -> Subscription<Message> {
- iced_native::subscription::events().map(Message::EventOccurred)
+ subscription::events().map(Message::EventOccurred)
}
fn view(&self) -> Element<Message> {
diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml
index 98e6f474..4bb22b6c 100644
--- a/graphics/Cargo.toml
+++ b/graphics/Cargo.toml
@@ -39,13 +39,9 @@ bitflags = "1.2"
version = "1.4"
features = ["derive"]
-[dependencies.iced_native]
-version = "0.9"
-path = "../native"
-
-[dependencies.iced_style]
-version = "0.7"
-path = "../style"
+[dependencies.iced_core]
+version = "0.8"
+path = "../core"
[dependencies.tiny-skia]
version = "0.8"
diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs
index 8658cffe..dd2888ab 100644
--- a/graphics/src/backend.rs
+++ b/graphics/src/backend.rs
@@ -1,8 +1,8 @@
//! Write a graphics backend.
-use iced_native::image;
-use iced_native::svg;
-use iced_native::text;
-use iced_native::{Font, Point, Size};
+use iced_core::image;
+use iced_core::svg;
+use iced_core::text;
+use iced_core::{Font, Point, Size};
use std::borrow::Cow;
diff --git a/graphics/src/window/compositor.rs b/graphics/src/compositor.rs
index 15f8dab5..d55e801a 100644
--- a/graphics/src/window/compositor.rs
+++ b/graphics/src/compositor.rs
@@ -1,6 +1,8 @@
//! A compositor is responsible for initializing a renderer and managing window
//! surfaces.
-use crate::{Color, Error, Viewport};
+use crate::{Error, Viewport};
+
+use iced_core::Color;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use thiserror::Error;
@@ -11,7 +13,7 @@ pub trait Compositor: Sized {
type Settings: Default;
/// The iced renderer of the backend.
- type Renderer: iced_native::Renderer;
+ type Renderer: iced_core::Renderer;
/// The surface of the backend.
type Surface;
diff --git a/graphics/src/geometry.rs b/graphics/src/geometry.rs
index 29ac84d6..8db1594a 100644
--- a/graphics/src/geometry.rs
+++ b/graphics/src/geometry.rs
@@ -16,7 +16,7 @@ pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
pub use style::Style;
pub use text::Text;
-pub use iced_native::gradient::{self, Gradient};
+pub use iced_core::gradient::{self, Gradient};
use crate::Primitive;
@@ -29,7 +29,7 @@ impl From<Geometry> for Primitive {
}
}
-pub trait Renderer: iced_native::Renderer {
+pub trait Renderer: iced_core::Renderer {
type Geometry;
fn draw(&mut self, geometry: Vec<Self::Geometry>);
diff --git a/graphics/src/geometry/fill.rs b/graphics/src/geometry/fill.rs
index 109d5e99..2e8c1669 100644
--- a/graphics/src/geometry/fill.rs
+++ b/graphics/src/geometry/fill.rs
@@ -1,5 +1,5 @@
//! Fill [crate::widget::canvas::Geometry] with a certain style.
-use crate::{Color, Gradient};
+use iced_core::{Color, Gradient};
pub use crate::geometry::Style;
diff --git a/graphics/src/geometry/path.rs b/graphics/src/geometry/path.rs
index 30c387c5..c3127bdf 100644
--- a/graphics/src/geometry/path.rs
+++ b/graphics/src/geometry/path.rs
@@ -9,7 +9,7 @@ pub use builder::Builder;
pub use lyon_path;
-use crate::{Point, Size};
+use iced_core::{Point, Size};
/// An immutable set of points that may or may not be connected.
///
diff --git a/graphics/src/geometry/path/arc.rs b/graphics/src/geometry/path/arc.rs
index e0747d3e..2cdebb66 100644
--- a/graphics/src/geometry/path/arc.rs
+++ b/graphics/src/geometry/path/arc.rs
@@ -1,5 +1,5 @@
//! Build and draw curves.
-use crate::{Point, Vector};
+use iced_core::{Point, Vector};
/// A segment of a differentiable curve.
#[derive(Debug, Clone, Copy)]
diff --git a/graphics/src/geometry/path/builder.rs b/graphics/src/geometry/path/builder.rs
index 4a9c5e36..794dd3bc 100644
--- a/graphics/src/geometry/path/builder.rs
+++ b/graphics/src/geometry/path/builder.rs
@@ -1,5 +1,6 @@
use crate::geometry::path::{arc, Arc, Path};
-use crate::{Point, Size};
+
+use iced_core::{Point, Size};
use lyon_path::builder::{self, SvgPathBuilder};
use lyon_path::geom;
diff --git a/graphics/src/geometry/stroke.rs b/graphics/src/geometry/stroke.rs
index b551a9c9..2d760a6c 100644
--- a/graphics/src/geometry/stroke.rs
+++ b/graphics/src/geometry/stroke.rs
@@ -1,7 +1,7 @@
//! Create lines from a [crate::widget::canvas::Path] and assigns them various attributes/styles.
pub use crate::geometry::Style;
-use crate::Color;
+use iced_core::Color;
/// The style of a stroke.
#[derive(Debug, Clone)]
diff --git a/graphics/src/geometry/style.rs b/graphics/src/geometry/style.rs
index 6794f2e7..be9ee376 100644
--- a/graphics/src/geometry/style.rs
+++ b/graphics/src/geometry/style.rs
@@ -1,4 +1,4 @@
-use crate::{Color, Gradient};
+use iced_core::{Color, Gradient};
/// The coloring style of some drawing.
#[derive(Debug, Clone, PartialEq)]
diff --git a/graphics/src/geometry/text.rs b/graphics/src/geometry/text.rs
index 8c0b2dfb..06e0b4d0 100644
--- a/graphics/src/geometry/text.rs
+++ b/graphics/src/geometry/text.rs
@@ -1,5 +1,5 @@
-use crate::alignment;
-use crate::{Color, Font, Point};
+use iced_core::alignment;
+use iced_core::{Color, Font, Point};
/// A bunch of text that can be drawn to a canvas
#[derive(Debug, Clone)]
diff --git a/graphics/src/image/raster.rs b/graphics/src/image/raster.rs
index da46c30f..03211160 100644
--- a/graphics/src/image/raster.rs
+++ b/graphics/src/image/raster.rs
@@ -1,8 +1,8 @@
//! Raster image loading and caching.
use crate::image::Storage;
-use crate::Size;
-use iced_native::image;
+use iced_core::image;
+use iced_core::Size;
use bitflags::bitflags;
use std::collections::{HashMap, HashSet};
diff --git a/graphics/src/image/storage.rs b/graphics/src/image/storage.rs
index 1b5b5c35..4caa6141 100644
--- a/graphics/src/image/storage.rs
+++ b/graphics/src/image/storage.rs
@@ -1,5 +1,5 @@
//! Store images.
-use crate::Size;
+use iced_core::Size;
use std::fmt::Debug;
diff --git a/graphics/src/image/vector.rs b/graphics/src/image/vector.rs
index c950ccd6..32729acd 100644
--- a/graphics/src/image/vector.rs
+++ b/graphics/src/image/vector.rs
@@ -1,9 +1,8 @@
//! Vector image loading and caching
use crate::image::Storage;
-use crate::Color;
-use iced_native::svg;
-use iced_native::Size;
+use iced_core::svg;
+use iced_core::{Color, Size};
use resvg::tiny_skia;
use resvg::usvg;
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index e56f8ad8..c6f9cf57 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -27,17 +27,17 @@ mod transformation;
mod viewport;
pub mod backend;
+pub mod compositor;
pub mod image;
-pub mod overlay;
pub mod primitive;
pub mod renderer;
-pub mod window;
#[cfg(feature = "geometry")]
pub mod geometry;
pub use antialiasing::Antialiasing;
pub use backend::Backend;
+pub use compositor::Compositor;
pub use error::Error;
pub use primitive::Primitive;
pub use renderer::Renderer;
@@ -47,9 +47,4 @@ pub use viewport::Viewport;
#[cfg(feature = "geometry")]
pub use geometry::Geometry;
-pub use iced_native::alignment;
-pub use iced_native::text;
-pub use iced_native::{
- Alignment, Background, Color, Font, Gradient, Point, Rectangle, Size,
- Vector,
-};
+pub use iced_core as core;
diff --git a/graphics/src/overlay.rs b/graphics/src/overlay.rs
deleted file mode 100644
index bc0ed744..00000000
--- a/graphics/src/overlay.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-//! Display interactive elements on top of other widgets.
-pub mod menu;
diff --git a/graphics/src/overlay/menu.rs b/graphics/src/overlay/menu.rs
deleted file mode 100644
index 8b489e5e..00000000
--- a/graphics/src/overlay/menu.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-//! Build and show dropdown menus.
-
-pub use iced_style::menu::{Appearance, StyleSheet};
diff --git a/graphics/src/primitive.rs b/graphics/src/primitive.rs
index f900b3fd..195b62da 100644
--- a/graphics/src/primitive.rs
+++ b/graphics/src/primitive.rs
@@ -1,8 +1,7 @@
-use crate::alignment;
-
-use iced_native::image;
-use iced_native::svg;
-use iced_native::{Background, Color, Font, Gradient, Rectangle, Size, Vector};
+use iced_core::alignment;
+use iced_core::image;
+use iced_core::svg;
+use iced_core::{Background, Color, Font, Gradient, Rectangle, Size, Vector};
use bytemuck::{Pod, Zeroable};
use std::sync::Arc;
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index cb57f429..7bc462ef 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -1,15 +1,15 @@
//! Create a renderer from a [`Backend`].
use crate::backend::{self, Backend};
-use crate::{Primitive, Vector};
+use crate::Primitive;
-use iced_native::image;
-use iced_native::layout;
-use iced_native::renderer;
-use iced_native::svg;
-use iced_native::text::{self, Text};
-use iced_native::{Background, Color, Element, Font, Point, Rectangle, Size};
-
-pub use iced_native::renderer::Style;
+use iced_core::image;
+use iced_core::layout;
+use iced_core::renderer;
+use iced_core::svg;
+use iced_core::text::{self, Text};
+use iced_core::{
+ Background, Color, Element, Font, Point, Rectangle, Size, Vector,
+};
use std::borrow::Cow;
use std::marker::PhantomData;
@@ -52,7 +52,7 @@ impl<B: Backend, T> Renderer<B, T> {
}
}
-impl<B, T> iced_native::Renderer for Renderer<B, T>
+impl<B, T> iced_core::Renderer for Renderer<B, T>
where
B: Backend,
{
diff --git a/graphics/src/viewport.rs b/graphics/src/viewport.rs
index 2c0b541a..5792555d 100644
--- a/graphics/src/viewport.rs
+++ b/graphics/src/viewport.rs
@@ -1,4 +1,6 @@
-use crate::{Size, Transformation};
+use crate::Transformation;
+
+use iced_core::Size;
/// A viewing region for displaying computer graphics.
#[derive(Debug, Clone)]
diff --git a/graphics/src/window.rs b/graphics/src/window.rs
deleted file mode 100644
index a38b81f3..00000000
--- a/graphics/src/window.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//! Draw graphics to window surfaces.
-pub mod compositor;
-
-#[cfg(feature = "opengl")]
-pub mod gl_compositor;
-
-pub use compositor::Compositor;
-
-#[cfg(feature = "opengl")]
-pub use gl_compositor::GLCompositor;
diff --git a/graphics/src/window/gl_compositor.rs b/graphics/src/window/gl_compositor.rs
deleted file mode 100644
index 3e6dfd9e..00000000
--- a/graphics/src/window/gl_compositor.rs
+++ /dev/null
@@ -1,71 +0,0 @@
-//! A compositor is responsible for initializing a renderer and managing window
-//! surfaces.
-use crate::window::compositor::Information;
-use crate::{Color, Error, Size, Viewport};
-
-use core::ffi::c_void;
-
-/// A basic OpenGL compositor.
-///
-/// A compositor is responsible for initializing a renderer and managing window
-/// surfaces.
-///
-/// For now, this compositor only deals with a single global surface
-/// for drawing. However, the trait will most likely change in the near future
-/// to handle multiple surfaces at once.
-///
-/// If you implement an OpenGL renderer, you can implement this trait to ease
-/// integration with existing windowing shells, like `iced_glutin`.
-pub trait GLCompositor: Sized {
- /// The renderer of the [`GLCompositor`].
- ///
- /// This should point to your renderer type, which could be a type alias
- /// of the [`Renderer`] provided in this crate with with a specific
- /// [`Backend`].
- ///
- /// [`Renderer`]: crate::Renderer
- /// [`Backend`]: crate::Backend
- type Renderer: iced_native::Renderer;
-
- /// The settings of the [`GLCompositor`].
- ///
- /// It's up to you to decide the configuration supported by your renderer!
- type Settings: Default;
-
- /// Creates a new [`GLCompositor`] and [`Renderer`] with the given
- /// [`Settings`] and an OpenGL address loader function.
- ///
- /// # Safety
- /// The `loader_function` should resolve to valid OpenGL bindings.
- ///
- /// [`Renderer`]: crate::Renderer
- /// [`Backend`]: crate::Backend
- /// [`Settings`]: Self::Settings
- #[allow(unsafe_code)]
- unsafe fn new(
- settings: Self::Settings,
- loader_function: impl FnMut(&str) -> *const c_void,
- ) -> Result<(Self, Self::Renderer), Error>;
-
- /// Returns the amount of samples that should be used when configuring
- /// an OpenGL context for this [`GLCompositor`].
- fn sample_count(settings: &Self::Settings) -> u32;
-
- /// Resizes the viewport of the [`GLCompositor`].
- fn resize_viewport(&mut self, physical_size: Size<u32>);
-
- /// Returns [`Information`] used by this [`GLCompositor`].
- fn fetch_information(&self) -> Information;
-
- /// Presents the primitives of the [`Renderer`] to the next frame of the
- /// [`GLCompositor`].
- ///
- /// [`Renderer`]: crate::Renderer
- fn present<T: AsRef<str>>(
- &mut self,
- renderer: &mut Self::Renderer,
- viewport: &Viewport,
- background_color: Color,
- overlay: &[T],
- );
-}
diff --git a/lazy/Cargo.toml b/lazy/Cargo.toml
deleted file mode 100644
index c739b312..00000000
--- a/lazy/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-name = "iced_lazy"
-version = "0.5.0"
-authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
-edition = "2021"
-description = "Lazy widgets for Iced"
-license = "MIT"
-repository = "https://github.com/iced-rs/iced"
-documentation = "https://docs.rs/iced_lazy"
-keywords = ["gui", "ui", "graphics", "interface", "widgets"]
-categories = ["gui"]
-
-[dependencies]
-ouroboros = "0.13"
-
-[dependencies.iced_native]
-version = "0.9"
-path = "../native"
diff --git a/native/Cargo.toml b/native/Cargo.toml
index 1eedf0da..bc4e7ca1 100644
--- a/native/Cargo.toml
+++ b/native/Cargo.toml
@@ -11,9 +11,6 @@ repository = "https://github.com/iced-rs/iced"
debug = []
[dependencies]
-twox-hash = { version = "1.5", default-features = false }
-unicode-segmentation = "1.6"
-num-traits = "0.2"
thiserror = "1"
[dependencies.iced_core]
@@ -24,7 +21,3 @@ path = "../core"
version = "0.6"
path = "../futures"
features = ["thread-pool"]
-
-[dependencies.iced_style]
-version = "0.7"
-path = "../style"
diff --git a/native/src/clipboard.rs b/native/src/clipboard.rs
index c9105bc0..e727c4a7 100644
--- a/native/src/clipboard.rs
+++ b/native/src/clipboard.rs
@@ -3,28 +3,6 @@ use iced_futures::MaybeSend;
use std::fmt;
-/// A buffer for short-term storage and transfer within and between
-/// applications.
-pub trait Clipboard {
- /// Reads the current content of the [`Clipboard`] as text.
- fn read(&self) -> Option<String>;
-
- /// Writes the given text contents to the [`Clipboard`].
- fn write(&mut self, contents: String);
-}
-
-/// A null implementation of the [`Clipboard`] trait.
-#[derive(Debug, Clone, Copy)]
-pub struct Null;
-
-impl Clipboard for Null {
- fn read(&self) -> Option<String> {
- None
- }
-
- fn write(&mut self, _contents: String) {}
-}
-
/// A clipboard action to be performed by some [`Command`].
///
/// [`Command`]: crate::Command
diff --git a/native/src/command.rs b/native/src/command.rs
index ca9d0b64..39bee8f6 100644
--- a/native/src/command.rs
+++ b/native/src/command.rs
@@ -28,7 +28,9 @@ impl<T> Command<T> {
}
/// Creates a [`Command`] that performs a [`widget::Operation`].
- pub fn widget(operation: impl widget::Operation<T> + 'static) -> Self {
+ pub fn widget(
+ operation: impl iced_core::widget::Operation<T> + 'static,
+ ) -> Self {
Self(iced_futures::Command::single(Action::Widget(
widget::Action::new(operation),
)))
diff --git a/native/src/debug/basic.rs b/native/src/debug/basic.rs
index 92f614da..32f725a1 100644
--- a/native/src/debug/basic.rs
+++ b/native/src/debug/basic.rs
@@ -1,5 +1,5 @@
#![allow(missing_docs)]
-use crate::time;
+use crate::core::time;
use std::collections::VecDeque;
diff --git a/native/src/lib.rs b/native/src/lib.rs
index c98827e7..0fc4f324 100644
--- a/native/src/lib.rs
+++ b/native/src/lib.rs
@@ -42,32 +42,19 @@
clippy::useless_conversion
)]
#![forbid(unsafe_code, rust_2018_idioms)]
-#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub mod clipboard;
pub mod command;
-pub mod event;
pub mod font;
-pub mod image;
pub mod keyboard;
-pub mod layout;
-pub mod mouse;
-pub mod overlay;
pub mod program;
-pub mod renderer;
pub mod subscription;
-pub mod svg;
pub mod system;
-pub mod text;
-pub mod touch;
pub mod user_interface;
pub mod widget;
pub mod window;
-mod element;
-mod hasher;
mod runtime;
-mod shell;
// We disable debug capabilities on release builds unless the `debug` feature
// is explicitly enabled.
@@ -78,35 +65,13 @@ mod debug;
#[path = "debug/null.rs"]
mod debug;
-pub use iced_core::alignment;
-pub use iced_core::gradient;
-pub use iced_core::time;
-pub use iced_core::{
- color, Alignment, Background, Color, ContentFit, Length, Padding, Pixels,
- Point, Rectangle, Size, Vector,
-};
-pub use iced_futures::{executor, futures};
-pub use iced_style::application;
-pub use iced_style::theme;
+pub use iced_core as core;
+pub use iced_futures as futures;
-#[doc(no_inline)]
-pub use executor::Executor;
-
-pub use clipboard::Clipboard;
pub use command::Command;
pub use debug::Debug;
-pub use element::Element;
-pub use event::Event;
pub use font::Font;
-pub use gradient::Gradient;
-pub use hasher::Hasher;
-pub use layout::Layout;
-pub use overlay::Overlay;
pub use program::Program;
-pub use renderer::Renderer;
pub use runtime::Runtime;
-pub use shell::Shell;
pub use subscription::Subscription;
-pub use theme::Theme;
pub use user_interface::UserInterface;
-pub use widget::Widget;
diff --git a/native/src/mouse.rs b/native/src/mouse.rs
deleted file mode 100644
index 9ee406cf..00000000
--- a/native/src/mouse.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-//! Track mouse events.
-
-pub mod click;
-
-pub use click::Click;
-pub use iced_core::mouse::*;
diff --git a/native/src/program.rs b/native/src/program.rs
index 25cab332..44585cc5 100644
--- a/native/src/program.rs
+++ b/native/src/program.rs
@@ -1,6 +1,8 @@
//! Build interactive programs using The Elm Architecture.
-use crate::text;
-use crate::{Command, Element, Renderer};
+use crate::Command;
+
+use iced_core::text;
+use iced_core::{Element, Renderer};
mod state;
diff --git a/native/src/program/state.rs b/native/src/program/state.rs
index 8ae1cacb..2fa9934d 100644
--- a/native/src/program/state.rs
+++ b/native/src/program/state.rs
@@ -1,9 +1,9 @@
-use crate::application;
-use crate::event::{self, Event};
-use crate::mouse;
-use crate::renderer;
+use crate::core::event::{self, Event};
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::{Clipboard, Point, Size};
use crate::user_interface::{self, UserInterface};
-use crate::{Clipboard, Command, Debug, Point, Program, Size};
+use crate::{Command, Debug, Program};
/// The execution state of a [`Program`]. It leverages caching, event
/// processing, and rendering primitive storage.
@@ -22,7 +22,6 @@ where
impl<P> State<P>
where
P: Program + 'static,
- <P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
{
/// Creates a new [`State`] with the provided [`Program`], initializing its
/// primitive with the given logical bounds and renderer.
@@ -91,7 +90,7 @@ where
bounds: Size,
cursor_position: Point,
renderer: &mut P::Renderer,
- theme: &<P::Renderer as crate::Renderer>::Theme,
+ theme: &<P::Renderer as iced_core::Renderer>::Theme,
style: &renderer::Style,
clipboard: &mut dyn Clipboard,
debug: &mut Debug,
@@ -182,10 +181,7 @@ fn build_user_interface<'a, P: Program>(
renderer: &mut P::Renderer,
size: Size,
debug: &mut Debug,
-) -> UserInterface<'a, P::Message, P::Renderer>
-where
- <P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
-{
+) -> UserInterface<'a, P::Message, P::Renderer> {
debug.view_started();
let view = program.view();
debug.view_finished();
diff --git a/native/src/runtime.rs b/native/src/runtime.rs
index 5b0a6925..1b81314f 100644
--- a/native/src/runtime.rs
+++ b/native/src/runtime.rs
@@ -1,6 +1,6 @@
//! Run commands and subscriptions.
-use crate::event::{self, Event};
-use crate::Hasher;
+use iced_core::event::{self, Event};
+use iced_core::Hasher;
/// A native runtime with a generic executor and receiver of results.
///
diff --git a/native/src/subscription.rs b/native/src/subscription.rs
index 16e78e82..b16bcb03 100644
--- a/native/src/subscription.rs
+++ b/native/src/subscription.rs
@@ -1,10 +1,9 @@
//! Listen to external events in your application.
-use crate::event::{self, Event};
-use crate::window;
-use crate::Hasher;
-
-use iced_futures::futures::{self, Future, Stream};
-use iced_futures::{BoxStream, MaybeSend};
+use crate::core::event::{self, Event};
+use crate::core::window;
+use crate::core::Hasher;
+use crate::futures::futures::{self, Future, Stream};
+use crate::futures::{BoxStream, MaybeSend};
use std::hash::Hash;
@@ -144,7 +143,9 @@ where
///
/// ```
/// use iced_native::subscription::{self, Subscription};
-/// use iced_native::futures::channel::mpsc;
+/// use iced_native::futures::futures;
+///
+/// use futures::channel::mpsc;
///
/// pub enum Event {
/// Ready(mpsc::Sender<Input>),
@@ -174,7 +175,7 @@ where
/// (Some(Event::Ready(sender)), State::Ready(receiver))
/// }
/// State::Ready(mut receiver) => {
-/// use iced_native::futures::StreamExt;
+/// use futures::StreamExt;
///
/// // Read next input sent from `Application`
/// let input = receiver.select_next_some().await;
diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs
index 68ccda55..315027fa 100644
--- a/native/src/user_interface.rs
+++ b/native/src/user_interface.rs
@@ -1,14 +1,12 @@
//! Implement your own event loop to drive a user interface.
-use crate::application;
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::widget;
-use crate::window;
-use crate::{
- Clipboard, Element, Layout, Point, Rectangle, Shell, Size, Vector,
-};
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::widget;
+use crate::core::window;
+use crate::core::{Clipboard, Point, Rectangle, Size, Vector};
+use crate::core::{Element, Layout, Shell};
/// A set of interactive graphical elements with a specific [`Layout`].
///
@@ -34,8 +32,7 @@ pub struct UserInterface<'a, Message, Renderer> {
impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
- Renderer::Theme: application::StyleSheet,
+ Renderer: iced_core::Renderer,
{
/// Builds a user interface for an [`Element`].
///
@@ -48,24 +45,21 @@ where
/// is naive way to set up our application loop:
///
/// ```no_run
- /// use iced_native::Size;
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_native::core::renderer::Null as Renderer;
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
+ /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_native::core::Size;
+ /// use iced_native::user_interface::{self, UserInterface};
+ /// use iced_wgpu::Renderer;
+ ///
/// // Initialization
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
@@ -124,25 +118,21 @@ where
/// completing [the previous example](#example):
///
/// ```no_run
- /// use iced_native::{clipboard, Size, Point};
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_native::core::renderer::Null as Renderer;
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
- /// # pub fn update(&mut self, message: ()) {}
+ /// # pub fn view(&self) -> iced_core::Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_native::core::{clipboard, Size, Point};
+ /// use iced_native::user_interface::{self, UserInterface};
+ /// use iced_wgpu::Renderer;
+ ///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
/// let mut renderer = Renderer::new();
@@ -357,27 +347,24 @@ where
/// [completing the last example](#example-1):
///
/// ```no_run
- /// use iced_native::clipboard;
- /// use iced_native::renderer;
- /// use iced_native::user_interface::{self, UserInterface};
- /// use iced_native::{Size, Point, Theme};
- /// use iced_wgpu::Renderer;
- ///
/// # mod iced_wgpu {
- /// # pub use iced_native::renderer::Null as Renderer;
+ /// # pub use iced_native::core::renderer::Null as Renderer;
+ /// # pub type Theme = ();
/// # }
/// #
- /// # use iced_native::widget::Column;
- /// #
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn new() -> Self { Counter }
- /// # pub fn view(&self) -> Column<(), Renderer> {
- /// # Column::new()
- /// # }
- /// # pub fn update(&mut self, message: ()) {}
+ /// # pub fn view(&self) -> Element<(), Renderer> { unimplemented!() }
+ /// # pub fn update(&mut self, _: ()) {}
/// # }
+ /// use iced_native::core::clipboard;
+ /// use iced_native::core::renderer;
+ /// use iced_native::core::{Element, Size, Point};
+ /// use iced_native::user_interface::{self, UserInterface};
+ /// use iced_wgpu::{Renderer, Theme};
+ ///
/// let mut counter = Counter::new();
/// let mut cache = user_interface::Cache::new();
/// let mut renderer = Renderer::new();
@@ -386,6 +373,7 @@ where
/// let mut clipboard = clipboard::Null;
/// let mut events = Vec::new();
/// let mut messages = Vec::new();
+ /// let mut theme = Theme::default();
///
/// loop {
/// // Obtain system events...
@@ -407,7 +395,7 @@ where
/// );
///
/// // Draw the user interface
- /// let mouse_cursor = user_interface.draw(&mut renderer, &Theme::default(), &renderer::Style::default(), cursor_position);
+ /// let mouse_cursor = user_interface.draw(&mut renderer, &theme, &renderer::Style::default(), cursor_position);
///
/// cache = user_interface.into_cache();
///
diff --git a/native/src/widget.rs b/native/src/widget.rs
index 2b3ca7be..0fdade54 100644
--- a/native/src/widget.rs
+++ b/native/src/widget.rs
@@ -11,212 +11,6 @@
//! source of inspiration.
//!
//! [renderer]: crate::renderer
-pub mod button;
-pub mod checkbox;
-pub mod column;
-pub mod container;
-pub mod helpers;
-pub mod image;
-pub mod operation;
-pub mod pane_grid;
-pub mod pick_list;
-pub mod progress_bar;
-pub mod radio;
-pub mod row;
-pub mod rule;
-pub mod scrollable;
-pub mod slider;
-pub mod space;
-pub mod svg;
-pub mod text;
-pub mod text_input;
-pub mod toggler;
-pub mod tooltip;
-pub mod tree;
-pub mod vertical_slider;
-
mod action;
-mod id;
-
-#[doc(no_inline)]
-pub use button::Button;
-#[doc(no_inline)]
-pub use checkbox::Checkbox;
-#[doc(no_inline)]
-pub use column::Column;
-#[doc(no_inline)]
-pub use container::Container;
-#[doc(no_inline)]
-pub use helpers::*;
-#[doc(no_inline)]
-pub use image::Image;
-#[doc(no_inline)]
-pub use pane_grid::PaneGrid;
-#[doc(no_inline)]
-pub use pick_list::PickList;
-#[doc(no_inline)]
-pub use progress_bar::ProgressBar;
-#[doc(no_inline)]
-pub use radio::Radio;
-#[doc(no_inline)]
-pub use row::Row;
-#[doc(no_inline)]
-pub use rule::Rule;
-#[doc(no_inline)]
-pub use scrollable::Scrollable;
-#[doc(no_inline)]
-pub use slider::Slider;
-#[doc(no_inline)]
-pub use space::Space;
-#[doc(no_inline)]
-pub use svg::Svg;
-#[doc(no_inline)]
-pub use text::Text;
-#[doc(no_inline)]
-pub use text_input::TextInput;
-#[doc(no_inline)]
-pub use toggler::Toggler;
-#[doc(no_inline)]
-pub use tooltip::Tooltip;
-#[doc(no_inline)]
-pub use tree::Tree;
-#[doc(no_inline)]
-pub use vertical_slider::VerticalSlider;
pub use action::Action;
-pub use id::Id;
-pub use operation::Operation;
-
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::{Clipboard, Layout, Length, Point, Rectangle, Shell};
-
-/// A component that displays information and allows interaction.
-///
-/// If you want to build your own widgets, you will need to implement this
-/// trait.
-///
-/// # Examples
-/// The repository has some [examples] showcasing how to implement a custom
-/// widget:
-///
-/// - [`bezier_tool`], a Paint-like tool for drawing Bézier curves using
-/// [`lyon`].
-/// - [`custom_widget`], a demonstration of how to build a custom widget that
-/// draws a circle.
-/// - [`geometry`], a custom widget showcasing how to draw geometry with the
-/// `Mesh2D` primitive in [`iced_wgpu`].
-///
-/// [examples]: https://github.com/iced-rs/iced/tree/0.8/examples
-/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.8/examples/bezier_tool
-/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.8/examples/custom_widget
-/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.8/examples/geometry
-/// [`lyon`]: https://github.com/nical/lyon
-/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.8/wgpu
-pub trait Widget<Message, Renderer>
-where
- Renderer: crate::Renderer,
-{
- /// Returns the width of the [`Widget`].
- fn width(&self) -> Length;
-
- /// Returns the height of the [`Widget`].
- fn height(&self) -> Length;
-
- /// Returns the [`layout::Node`] of the [`Widget`].
- ///
- /// This [`layout::Node`] is used by the runtime to compute the [`Layout`] of the
- /// user interface.
- fn layout(
- &self,
- renderer: &Renderer,
- limits: &layout::Limits,
- ) -> layout::Node;
-
- /// Draws the [`Widget`] using the associated `Renderer`.
- fn draw(
- &self,
- state: &Tree,
- renderer: &mut Renderer,
- theme: &Renderer::Theme,
- style: &renderer::Style,
- layout: Layout<'_>,
- cursor_position: Point,
- viewport: &Rectangle,
- );
-
- /// Returns the [`Tag`] of the [`Widget`].
- ///
- /// [`Tag`]: tree::Tag
- fn tag(&self) -> tree::Tag {
- tree::Tag::stateless()
- }
-
- /// Returns the [`State`] of the [`Widget`].
- ///
- /// [`State`]: tree::State
- fn state(&self) -> tree::State {
- tree::State::None
- }
-
- /// Returns the state [`Tree`] of the children of the [`Widget`].
- fn children(&self) -> Vec<Tree> {
- Vec::new()
- }
-
- /// Reconciliates the [`Widget`] with the provided [`Tree`].
- fn diff(&self, _tree: &mut Tree) {}
-
- /// Applies an [`Operation`] to the [`Widget`].
- fn operate(
- &self,
- _state: &mut Tree,
- _layout: Layout<'_>,
- _renderer: &Renderer,
- _operation: &mut dyn Operation<Message>,
- ) {
- }
-
- /// Processes a runtime [`Event`].
- ///
- /// By default, it does nothing.
- fn on_event(
- &mut self,
- _state: &mut Tree,
- _event: Event,
- _layout: Layout<'_>,
- _cursor_position: Point,
- _renderer: &Renderer,
- _clipboard: &mut dyn Clipboard,
- _shell: &mut Shell<'_, Message>,
- ) -> event::Status {
- event::Status::Ignored
- }
-
- /// Returns the current [`mouse::Interaction`] of the [`Widget`].
- ///
- /// By default, it returns [`mouse::Interaction::Idle`].
- fn mouse_interaction(
- &self,
- _state: &Tree,
- _layout: Layout<'_>,
- _cursor_position: Point,
- _viewport: &Rectangle,
- _renderer: &Renderer,
- ) -> mouse::Interaction {
- mouse::Interaction::Idle
- }
-
- /// Returns the overlay of the [`Widget`], if there is any.
- fn overlay<'a>(
- &'a mut self,
- _state: &'a mut Tree,
- _layout: Layout<'_>,
- _renderer: &Renderer,
- ) -> Option<overlay::Element<'a, Message, Renderer>> {
- None
- }
-}
diff --git a/native/src/widget/action.rs b/native/src/widget/action.rs
index 3f1b6b6c..f50d7aec 100644
--- a/native/src/widget/action.rs
+++ b/native/src/widget/action.rs
@@ -1,8 +1,7 @@
-use crate::widget::operation::{
+use iced_core::widget::operation::{
self, Focusable, Operation, Scrollable, TextInput,
};
-use crate::widget::Id;
-
+use iced_core::widget::Id;
use iced_futures::MaybeSend;
use std::any::Any;
diff --git a/native/src/widget/helpers.rs b/native/src/widget/helpers.rs
deleted file mode 100644
index d13eca75..00000000
--- a/native/src/widget/helpers.rs
+++ /dev/null
@@ -1,317 +0,0 @@
-//! Helper functions to create pure widgets.
-use crate::overlay;
-use crate::widget;
-use crate::{Element, Length, Pixels};
-
-use std::borrow::Cow;
-use std::ops::RangeInclusive;
-
-/// Creates a [`Column`] with the given children.
-///
-/// [`Column`]: widget::Column
-#[macro_export]
-macro_rules! column {
- () => (
- $crate::widget::Column::new()
- );
- ($($x:expr),+ $(,)?) => (
- $crate::widget::Column::with_children(vec![$($crate::Element::from($x)),+])
- );
-}
-
-/// Creates a [`Row`] with the given children.
-///
-/// [`Row`]: widget::Row
-#[macro_export]
-macro_rules! row {
- () => (
- $crate::widget::Row::new()
- );
- ($($x:expr),+ $(,)?) => (
- $crate::widget::Row::with_children(vec![$($crate::Element::from($x)),+])
- );
-}
-
-/// Creates a new [`Container`] with the provided content.
-///
-/// [`Container`]: widget::Container
-pub fn container<'a, Message, Renderer>(
- content: impl Into<Element<'a, Message, Renderer>>,
-) -> widget::Container<'a, Message, Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::container::StyleSheet,
-{
- widget::Container::new(content)
-}
-
-/// Creates a new [`Column`] with the given children.
-///
-/// [`Column`]: widget::Column
-pub fn column<Message, Renderer>(
- children: Vec<Element<'_, Message, Renderer>>,
-) -> widget::Column<'_, Message, Renderer> {
- widget::Column::with_children(children)
-}
-
-/// Creates a new [`Row`] with the given children.
-///
-/// [`Row`]: widget::Row
-pub fn row<Message, Renderer>(
- children: Vec<Element<'_, Message, Renderer>>,
-) -> widget::Row<'_, Message, Renderer> {
- widget::Row::with_children(children)
-}
-
-/// Creates a new [`Scrollable`] with the provided content.
-///
-/// [`Scrollable`]: widget::Scrollable
-pub fn scrollable<'a, Message, Renderer>(
- content: impl Into<Element<'a, Message, Renderer>>,
-) -> widget::Scrollable<'a, Message, Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::scrollable::StyleSheet,
-{
- widget::Scrollable::new(content)
-}
-
-/// Creates a new [`Button`] with the provided content.
-///
-/// [`Button`]: widget::Button
-pub fn button<'a, Message, Renderer>(
- content: impl Into<Element<'a, Message, Renderer>>,
-) -> widget::Button<'a, Message, Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::button::StyleSheet,
- <Renderer::Theme as widget::button::StyleSheet>::Style: Default,
-{
- widget::Button::new(content)
-}
-
-/// Creates a new [`Tooltip`] with the provided content, tooltip text, and [`tooltip::Position`].
-///
-/// [`Tooltip`]: widget::Tooltip
-/// [`tooltip::Position`]: widget::tooltip::Position
-pub fn tooltip<'a, Message, Renderer>(
- content: impl Into<Element<'a, Message, Renderer>>,
- tooltip: impl ToString,
- position: widget::tooltip::Position,
-) -> widget::Tooltip<'a, Message, Renderer>
-where
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::container::StyleSheet + widget::text::StyleSheet,
-{
- widget::Tooltip::new(content, tooltip.to_string(), position)
-}
-
-/// Creates a new [`Text`] widget with the provided content.
-///
-/// [`Text`]: widget::Text
-pub fn text<'a, Renderer>(text: impl ToString) -> widget::Text<'a, Renderer>
-where
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::text::StyleSheet,
-{
- widget::Text::new(text.to_string())
-}
-
-/// Creates a new [`Checkbox`].
-///
-/// [`Checkbox`]: widget::Checkbox
-pub fn checkbox<'a, Message, Renderer>(
- label: impl Into<String>,
- is_checked: bool,
- f: impl Fn(bool) -> Message + 'a,
-) -> widget::Checkbox<'a, Message, Renderer>
-where
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::checkbox::StyleSheet + widget::text::StyleSheet,
-{
- widget::Checkbox::new(label, is_checked, f)
-}
-
-/// Creates a new [`Radio`].
-///
-/// [`Radio`]: widget::Radio
-pub fn radio<Message, Renderer, V>(
- label: impl Into<String>,
- value: V,
- selected: Option<V>,
- on_click: impl FnOnce(V) -> Message,
-) -> widget::Radio<Message, Renderer>
-where
- Message: Clone,
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::radio::StyleSheet,
- V: Copy + Eq,
-{
- widget::Radio::new(value, label, selected, on_click)
-}
-
-/// Creates a new [`Toggler`].
-///
-/// [`Toggler`]: widget::Toggler
-pub fn toggler<'a, Message, Renderer>(
- label: impl Into<Option<String>>,
- is_checked: bool,
- f: impl Fn(bool) -> Message + 'a,
-) -> widget::Toggler<'a, Message, Renderer>
-where
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::toggler::StyleSheet,
-{
- widget::Toggler::new(label, is_checked, f)
-}
-
-/// Creates a new [`TextInput`].
-///
-/// [`TextInput`]: widget::TextInput
-pub fn text_input<'a, Message, Renderer>(
- placeholder: &str,
- value: &str,
- on_change: impl Fn(String) -> Message + 'a,
-) -> widget::TextInput<'a, Message, Renderer>
-where
- Message: Clone,
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::text_input::StyleSheet,
-{
- widget::TextInput::new(placeholder, value, on_change)
-}
-
-/// Creates a new [`Slider`].
-///
-/// [`Slider`]: widget::Slider
-pub fn slider<'a, T, Message, Renderer>(
- range: std::ops::RangeInclusive<T>,
- value: T,
- on_change: impl Fn(T) -> Message + 'a,
-) -> widget::Slider<'a, T, Message, Renderer>
-where
- T: Copy + From<u8> + std::cmp::PartialOrd,
- Message: Clone,
- Renderer: crate::Renderer,
- Renderer::Theme: widget::slider::StyleSheet,
-{
- widget::Slider::new(range, value, on_change)
-}
-
-/// Creates a new [`VerticalSlider`].
-///
-/// [`VerticalSlider`]: widget::VerticalSlider
-pub fn vertical_slider<'a, T, Message, Renderer>(
- range: std::ops::RangeInclusive<T>,
- value: T,
- on_change: impl Fn(T) -> Message + 'a,
-) -> widget::VerticalSlider<'a, T, Message, Renderer>
-where
- T: Copy + From<u8> + std::cmp::PartialOrd,
- Message: Clone,
- Renderer: crate::Renderer,
- Renderer::Theme: widget::slider::StyleSheet,
-{
- widget::VerticalSlider::new(range, value, on_change)
-}
-
-/// Creates a new [`PickList`].
-///
-/// [`PickList`]: widget::PickList
-pub fn pick_list<'a, Message, Renderer, T>(
- options: impl Into<Cow<'a, [T]>>,
- selected: Option<T>,
- on_selected: impl Fn(T) -> Message + 'a,
-) -> widget::PickList<'a, T, Message, Renderer>
-where
- T: ToString + Eq + 'static,
- [T]: ToOwned<Owned = Vec<T>>,
- Renderer: crate::text::Renderer,
- Renderer::Theme: widget::pick_list::StyleSheet
- + widget::scrollable::StyleSheet
- + overlay::menu::StyleSheet
- + widget::container::StyleSheet,
- <Renderer::Theme as overlay::menu::StyleSheet>::Style:
- From<<Renderer::Theme as widget::pick_list::StyleSheet>::Style>,
-{
- widget::PickList::new(options, selected, on_selected)
-}
-
-/// Creates a new [`Image`].
-///
-/// [`Image`]: widget::Image
-pub fn image<Handle>(handle: impl Into<Handle>) -> widget::Image<Handle> {
- widget::Image::new(handle.into())
-}
-
-/// Creates a new horizontal [`Space`] with the given [`Length`].
-///
-/// [`Space`]: widget::Space
-pub fn horizontal_space(width: impl Into<Length>) -> widget::Space {
- widget::Space::with_width(width)
-}
-
-/// Creates a new vertical [`Space`] with the given [`Length`].
-///
-/// [`Space`]: widget::Space
-pub fn vertical_space(height: impl Into<Length>) -> widget::Space {
- widget::Space::with_height(height)
-}
-
-/// Creates a horizontal [`Rule`] with the given height.
-///
-/// [`Rule`]: widget::Rule
-pub fn horizontal_rule<Renderer>(
- height: impl Into<Pixels>,
-) -> widget::Rule<Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::rule::StyleSheet,
-{
- widget::Rule::horizontal(height)
-}
-
-/// Creates a vertical [`Rule`] with the given width.
-///
-/// [`Rule`]: widget::Rule
-pub fn vertical_rule<Renderer>(
- width: impl Into<Pixels>,
-) -> widget::Rule<Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::rule::StyleSheet,
-{
- widget::Rule::vertical(width)
-}
-
-/// Creates a new [`ProgressBar`].
-///
-/// It expects:
-/// * an inclusive range of possible values, and
-/// * the current value of the [`ProgressBar`].
-///
-/// [`ProgressBar`]: widget::ProgressBar
-pub fn progress_bar<Renderer>(
- range: RangeInclusive<f32>,
- value: f32,
-) -> widget::ProgressBar<Renderer>
-where
- Renderer: crate::Renderer,
- Renderer::Theme: widget::progress_bar::StyleSheet,
-{
- widget::ProgressBar::new(range, value)
-}
-
-/// Creates a new [`Svg`] widget from the given [`Handle`].
-///
-/// [`Svg`]: widget::Svg
-/// [`Handle`]: widget::svg::Handle
-pub fn svg<Renderer>(
- handle: impl Into<widget::svg::Handle>,
-) -> widget::Svg<Renderer>
-where
- Renderer: crate::svg::Renderer,
- Renderer::Theme: widget::svg::StyleSheet,
-{
- widget::Svg::new(handle)
-}
diff --git a/native/src/window.rs b/native/src/window.rs
index a5cdc8ce..97a96e54 100644
--- a/native/src/window.rs
+++ b/native/src/window.rs
@@ -1,18 +1,11 @@
//! Build window-based GUI applications.
mod action;
-mod event;
-mod mode;
-mod redraw_request;
-mod user_attention;
pub use action::Action;
-pub use event::Event;
-pub use mode::Mode;
-pub use redraw_request::RedrawRequest;
-pub use user_attention::UserAttention;
+use crate::core::time::Instant;
+use crate::core::window::Event;
use crate::subscription::{self, Subscription};
-use crate::time::Instant;
/// Subscribes to the frames of the window of the running application.
///
@@ -24,7 +17,7 @@ use crate::time::Instant;
/// animations without missing any frames.
pub fn frames() -> Subscription<Instant> {
subscription::raw_events(|event, _status| match event {
- crate::Event::Window(Event::RedrawRequested(at)) => Some(at),
+ iced_core::Event::Window(Event::RedrawRequested(at)) => Some(at),
_ => None,
})
}
diff --git a/native/src/window/action.rs b/native/src/window/action.rs
index ce36d129..c1dbd84f 100644
--- a/native/src/window/action.rs
+++ b/native/src/window/action.rs
@@ -1,6 +1,6 @@
-use crate::window::{Mode, UserAttention};
+use crate::core::window::{Mode, UserAttention};
+use crate::futures::MaybeSend;
-use iced_futures::MaybeSend;
use std::fmt;
/// An operation to be performed on some window.
diff --git a/renderer/Cargo.toml b/renderer/Cargo.toml
index 189f5309..d0420ad0 100644
--- a/renderer/Cargo.toml
+++ b/renderer/Cargo.toml
@@ -13,10 +13,6 @@ tracing = ["iced_wgpu/tracing"]
raw-window-handle = "0.5"
thiserror = "1"
-[dependencies.iced_native]
-version = "0.9"
-path = "../native"
-
[dependencies.iced_graphics]
version = "0.7"
path = "../graphics"
diff --git a/renderer/src/backend.rs b/renderer/src/backend.rs
index b0a409dc..bf5da322 100644
--- a/renderer/src/backend.rs
+++ b/renderer/src/backend.rs
@@ -1,7 +1,6 @@
-use crate::{Font, Point, Size};
-
-use iced_graphics::backend;
-use iced_graphics::text;
+use crate::core::text;
+use crate::core::{Font, Point, Size};
+use crate::graphics::backend;
use std::borrow::Cow;
@@ -99,7 +98,7 @@ impl backend::Text for Backend {
#[cfg(feature = "image")]
impl backend::Image for Backend {
- fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
+ fn dimensions(&self, handle: &crate::core::image::Handle) -> Size<u32> {
match self {
Self::Wgpu(backend) => backend.dimensions(handle),
Self::TinySkia(backend) => backend.dimensions(handle),
@@ -111,7 +110,7 @@ impl backend::Image for Backend {
impl backend::Svg for Backend {
fn viewport_dimensions(
&self,
- handle: &iced_native::svg::Handle,
+ handle: &crate::core::svg::Handle,
) -> Size<u32> {
match self {
Self::Wgpu(backend) => backend.viewport_dimensions(handle),
diff --git a/renderer/src/window/compositor.rs b/renderer/src/compositor.rs
index a11374ed..0cdcb293 100644
--- a/renderer/src/window/compositor.rs
+++ b/renderer/src/compositor.rs
@@ -1,9 +1,10 @@
-use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
+use crate::core::Color;
+use crate::graphics::compositor::{Information, SurfaceError};
+use crate::graphics::{Error, Viewport};
+use crate::{Backend, Renderer, Settings};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
-pub use iced_graphics::window::compositor::{Information, SurfaceError};
-
pub enum Compositor<Theme> {
Wgpu(iced_wgpu::window::Compositor<Theme>),
TinySkia(iced_tiny_skia::window::Compositor<Theme>),
@@ -14,7 +15,7 @@ pub enum Surface {
TinySkia(iced_tiny_skia::window::Surface),
}
-impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
+impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
type Settings = Settings;
type Renderer = Renderer<Theme>;
type Surface = Surface;
diff --git a/renderer/src/geometry.rs b/renderer/src/geometry.rs
index e491ea73..361fc86b 100644
--- a/renderer/src/geometry.rs
+++ b/renderer/src/geometry.rs
@@ -2,9 +2,9 @@ mod cache;
pub use cache::Cache;
-pub use iced_graphics::geometry::*;
-
-use crate::{Backend, Point, Rectangle, Size, Vector};
+use crate::core::{Point, Rectangle, Size, Vector};
+use crate::graphics::geometry::{Fill, Geometry, Path, Stroke, Text};
+use crate::Backend;
pub enum Frame {
Wgpu(iced_wgpu::geometry::Frame),
diff --git a/renderer/src/geometry/cache.rs b/renderer/src/geometry/cache.rs
index 1f1febdd..2a3534d0 100644
--- a/renderer/src/geometry/cache.rs
+++ b/renderer/src/geometry/cache.rs
@@ -1,5 +1,7 @@
+use crate::core::Size;
use crate::geometry::{Frame, Geometry};
-use crate::{Primitive, Renderer, Size};
+use crate::graphics::Primitive;
+use crate::Renderer;
use std::cell::RefCell;
use std::sync::Arc;
diff --git a/renderer/src/lib.rs b/renderer/src/lib.rs
index aae3322d..22ec7bd1 100644
--- a/renderer/src/lib.rs
+++ b/renderer/src/lib.rs
@@ -1,4 +1,4 @@
-pub mod window;
+pub mod compositor;
#[cfg(feature = "geometry")]
pub mod geometry;
@@ -6,18 +6,14 @@ pub mod geometry;
mod backend;
mod settings;
-pub use iced_graphics::primitive;
+pub use iced_graphics as graphics;
+pub use iced_graphics::core;
pub use backend::Backend;
-pub use primitive::Primitive;
+pub use compositor::Compositor;
pub use settings::Settings;
-pub use iced_graphics::{
- Antialiasing, Color, Error, Font, Point, Rectangle, Size, Vector, Viewport,
-};
-
/// The default graphics renderer for [`iced`].
///
/// [`iced`]: https://github.com/iced-rs/iced
-pub type Renderer<Theme = iced_native::Theme> =
- iced_graphics::Renderer<Backend, Theme>;
+pub type Renderer<Theme> = iced_graphics::Renderer<Backend, Theme>;
diff --git a/renderer/src/settings.rs b/renderer/src/settings.rs
index c4dc248b..d32c87d3 100644
--- a/renderer/src/settings.rs
+++ b/renderer/src/settings.rs
@@ -1,4 +1,5 @@
-use crate::{Antialiasing, Font};
+use crate::core::Font;
+use crate::graphics::Antialiasing;
/// The settings of a [`Backend`].
///
diff --git a/renderer/src/window.rs b/renderer/src/window.rs
deleted file mode 100644
index a7c8911b..00000000
--- a/renderer/src/window.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-mod compositor;
-
-pub use compositor::Compositor;
diff --git a/src/advanced.rs b/src/advanced.rs
new file mode 100644
index 00000000..714076e0
--- /dev/null
+++ b/src/advanced.rs
@@ -0,0 +1,9 @@
+//! Leverage advanced concepts like custom widgets.
+pub use crate::core::image;
+pub use crate::core::layout::{self, Layout};
+pub use crate::core::overlay::{self, Overlay};
+pub use crate::core::renderer::{self, Renderer};
+pub use crate::core::svg;
+pub use crate::core::text::{self, Text};
+pub use crate::core::widget::{self, Widget};
+pub use crate::core::{Clipboard, Shell};
diff --git a/src/application.rs b/src/application.rs
index b9871556..f5cf3317 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -1,7 +1,7 @@
//! Build interactive cross-platform applications.
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 application.
///
@@ -198,24 +198,24 @@ pub trait Application: Sized {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
antialiasing: if settings.antialiasing {
- Some(crate::renderer::Antialiasing::MSAAx4)
+ Some(crate::graphics::Antialiasing::MSAAx4)
} else {
None
},
..crate::renderer::Settings::default()
};
- Ok(crate::runtime::application::run::<
+ Ok(crate::shell::application::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> iced_winit::Program for Instance<A>
+impl<A> crate::native::Program for Instance<A>
where
A: Application,
{
@@ -231,7 +231,7 @@ where
}
}
-impl<A> crate::runtime::Application for Instance<A>
+impl<A> crate::shell::Application for Instance<A>
where
A: Application,
{
diff --git a/src/clipboard.rs b/src/clipboard.rs
deleted file mode 100644
index dde17051..00000000
--- a/src/clipboard.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-//! Access the clipboard.
-#[cfg(not(target_arch = "wasm32"))]
-pub use crate::runtime::clipboard::{read, write};
diff --git a/src/element.rs b/src/element.rs
deleted file mode 100644
index 2eb1bb4d..00000000
--- a/src/element.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-/// 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::runtime::Element<'a, Message, Renderer>;
diff --git a/src/error.rs b/src/error.rs
index 5326718f..111bedf2 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,4 +1,6 @@
-use iced_futures::futures;
+use crate::futures;
+use crate::graphics;
+use crate::shell;
/// An error that occurred while running an application.
#[derive(Debug, thiserror::Error)]
@@ -13,19 +15,19 @@ pub enum Error {
/// The application graphics context could not be created.
#[error("the application graphics context could not be created")]
- GraphicsCreationFailed(iced_renderer::Error),
+ GraphicsCreationFailed(graphics::Error),
}
-impl From<iced_winit::Error> for Error {
- fn from(error: iced_winit::Error) -> Error {
+impl From<shell::Error> for Error {
+ fn from(error: shell::Error) -> Error {
match error {
- iced_winit::Error::ExecutorCreationFailed(error) => {
+ shell::Error::ExecutorCreationFailed(error) => {
Error::ExecutorCreationFailed(error)
}
- iced_winit::Error::WindowCreationFailed(error) => {
+ shell::Error::WindowCreationFailed(error) => {
Error::WindowCreationFailed(Box::new(error))
}
- iced_winit::Error::GraphicsCreationFailed(error) => {
+ shell::Error::GraphicsCreationFailed(error) => {
Error::GraphicsCreationFailed(error)
}
}
diff --git a/src/executor.rs b/src/executor.rs
deleted file mode 100644
index 36ae274e..00000000
--- a/src/executor.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-//! Choose your preferred executor to power your application.
-pub use crate::runtime::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;
diff --git a/src/keyboard.rs b/src/keyboard.rs
deleted file mode 100644
index 2134a66b..00000000
--- a/src/keyboard.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-//! Listen and react to keyboard events.
-pub use crate::runtime::keyboard::{Event, KeyCode, Modifiers};
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<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>;
diff --git a/src/mouse.rs b/src/mouse.rs
deleted file mode 100644
index d61ed09a..00000000
--- a/src/mouse.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-//! Listen and react to mouse events.
-pub use crate::runtime::mouse::{Button, Event, Interaction, ScrollDelta};
diff --git a/src/overlay.rs b/src/overlay.rs
deleted file mode 100644
index c0f4c492..00000000
--- a/src/overlay.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-//! 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> =
- iced_native::overlay::Element<'a, Message, Renderer>;
-
-pub mod menu {
- //! Build and show dropdown menus.
- pub use iced_native::overlay::menu::{Appearance, State, StyleSheet};
-
- /// A widget that produces a message when clicked.
- pub type Menu<'a, Message, Renderer = crate::Renderer> =
- iced_native::overlay::Menu<'a, Message, Renderer>;
-}
diff --git a/src/result.rs b/src/result.rs
deleted file mode 100644
index ef565bd6..00000000
--- a/src/result.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-use crate::Error;
-
-/// The result of running an [`Application`].
-///
-/// [`Application`]: crate::Application
-pub type Result = std::result::Result<(), Error>;
diff --git a/src/touch.rs b/src/touch.rs
index 0b77c386..f2bdfca8 100644
--- a/src/touch.rs
+++ b/src/touch.rs
@@ -1,2 +1,2 @@
//! Listen and react to touch events.
-pub use crate::runtime::touch::{Event, Finger};
+pub use crate::core::touch::{Event, Finger};
diff --git a/src/widget.rs b/src/widget.rs
deleted file mode 100644
index 19434e84..00000000
--- a/src/widget.rs
+++ /dev/null
@@ -1,239 +0,0 @@
-//! Display information and interactive controls in your application.
-pub use iced_native::widget::helpers::*;
-
-pub use iced_native::{column, row};
-
-/// A container that distributes its contents vertically.
-pub type Column<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Column<'a, Message, Renderer>;
-
-/// A container that distributes its contents horizontally.
-pub type Row<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Row<'a, Message, Renderer>;
-
-pub mod text {
- //! Write some text for your users to read.
- pub use iced_native::widget::text::{Appearance, StyleSheet};
-
- /// A paragraph of text.
- pub type Text<'a, Renderer = crate::Renderer> =
- iced_native::widget::Text<'a, Renderer>;
-}
-
-pub mod button {
- //! Allow your users to perform actions by pressing a button.
- pub use iced_native::widget::button::{Appearance, StyleSheet};
-
- /// A widget that produces a message when clicked.
- pub type Button<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Button<'a, Message, Renderer>;
-}
-
-pub mod checkbox {
- //! Show toggle controls using checkboxes.
- pub use iced_native::widget::checkbox::{Appearance, Icon, StyleSheet};
-
- /// A box that can be checked.
- pub type Checkbox<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Checkbox<'a, Message, Renderer>;
-}
-
-pub mod container {
- //! Decorate content and apply alignment.
- pub use iced_native::widget::container::{Appearance, StyleSheet};
-
- /// An element decorating some content.
- pub type Container<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Container<'a, Message, Renderer>;
-}
-
-pub mod pane_grid {
- //! Let your users split regions of your application and organize layout dynamically.
- //!
- //! [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
- //!
- //! # Example
- //! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
- //! drag and drop, and hotkey support.
- //!
- //! [`pane_grid` example]: https://github.com/iced-rs/iced/tree/0.8/examples/pane_grid
- pub use iced_native::widget::pane_grid::{
- Axis, Configuration, Direction, DragEvent, Line, Node, Pane,
- ResizeEvent, Split, State, StyleSheet,
- };
-
- /// A collection of panes distributed using either vertical or horizontal splits
- /// to completely fill the space available.
- ///
- /// [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
- pub type PaneGrid<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::PaneGrid<'a, Message, Renderer>;
-
- /// The content of a [`Pane`].
- pub type Content<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::pane_grid::Content<'a, Message, Renderer>;
-
- /// The title bar of a [`Pane`].
- pub type TitleBar<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::pane_grid::TitleBar<'a, Message, Renderer>;
-}
-
-pub mod pick_list {
- //! Display a dropdown list of selectable values.
- pub use iced_native::widget::pick_list::{
- Appearance, Handle, Icon, StyleSheet,
- };
-
- /// A widget allowing the selection of a single value from a list of options.
- pub type PickList<'a, T, Message, Renderer = crate::Renderer> =
- iced_native::widget::PickList<'a, T, Message, Renderer>;
-}
-
-pub mod radio {
- //! Create choices using radio buttons.
- pub use iced_native::widget::radio::{Appearance, StyleSheet};
-
- /// A circular button representing a choice.
- pub type Radio<Message, Renderer = crate::Renderer> =
- iced_native::widget::Radio<Message, Renderer>;
-}
-
-pub mod scrollable {
- //! Navigate an endless amount of content with a scrollbar.
- pub use iced_native::widget::scrollable::{
- snap_to, style::Scrollbar, style::Scroller, Id, Properties,
- RelativeOffset, StyleSheet,
- };
-
- /// A widget that can vertically display an infinite amount of content
- /// with a scrollbar.
- pub type Scrollable<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Scrollable<'a, Message, Renderer>;
-}
-
-pub mod toggler {
- //! Show toggle controls using togglers.
- pub use iced_native::widget::toggler::{Appearance, StyleSheet};
-
- /// A toggler widget.
- pub type Toggler<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Toggler<'a, Message, Renderer>;
-}
-
-pub mod text_input {
- //! Display fields that can be filled with text.
- pub use iced_native::widget::text_input::{
- focus, move_cursor_to, move_cursor_to_end, move_cursor_to_front,
- select_all, Appearance, Id, StyleSheet,
- };
-
- /// A field that can be filled with text.
- pub type TextInput<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::TextInput<'a, Message, Renderer>;
-}
-
-pub mod tooltip {
- //! Display a widget over another.
- pub use iced_native::widget::tooltip::Position;
-
- /// A widget allowing the selection of a single value from a list of options.
- pub type Tooltip<'a, Message, Renderer = crate::Renderer> =
- iced_native::widget::Tooltip<'a, Message, Renderer>;
-}
-
-pub use iced_native::widget::progress_bar;
-pub use iced_native::widget::rule;
-pub use iced_native::widget::slider;
-pub use iced_native::widget::vertical_slider;
-pub use iced_native::widget::Space;
-
-pub use button::Button;
-pub use checkbox::Checkbox;
-pub use container::Container;
-pub use pane_grid::PaneGrid;
-pub use pick_list::PickList;
-pub use progress_bar::ProgressBar;
-pub use radio::Radio;
-pub use rule::Rule;
-pub use scrollable::Scrollable;
-pub use slider::Slider;
-pub use text::Text;
-pub use text_input::TextInput;
-pub use toggler::Toggler;
-pub use tooltip::Tooltip;
-pub use vertical_slider::VerticalSlider;
-
-#[cfg(feature = "canvas")]
-#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
-pub mod canvas;
-
-#[cfg(feature = "canvas")]
-#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
-/// Creates a new [`Canvas`].
-pub fn canvas<P, Message, Renderer>(program: P) -> Canvas<P, Message, Renderer>
-where
- Renderer: iced_renderer::geometry::Renderer,
- P: canvas::Program<Message, Renderer>,
-{
- Canvas::new(program)
-}
-
-#[cfg(feature = "image")]
-#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
-pub mod image {
- //! Display images in your user interface.
- pub use iced_native::image::Handle;
-
- /// A frame that displays an image.
- pub type Image = iced_native::widget::Image<Handle>;
-
- pub use iced_native::widget::image::viewer;
- pub use viewer::Viewer;
-}
-
-#[cfg(feature = "qr_code")]
-#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
-pub mod qr_code;
-
-#[cfg(feature = "svg")]
-#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
-pub mod svg {
- //! Display vector graphics in your application.
- pub use iced_native::svg::Handle;
- pub use iced_native::widget::svg::{Appearance, StyleSheet, Svg};
-}
-
-#[cfg(feature = "canvas")]
-#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
-pub use canvas::Canvas;
-
-#[cfg(feature = "image")]
-#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
-pub use image::Image;
-
-#[cfg(feature = "qr_code")]
-#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
-pub use qr_code::QRCode;
-
-#[cfg(feature = "svg")]
-#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
-pub use svg::Svg;
-
-use crate::Command;
-use iced_native::widget::operation;
-
-/// Focuses the previous focusable widget.
-pub fn focus_previous<Message>() -> Command<Message>
-where
- Message: 'static,
-{
- Command::widget(operation::focusable::focus_previous())
-}
-
-/// Focuses the next focusable widget.
-pub fn focus_next<Message>() -> Command<Message>
-where
- Message: 'static,
-{
- Command::widget(operation::focusable::focus_next())
-}
diff --git a/src/window.rs b/src/window.rs
index 2018053f..26239065 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -8,5 +8,6 @@ pub use icon::Icon;
pub use position::Position;
pub use settings::Settings;
-#[cfg(not(target_arch = "wasm32"))]
-pub use crate::runtime::window::*;
+pub use crate::core::window::*;
+pub use crate::native::window::*;
+pub use crate::shell::window::*;
diff --git a/style/src/lib.rs b/style/src/lib.rs
index 59eb1eb8..286ff9db 100644
--- a/style/src/lib.rs
+++ b/style/src/lib.rs
@@ -18,7 +18,7 @@
#![deny(missing_docs, unused_results)]
#![forbid(unsafe_code, rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
-pub use iced_core::{Background, Color};
+pub use iced_core as core;
pub mod application;
pub mod button;
@@ -33,7 +33,6 @@ pub mod rule;
pub mod scrollable;
pub mod slider;
pub mod svg;
-pub mod text;
pub mod text_input;
pub mod theme;
pub mod toggler;
diff --git a/style/src/text.rs b/style/src/text.rs
index f31c2306..d5a16bef 100644
--- a/style/src/text.rs
+++ b/style/src/text.rs
@@ -1,5 +1,5 @@
//! Change the appearance of text.
-use iced_core::Color;
+use crate::core::Color;
/// The style sheet of some text.
pub trait StyleSheet {
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 4ba4facf..b507d096 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -8,6 +8,7 @@ use crate::application;
use crate::button;
use crate::checkbox;
use crate::container;
+use crate::core::widget::text;
use crate::menu;
use crate::pane_grid;
use crate::pick_list;
@@ -17,7 +18,6 @@ use crate::rule;
use crate::scrollable;
use crate::slider;
use crate::svg;
-use crate::text;
use crate::text_input;
use crate::toggler;
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 050c6c75..d364e36a 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -1,9 +1,9 @@
-use crate::{Color, Font, Primitive, Settings, Size, Viewport};
-
-use iced_graphics::alignment;
-use iced_graphics::backend;
-use iced_graphics::text;
-use iced_graphics::{Background, Rectangle, Vector};
+use crate::core::alignment;
+use crate::core::text;
+use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector};
+use crate::graphics::backend;
+use crate::graphics::{Primitive, Viewport};
+use crate::Settings;
use std::borrow::Cow;
@@ -470,7 +470,7 @@ impl backend::Text for Backend {
size: f32,
font: Font,
bounds: Size,
- point: iced_native::Point,
+ point: Point,
nearest_only: bool,
) -> Option<text::Hit> {
self.text_pipeline.hit_test(
@@ -490,7 +490,7 @@ impl backend::Text for Backend {
#[cfg(feature = "image")]
impl backend::Image for Backend {
- fn dimensions(&self, _handle: &iced_native::image::Handle) -> Size<u32> {
+ fn dimensions(&self, _handle: &crate::core::image::Handle) -> Size<u32> {
// TODO
Size::new(0, 0)
}
@@ -500,7 +500,7 @@ impl backend::Image for Backend {
impl backend::Svg for Backend {
fn viewport_dimensions(
&self,
- _handle: &iced_native::svg::Handle,
+ _handle: &crate::core::svg::Handle,
) -> Size<u32> {
// TODO
Size::new(0, 0)
diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs
index 73fc1ebd..c66621dd 100644
--- a/tiny_skia/src/geometry.rs
+++ b/tiny_skia/src/geometry.rs
@@ -1,9 +1,9 @@
-use crate::{Point, Primitive, Rectangle, Size, Vector};
-
-use iced_graphics::geometry::fill::{self, Fill};
-use iced_graphics::geometry::stroke::{self, Stroke};
-use iced_graphics::geometry::{Path, Style, Text};
-use iced_graphics::Gradient;
+use crate::core::Gradient;
+use crate::core::{Point, Rectangle, Size, Vector};
+use crate::graphics::geometry::fill::{self, Fill};
+use crate::graphics::geometry::stroke::{self, Stroke};
+use crate::graphics::geometry::{Path, Style, Text};
+use crate::graphics::Primitive;
pub struct Frame {
size: Size,
diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs
index ef5c6b1d..bf83e400 100644
--- a/tiny_skia/src/lib.rs
+++ b/tiny_skia/src/lib.rs
@@ -7,19 +7,14 @@ mod text;
#[cfg(feature = "geometry")]
pub mod geometry;
-pub use iced_graphics::primitive;
+pub use iced_graphics as graphics;
+pub use iced_graphics::core;
pub use backend::Backend;
-pub use primitive::Primitive;
pub use settings::Settings;
-pub use iced_graphics::{
- Color, Error, Font, Point, Rectangle, Size, Vector, Viewport,
-};
-
/// A [`tiny-skia`] graphics renderer for [`iced`].
///
/// [`tiny-skia`]: https://github.com/RazrFalcon/tiny-skia
/// [`iced`]: https://github.com/iced-rs/iced
-pub type Renderer<Theme = iced_native::Theme> =
- iced_graphics::Renderer<Backend, Theme>;
+pub type Renderer<Theme> = iced_graphics::Renderer<Backend, Theme>;
diff --git a/tiny_skia/src/settings.rs b/tiny_skia/src/settings.rs
index 88098345..9e4be0c4 100644
--- a/tiny_skia/src/settings.rs
+++ b/tiny_skia/src/settings.rs
@@ -1,4 +1,4 @@
-use crate::Font;
+use crate::core::Font;
/// The settings of a [`Backend`].
///
diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs
index da3a06bf..7a5034c2 100644
--- a/tiny_skia/src/text.rs
+++ b/tiny_skia/src/text.rs
@@ -1,7 +1,6 @@
-pub use iced_native::text::Hit;
-
-use iced_native::alignment;
-use iced_native::{Color, Font, Rectangle, Size};
+use crate::core::alignment;
+use crate::core::text::Hit;
+use crate::core::{Color, Font, Point, Rectangle, Size};
use rustc_hash::{FxHashMap, FxHashSet};
use std::borrow::Cow;
@@ -189,8 +188,8 @@ impl Pipeline {
content: &str,
size: f32,
font: iced_native::Font,
- bounds: iced_native::Size,
- point: iced_native::Point,
+ bounds: Size,
+ point: Point,
_nearest_only: bool,
) -> Option<Hit> {
self.system.as_ref().unwrap().with(|fields| {
diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs
index 76f371e1..cea1cabf 100644
--- a/tiny_skia/src/window/compositor.rs
+++ b/tiny_skia/src/window/compositor.rs
@@ -1,6 +1,7 @@
-use crate::{Backend, Color, Error, Primitive, Renderer, Settings, Viewport};
-
-use iced_graphics::window::compositor::{self, Information, SurfaceError};
+use crate::core::Color;
+use crate::graphics::compositor::{self, Information, SurfaceError};
+use crate::graphics::{Error, Primitive, Viewport};
+use crate::{Backend, Renderer, Settings};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use std::marker::PhantomData;
@@ -15,7 +16,7 @@ pub struct Surface {
buffer: Vec<u32>,
}
-impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
+impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
type Settings = Settings;
type Renderer = Renderer<Theme>;
type Surface = Surface;
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index 2e39a9e7..f3ea66dd 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -48,10 +48,6 @@ features = ["std"]
version = "1.9"
features = ["derive"]
-[dependencies.iced_native]
-version = "0.9"
-path = "../native"
-
[dependencies.iced_graphics]
version = "0.7"
path = "../graphics"
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs
index 6f39a5fe..9c9a1b76 100644
--- a/wgpu/src/backend.rs
+++ b/wgpu/src/backend.rs
@@ -1,10 +1,11 @@
+use crate::core;
+use crate::core::{Color, Font, Point, Size};
+use crate::graphics::backend;
+use crate::graphics::{Primitive, Transformation, Viewport};
use crate::quad;
use crate::text;
use crate::triangle;
-use crate::{Layer, Primitive, Settings, Transformation};
-
-use iced_graphics::backend;
-use iced_graphics::{Color, Font, Size, Viewport};
+use crate::{Layer, Settings};
#[cfg(feature = "tracing")]
use tracing::info_span;
@@ -363,9 +364,9 @@ impl backend::Text for Backend {
size: f32,
font: Font,
bounds: Size,
- point: iced_native::Point,
+ point: Point,
nearest_only: bool,
- ) -> Option<text::Hit> {
+ ) -> Option<core::text::Hit> {
self.text_pipeline.hit_test(
contents,
size,
@@ -383,17 +384,14 @@ impl backend::Text for Backend {
#[cfg(feature = "image")]
impl backend::Image for Backend {
- fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
+ fn dimensions(&self, handle: &core::image::Handle) -> Size<u32> {
self.image_pipeline.dimensions(handle)
}
}
#[cfg(feature = "svg")]
impl backend::Svg for Backend {
- fn viewport_dimensions(
- &self,
- handle: &iced_native::svg::Handle,
- ) -> Size<u32> {
+ fn viewport_dimensions(&self, handle: &core::svg::Handle) -> Size<u32> {
self.image_pipeline.viewport_dimensions(handle)
}
}
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs
index 11e8126f..59ec31fe 100644
--- a/wgpu/src/geometry.rs
+++ b/wgpu/src/geometry.rs
@@ -1,9 +1,9 @@
-use iced_graphics::geometry::fill::{self, Fill};
-use iced_graphics::geometry::{
+use crate::core::{Gradient, Point, Rectangle, Size, Vector};
+use crate::graphics::geometry::fill::{self, Fill};
+use crate::graphics::geometry::{
LineCap, LineDash, LineJoin, Path, Stroke, Style, Text,
};
-use iced_graphics::primitive::{self, Primitive};
-use iced_graphics::{Gradient, Point, Rectangle, Size, Vector};
+use crate::graphics::primitive::{self, Primitive};
use lyon::geom::euclid;
use lyon::tessellation;
diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs
index 2159a3ec..5eaa9a86 100644
--- a/wgpu/src/image.rs
+++ b/wgpu/src/image.rs
@@ -1,16 +1,17 @@
mod atlas;
-#[cfg(feature = "image")]
-use iced_graphics::image::raster;
-
-#[cfg(feature = "svg")]
-use iced_graphics::image::vector;
+use atlas::Atlas;
+use crate::core::{Rectangle, Size};
+use crate::graphics::Transformation;
use crate::layer;
-use crate::{Buffer, Transformation};
-use atlas::Atlas;
+use crate::Buffer;
+
+#[cfg(feature = "image")]
+use crate::graphics::image::raster;
-use iced_native::{Rectangle, Size};
+#[cfg(feature = "svg")]
+use crate::graphics::image::vector;
use std::cell::RefCell;
use std::mem;
@@ -18,10 +19,10 @@ use std::mem;
use bytemuck::{Pod, Zeroable};
#[cfg(feature = "image")]
-use iced_native::image;
+use crate::core::image;
#[cfg(feature = "svg")]
-use iced_native::svg;
+use crate::core::svg;
#[cfg(feature = "tracing")]
use tracing::info_span;
diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs
index 7df67abd..0a17ca33 100644
--- a/wgpu/src/image/atlas.rs
+++ b/wgpu/src/image/atlas.rs
@@ -12,8 +12,8 @@ use allocator::Allocator;
pub const SIZE: u32 = 2048;
-use iced_graphics::image;
-use iced_graphics::Size;
+use crate::core::Size;
+use crate::graphics::image;
use std::num::NonZeroU32;
diff --git a/wgpu/src/image/atlas/allocation.rs b/wgpu/src/image/atlas/allocation.rs
index 43aba875..11289771 100644
--- a/wgpu/src/image/atlas/allocation.rs
+++ b/wgpu/src/image/atlas/allocation.rs
@@ -1,7 +1,6 @@
+use crate::core::Size;
use crate::image::atlas::{self, allocator};
-use iced_graphics::Size;
-
#[derive(Debug)]
pub enum Allocation {
Partial {
diff --git a/wgpu/src/image/atlas/allocator.rs b/wgpu/src/image/atlas/allocator.rs
index 03effdcb..204a5c26 100644
--- a/wgpu/src/image/atlas/allocator.rs
+++ b/wgpu/src/image/atlas/allocator.rs
@@ -46,10 +46,10 @@ impl Region {
(rectangle.min.x as u32, rectangle.min.y as u32)
}
- pub fn size(&self) -> iced_graphics::Size<u32> {
+ pub fn size(&self) -> crate::core::Size<u32> {
let size = self.allocation.rectangle.size();
- iced_graphics::Size::new(size.width as u32, size.height as u32)
+ crate::core::Size::new(size.width as u32, size.height as u32)
}
}
diff --git a/wgpu/src/image/atlas/entry.rs b/wgpu/src/image/atlas/entry.rs
index 69c05a50..4b06bd95 100644
--- a/wgpu/src/image/atlas/entry.rs
+++ b/wgpu/src/image/atlas/entry.rs
@@ -1,8 +1,7 @@
+use crate::core::Size;
+use crate::graphics::image;
use crate::image::atlas;
-use iced_graphics::image;
-use iced_graphics::Size;
-
#[derive(Debug)]
pub enum Entry {
Contiguous(atlas::Allocation),
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index 69fcf899..cb9d5e2f 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -10,12 +10,9 @@ pub use mesh::Mesh;
pub use quad::Quad;
pub use text::Text;
-use crate::Primitive;
-
-use iced_graphics::alignment;
-use iced_graphics::{
- Background, Color, Font, Point, Rectangle, Size, Vector, Viewport,
-};
+use crate::core::alignment;
+use crate::core::{Background, Color, Font, Point, Rectangle, Size, Vector};
+use crate::graphics::{Primitive, Viewport};
/// A group of primitives that should be clipped together.
#[derive(Debug)]
diff --git a/wgpu/src/layer/image.rs b/wgpu/src/layer/image.rs
index 3eff2397..0de589f8 100644
--- a/wgpu/src/layer/image.rs
+++ b/wgpu/src/layer/image.rs
@@ -1,6 +1,6 @@
-use crate::{Color, Rectangle};
-
-use iced_native::{image, svg};
+use crate::core::image;
+use crate::core::svg;
+use crate::core::{Color, Rectangle};
/// A raster or vector image.
#[derive(Debug, Clone)]
diff --git a/wgpu/src/layer/mesh.rs b/wgpu/src/layer/mesh.rs
index 5c1e41ad..9dd14391 100644
--- a/wgpu/src/layer/mesh.rs
+++ b/wgpu/src/layer/mesh.rs
@@ -1,6 +1,6 @@
//! A collection of triangle primitives.
-use crate::primitive;
-use crate::{Gradient, Point, Rectangle};
+use crate::core::{Gradient, Point, Rectangle};
+use crate::graphics::primitive;
/// A mesh of triangles.
#[derive(Debug, Clone, Copy)]
diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs
index 38d62616..fdbdaafb 100644
--- a/wgpu/src/layer/text.rs
+++ b/wgpu/src/layer/text.rs
@@ -1,4 +1,5 @@
-use crate::{alignment, Color, Font, Rectangle};
+use crate::core::alignment;
+use crate::core::{Color, Font, Rectangle};
/// A paragraph of text.
#[derive(Debug, Clone, Copy)]
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs
index 4439b185..473f3621 100644
--- a/wgpu/src/lib.rs
+++ b/wgpu/src/lib.rs
@@ -50,25 +50,17 @@ mod quad;
mod text;
mod triangle;
-pub use iced_graphics::primitive;
-pub use iced_graphics::{
- Antialiasing, Color, Error, Font, Gradient, Point, Rectangle, Size, Vector,
- Viewport,
-};
-pub use iced_native::alignment;
+pub use iced_graphics as graphics;
+pub use iced_graphics::core;
-pub use iced_native::Theme;
pub use wgpu;
pub use backend::Backend;
pub use layer::Layer;
-pub use primitive::Primitive;
pub use settings::Settings;
use buffer::Buffer;
-use iced_graphics::Transformation;
-
#[cfg(any(feature = "image", feature = "svg"))]
mod image;
@@ -76,5 +68,4 @@ mod image;
///
/// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
/// [`iced`]: https://github.com/iced-rs/iced
-pub type Renderer<Theme = iced_native::Theme> =
- iced_graphics::Renderer<Backend, Theme>;
+pub type Renderer<Theme> = iced_graphics::Renderer<Backend, Theme>;
diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs
index 8a568968..b55216d7 100644
--- a/wgpu/src/quad.rs
+++ b/wgpu/src/quad.rs
@@ -1,7 +1,7 @@
+use crate::core::Rectangle;
+use crate::graphics::Transformation;
use crate::layer;
-use crate::{Buffer, Transformation};
-
-use iced_native::Rectangle;
+use crate::Buffer;
use bytemuck::{Pod, Zeroable};
use std::mem;
diff --git a/wgpu/src/settings.rs b/wgpu/src/settings.rs
index bd9cf473..7c0750ef 100644
--- a/wgpu/src/settings.rs
+++ b/wgpu/src/settings.rs
@@ -1,7 +1,6 @@
//! Configure a renderer.
-pub use crate::Antialiasing;
-
-use crate::Font;
+use crate::core::Font;
+use crate::graphics::Antialiasing;
/// The settings of a [`Backend`].
///
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index 0dc8a64c..d7a27f3a 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -1,10 +1,8 @@
+use crate::core::alignment;
+use crate::core::text::Hit;
+use crate::core::{Color, Font, Point, Rectangle, Size};
use crate::layer::Text;
-pub use iced_native::text::Hit;
-
-use iced_native::alignment;
-use iced_native::{Color, Font, Rectangle, Size};
-
use rustc_hash::{FxHashMap, FxHashSet};
use std::borrow::Cow;
use std::cell::RefCell;
@@ -269,9 +267,9 @@ impl Pipeline {
&self,
content: &str,
size: f32,
- font: iced_native::Font,
- bounds: iced_native::Size,
- point: iced_native::Point,
+ font: Font,
+ bounds: Size,
+ point: Point,
_nearest_only: bool,
) -> Option<Hit> {
self.system.as_ref().unwrap().with(|fields| {
diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs
index 706e4282..9fa521d7 100644
--- a/wgpu/src/triangle.rs
+++ b/wgpu/src/triangle.rs
@@ -2,11 +2,9 @@
mod msaa;
use crate::buffer::r#static::Buffer;
+use crate::core::{Gradient, Size};
+use crate::graphics::{Antialiasing, Transformation};
use crate::layer::mesh::{self, Mesh};
-use crate::settings;
-use crate::Transformation;
-
-use iced_graphics::Size;
#[cfg(feature = "tracing")]
use tracing::info_span;
@@ -137,7 +135,7 @@ impl Layer {
gradient_vertex_offset += written_bytes;
match gradient {
- iced_graphics::Gradient::Linear(linear) => {
+ Gradient::Linear(linear) => {
use glam::{IVec4, Vec4};
let start_offset = self.gradient.color_stop_offset;
@@ -319,7 +317,7 @@ impl Pipeline {
pub fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
- antialiasing: Option<settings::Antialiasing>,
+ antialiasing: Option<Antialiasing>,
) -> Pipeline {
Pipeline {
blit: antialiasing.map(|a| msaa::Blit::new(device, format, a)),
@@ -453,7 +451,7 @@ fn primitive_state() -> wgpu::PrimitiveState {
}
fn multisample_state(
- antialiasing: Option<settings::Antialiasing>,
+ antialiasing: Option<Antialiasing>,
) -> wgpu::MultisampleState {
wgpu::MultisampleState {
count: antialiasing.map(|a| a.sample_count()).unwrap_or(1),
@@ -465,11 +463,11 @@ fn multisample_state(
mod solid {
use crate::buffer::dynamic;
use crate::buffer::r#static::Buffer;
- use crate::settings;
+ use crate::graphics::primitive;
+ use crate::graphics::{Antialiasing, Transformation};
use crate::triangle;
+
use encase::ShaderType;
- use iced_graphics::primitive;
- use iced_graphics::Transformation;
#[derive(Debug)]
pub struct Pipeline {
@@ -550,7 +548,7 @@ mod solid {
pub fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
- antialiasing: Option<settings::Antialiasing>,
+ antialiasing: Option<Antialiasing>,
) -> Self {
let constants_layout = device.create_bind_group_layout(
&wgpu::BindGroupLayoutDescriptor {
@@ -633,7 +631,7 @@ mod solid {
mod gradient {
use crate::buffer::dynamic;
use crate::buffer::r#static::Buffer;
- use crate::settings;
+ use crate::graphics::Antialiasing;
use crate::triangle;
use encase::ShaderType;
@@ -755,7 +753,7 @@ mod gradient {
pub(super) fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
- antialiasing: Option<settings::Antialiasing>,
+ antialiasing: Option<Antialiasing>,
) -> Self {
let constants_layout = device.create_bind_group_layout(
&wgpu::BindGroupLayoutDescriptor {
diff --git a/wgpu/src/triangle/msaa.rs b/wgpu/src/triangle/msaa.rs
index a3016ff8..7144125c 100644
--- a/wgpu/src/triangle/msaa.rs
+++ b/wgpu/src/triangle/msaa.rs
@@ -1,4 +1,4 @@
-use crate::settings;
+use crate::graphics;
#[derive(Debug)]
pub struct Blit {
@@ -14,7 +14,7 @@ impl Blit {
pub fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
- antialiasing: settings::Antialiasing,
+ antialiasing: graphics::Antialiasing,
) -> Blit {
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
address_mode_u: wgpu::AddressMode::ClampToEdge,
diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs
index 3a4a7123..a67ac3c0 100644
--- a/wgpu/src/window/compositor.rs
+++ b/wgpu/src/window/compositor.rs
@@ -1,10 +1,12 @@
//! Connect a window with a renderer.
-use crate::{Backend, Color, Error, Primitive, Renderer, Settings, Viewport};
+use crate::core::Color;
+use crate::graphics;
+use crate::graphics::compositor;
+use crate::graphics::{Error, Primitive, Viewport};
+use crate::{Backend, Renderer, Settings};
use futures::stream::{self, StreamExt};
-use iced_graphics::window::compositor;
-use iced_native::futures;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use std::marker::PhantomData;
@@ -184,7 +186,7 @@ pub fn present<Theme, T: AsRef<str>>(
}
}
-impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
+impl<Theme> graphics::Compositor for Compositor<Theme> {
type Settings = Settings;
type Renderer = Renderer<Theme>;
type Surface = wgpu::Surface;
diff --git a/widget/Cargo.toml b/widget/Cargo.toml
new file mode 100644
index 00000000..fb617079
--- /dev/null
+++ b/widget/Cargo.toml
@@ -0,0 +1,37 @@
+[package]
+name = "iced_widget"
+version = "0.1.0"
+edition = "2021"
+
+[features]
+lazy = ["ouroboros"]
+image = ["iced_renderer/image"]
+svg = ["iced_renderer/svg"]
+canvas = ["iced_renderer/geometry"]
+qr_code = ["canvas", "qrcode"]
+
+[dependencies]
+unicode-segmentation = "1.6"
+num-traits = "0.2"
+thiserror = "1"
+
+[dependencies.iced_native]
+version = "0.9"
+path = "../native"
+
+[dependencies.iced_renderer]
+version = "0.1"
+path = "../renderer"
+
+[dependencies.iced_style]
+version = "0.7"
+path = "../style"
+
+[dependencies.ouroboros]
+version = "0.13"
+optional = true
+
+[dependencies.qrcode]
+version = "0.12"
+optional = true
+default-features = false
diff --git a/native/src/widget/button.rs b/widget/src/button.rs
index 39387173..d6fd3997 100644
--- a/native/src/widget/button.rs
+++ b/widget/src/button.rs
@@ -1,15 +1,15 @@
//! Allow your users to perform actions by pressing a button.
//!
//! A [`Button`] has some local [`State`].
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::touch;
-use crate::widget::tree::{self, Tree};
-use crate::widget::Operation;
-use crate::{
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::touch;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::widget::Operation;
+use crate::core::{
Background, Clipboard, Color, Element, Layout, Length, Padding, Point,
Rectangle, Shell, Vector, Widget,
};
@@ -20,7 +20,7 @@ pub use iced_style::button::{Appearance, StyleSheet};
///
/// ```
/// # type Button<'a, Message> =
-/// # iced_native::widget::Button<'a, Message, iced_native::renderer::Null>;
+/// # iced_widget::Button<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// #[derive(Clone)]
/// enum Message {
@@ -35,7 +35,7 @@ pub use iced_style::button::{Appearance, StyleSheet};
///
/// ```
/// # type Button<'a, Message> =
-/// # iced_native::widget::Button<'a, Message, iced_native::renderer::Null>;
+/// # iced_widget::Button<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// #[derive(Clone)]
/// enum Message {
@@ -51,9 +51,9 @@ pub use iced_style::button::{Appearance, StyleSheet};
/// }
/// ```
#[allow(missing_debug_implementations)]
-pub struct Button<'a, Message, Renderer>
+pub struct Button<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
content: Element<'a, Message, Renderer>,
@@ -66,7 +66,7 @@ where
impl<'a, Message, Renderer> Button<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Button`] with the given content.
@@ -121,7 +121,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
for Button<'a, Message, Renderer>
where
Message: 'a + Clone,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn tag(&self) -> tree::Tag {
@@ -279,7 +279,7 @@ impl<'a, Message, Renderer> From<Button<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: Clone + 'a,
- Renderer: crate::Renderer + 'a,
+ Renderer: crate::core::Renderer + 'a,
Renderer::Theme: StyleSheet,
{
fn from(button: Button<'a, Message, Renderer>) -> Self {
@@ -355,7 +355,7 @@ pub fn update<'a, Message: Clone>(
}
/// Draws a [`Button`].
-pub fn draw<'a, Renderer: crate::Renderer>(
+pub fn draw<'a, Renderer: crate::core::Renderer>(
renderer: &mut Renderer,
bounds: Rectangle,
cursor_position: Point,
diff --git a/src/widget/canvas.rs b/widget/src/canvas.rs
index bc5995c6..171c4534 100644
--- a/src/widget/canvas.rs
+++ b/widget/src/canvas.rs
@@ -8,15 +8,17 @@ pub use cursor::Cursor;
pub use event::Event;
pub use program::Program;
-pub use iced_renderer::geometry::*;
-
-use crate::{Length, Point, Rectangle, Size, Vector};
-
-use iced_native::layout::{self, Layout};
-use iced_native::mouse;
-use iced_native::renderer;
-use iced_native::widget::tree::{self, Tree};
-use iced_native::{Clipboard, Element, Shell, Widget};
+pub use crate::graphics::geometry::*;
+pub use crate::renderer::geometry::*;
+
+use crate::core;
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{Clipboard, Element, Shell, Widget};
+use crate::core::{Length, Point, Rectangle, Size, Vector};
+use crate::graphics::geometry;
use std::marker::PhantomData;
@@ -26,9 +28,11 @@ use std::marker::PhantomData;
/// If you want to get a quick overview, here's how we can draw a simple circle:
///
/// ```no_run
-/// use iced::widget::canvas::{self, Canvas, Cursor, Fill, Frame, Geometry, Path, Program};
-/// use iced::{Color, Rectangle, Theme, Renderer};
-///
+/// # use iced_widget::canvas::{self, Canvas, Cursor, Fill, Frame, Geometry, Path, Program};
+/// # use iced_widget::core::{Color, Rectangle};
+/// # use iced_widget::style::Theme;
+/// #
+/// # pub type Renderer = iced_widget::renderer::Renderer<Theme>;
/// // First, we define the data we need for drawing
/// #[derive(Debug)]
/// struct Circle {
@@ -60,7 +64,7 @@ use std::marker::PhantomData;
#[derive(Debug)]
pub struct Canvas<P, Message, Renderer = crate::Renderer>
where
- Renderer: iced_renderer::geometry::Renderer,
+ Renderer: geometry::Renderer,
P: Program<Message, Renderer>,
{
width: Length,
@@ -72,7 +76,7 @@ where
impl<P, Message, Renderer> Canvas<P, Message, Renderer>
where
- Renderer: iced_renderer::geometry::Renderer,
+ Renderer: geometry::Renderer,
P: Program<Message, Renderer>,
{
const DEFAULT_SIZE: f32 = 100.0;
@@ -104,7 +108,7 @@ where
impl<P, Message, Renderer> Widget<Message, Renderer>
for Canvas<P, Message, Renderer>
where
- Renderer: iced_renderer::geometry::Renderer,
+ Renderer: geometry::Renderer,
P: Program<Message, Renderer>,
{
fn tag(&self) -> tree::Tag {
@@ -138,7 +142,7 @@ where
fn on_event(
&mut self,
tree: &mut Tree,
- event: iced_native::Event,
+ event: core::Event,
layout: Layout<'_>,
cursor_position: Point,
_renderer: &Renderer,
@@ -148,13 +152,9 @@ where
let bounds = layout.bounds();
let canvas_event = match event {
- iced_native::Event::Mouse(mouse_event) => {
- Some(Event::Mouse(mouse_event))
- }
- iced_native::Event::Touch(touch_event) => {
- Some(Event::Touch(touch_event))
- }
- iced_native::Event::Keyboard(keyboard_event) => {
+ core::Event::Mouse(mouse_event) => Some(Event::Mouse(mouse_event)),
+ core::Event::Touch(touch_event) => Some(Event::Touch(touch_event)),
+ core::Event::Keyboard(keyboard_event) => {
Some(Event::Keyboard(keyboard_event))
}
_ => None,
@@ -227,7 +227,7 @@ impl<'a, P, Message, Renderer> From<Canvas<P, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + iced_renderer::geometry::Renderer,
+ Renderer: 'a + geometry::Renderer,
P: Program<Message, Renderer> + 'a,
{
fn from(
diff --git a/src/widget/canvas/cursor.rs b/widget/src/canvas/cursor.rs
index ef6a7771..5a65e9a7 100644
--- a/src/widget/canvas/cursor.rs
+++ b/widget/src/canvas/cursor.rs
@@ -1,4 +1,4 @@
-use crate::{Point, Rectangle};
+use crate::core::{Point, Rectangle};
/// The mouse cursor state.
#[derive(Debug, Clone, Copy, PartialEq)]
diff --git a/src/widget/canvas/event.rs b/widget/src/canvas/event.rs
index 7c733a4d..4508c184 100644
--- a/src/widget/canvas/event.rs
+++ b/widget/src/canvas/event.rs
@@ -1,9 +1,9 @@
//! Handle events of a canvas.
-use iced_native::keyboard;
-use iced_native::mouse;
-use iced_native::touch;
+use crate::core::keyboard;
+use crate::core::mouse;
+use crate::core::touch;
-pub use iced_native::event::Status;
+pub use crate::core::event::Status;
/// A [`Canvas`] event.
///
diff --git a/src/widget/canvas/program.rs b/widget/src/canvas/program.rs
index fd15663a..efb33c56 100644
--- a/src/widget/canvas/program.rs
+++ b/widget/src/canvas/program.rs
@@ -1,7 +1,8 @@
-use crate::widget::canvas::event::{self, Event};
-use crate::widget::canvas::mouse;
-use crate::widget::canvas::Cursor;
-use crate::Rectangle;
+use crate::canvas::event::{self, Event};
+use crate::canvas::mouse;
+use crate::canvas::Cursor;
+use crate::core::Rectangle;
+use crate::graphics::geometry;
/// The state and logic of a [`Canvas`].
///
@@ -11,7 +12,7 @@ use crate::Rectangle;
/// [`Canvas`]: crate::widget::Canvas
pub trait Program<Message, Renderer = crate::Renderer>
where
- Renderer: iced_renderer::geometry::Renderer,
+ Renderer: geometry::Renderer,
{
/// The internal state mutated by the [`Program`].
type State: Default + 'static;
@@ -71,7 +72,7 @@ where
impl<Message, Renderer, T> Program<Message, Renderer> for &T
where
- Renderer: iced_renderer::geometry::Renderer,
+ Renderer: geometry::Renderer,
T: Program<Message, Renderer>,
{
type State = T::State;
diff --git a/native/src/widget/checkbox.rs b/widget/src/checkbox.rs
index cd8b9c6b..6a062f94 100644
--- a/native/src/widget/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -1,16 +1,17 @@
//! Show toggle controls using checkboxes.
-use crate::alignment;
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::text;
-use crate::touch;
-use crate::widget::{self, Row, Text, Tree};
-use crate::{
+use crate::core::alignment;
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::text;
+use crate::core::touch;
+use crate::core::widget::Tree;
+use crate::core::{
Alignment, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle,
Shell, Widget,
};
+use crate::{Row, Text};
pub use iced_style::checkbox::{Appearance, StyleSheet};
@@ -30,7 +31,8 @@ pub struct Icon<Font> {
/// # Example
///
/// ```
-/// # type Checkbox<'a, Message> = iced_native::widget::Checkbox<'a, Message, iced_native::renderer::Null>;
+/// # type Checkbox<'a, Message> =
+/// # iced_widget::Checkbox<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// pub enum Message {
/// CheckboxToggled(bool),
@@ -43,10 +45,10 @@ pub struct Icon<Font> {
///
/// ![Checkbox drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/checkbox.png?raw=true)
#[allow(missing_debug_implementations)]
-pub struct Checkbox<'a, Message, Renderer>
+pub struct Checkbox<'a, Message, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
is_checked: bool,
on_toggle: Box<dyn Fn(bool) -> Message + 'a>,
@@ -63,7 +65,7 @@ where
impl<'a, Message, Renderer> Checkbox<'a, Message, Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
/// The default size of a [`Checkbox`].
const DEFAULT_SIZE: f32 = 20.0;
@@ -153,7 +155,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
for Checkbox<'a, Message, Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn width(&self) -> Length {
self.width
@@ -289,14 +291,14 @@ where
{
let label_layout = children.next().unwrap();
- widget::text::draw(
+ crate::text::draw(
renderer,
style,
label_layout,
&self.label,
self.text_size,
self.font,
- widget::text::Appearance {
+ crate::text::Appearance {
color: custom_style.text_color,
},
alignment::Horizontal::Left,
@@ -311,7 +313,7 @@ impl<'a, Message, Renderer> From<Checkbox<'a, Message, Renderer>>
where
Message: 'a,
Renderer: 'a + text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn from(
checkbox: Checkbox<'a, Message, Renderer>,
diff --git a/native/src/widget/column.rs b/widget/src/column.rs
index ebe579d5..8f363ec6 100644
--- a/native/src/widget/column.rs
+++ b/widget/src/column.rs
@@ -1,18 +1,18 @@
//! Distribute content vertically.
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::widget::{Operation, Tree};
-use crate::{
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::{Operation, Tree};
+use crate::core::{
Alignment, Clipboard, Element, Layout, Length, Padding, Pixels, Point,
Rectangle, Shell, Widget,
};
/// A container that distributes its contents vertically.
#[allow(missing_debug_implementations)]
-pub struct Column<'a, Message, Renderer> {
+pub struct Column<'a, Message, Renderer = crate::Renderer> {
spacing: f32,
padding: Padding,
width: Length,
@@ -102,7 +102,7 @@ impl<'a, Message, Renderer> Default for Column<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Column<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
{
fn children(&self) -> Vec<Tree> {
self.children.iter().map(Tree::new).collect()
@@ -256,7 +256,7 @@ impl<'a, Message, Renderer> From<Column<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: crate::Renderer + 'a,
+ Renderer: crate::core::Renderer + 'a,
{
fn from(column: Column<'a, Message, Renderer>) -> Self {
Self::new(column)
diff --git a/native/src/widget/container.rs b/widget/src/container.rs
index b77bf50d..9d932772 100644
--- a/native/src/widget/container.rs
+++ b/widget/src/container.rs
@@ -1,12 +1,12 @@
//! Decorate content and apply alignment.
-use crate::alignment::{self, Alignment};
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::widget::{self, Operation, Tree};
-use crate::{
+use crate::core::alignment::{self, Alignment};
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::{self, Operation, Tree};
+use crate::core::{
Background, Clipboard, Color, Element, Layout, Length, Padding, Pixels,
Point, Rectangle, Shell, Widget,
};
@@ -17,9 +17,9 @@ pub use iced_style::container::{Appearance, StyleSheet};
///
/// It is normally used for alignment purposes.
#[allow(missing_debug_implementations)]
-pub struct Container<'a, Message, Renderer>
+pub struct Container<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
id: Option<Id>,
@@ -36,7 +36,7 @@ where
impl<'a, Message, Renderer> Container<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates an empty [`Container`].
@@ -131,7 +131,7 @@ where
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Container<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn children(&self) -> Vec<Tree> {
@@ -276,7 +276,7 @@ impl<'a, Message, Renderer> From<Container<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(
@@ -326,7 +326,7 @@ pub fn draw_background<Renderer>(
appearance: &Appearance,
bounds: Rectangle,
) where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
{
if appearance.background.is_some() || appearance.border_width > 0.0 {
renderer.fill_quad(
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs
new file mode 100644
index 00000000..1a73c16f
--- /dev/null
+++ b/widget/src/helpers.rs
@@ -0,0 +1,362 @@
+//! Helper functions to create pure widgets.
+use crate::button::{self, Button};
+use crate::checkbox::{self, Checkbox};
+use crate::container::{self, Container};
+use crate::core;
+use crate::core::widget::operation;
+use crate::core::{Element, Length, Pixels};
+use crate::native::Command;
+use crate::overlay;
+use crate::pick_list::{self, PickList};
+use crate::progress_bar::{self, ProgressBar};
+use crate::radio::{self, Radio};
+use crate::rule::{self, Rule};
+use crate::scrollable::{self, Scrollable};
+use crate::slider::{self, Slider};
+use crate::text::{self, Text};
+use crate::text_input::{self, TextInput};
+use crate::toggler::{self, Toggler};
+use crate::tooltip::{self, Tooltip};
+use crate::{Column, Row, Space, VerticalSlider};
+
+use std::borrow::Cow;
+use std::ops::RangeInclusive;
+
+/// Creates a [`Column`] with the given children.
+///
+/// [`Column`]: widget::Column
+#[macro_export]
+macro_rules! column {
+ () => (
+ $crate::Column::new()
+ );
+ ($($x:expr),+ $(,)?) => (
+ $crate::Column::with_children(vec![$($crate::core::Element::from($x)),+])
+ );
+}
+
+/// Creates a [`Row`] with the given children.
+///
+/// [`Row`]: widget::Row
+#[macro_export]
+macro_rules! row {
+ () => (
+ $crate::Row::new()
+ );
+ ($($x:expr),+ $(,)?) => (
+ $crate::Row::with_children(vec![$($crate::core::Element::from($x)),+])
+ );
+}
+
+/// Creates a new [`Container`] with the provided content.
+///
+/// [`Container`]: widget::Container
+pub fn container<'a, Message, Renderer>(
+ content: impl Into<Element<'a, Message, Renderer>>,
+) -> Container<'a, Message, Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: container::StyleSheet,
+{
+ Container::new(content)
+}
+
+/// Creates a new [`Column`] with the given children.
+///
+/// [`Column`]: widget::Column
+pub fn column<Message, Renderer>(
+ children: Vec<Element<'_, Message, Renderer>>,
+) -> Column<'_, Message, Renderer> {
+ Column::with_children(children)
+}
+
+/// Creates a new [`Row`] with the given children.
+///
+/// [`Row`]: widget::Row
+pub fn row<Message, Renderer>(
+ children: Vec<Element<'_, Message, Renderer>>,
+) -> Row<'_, Message, Renderer> {
+ Row::with_children(children)
+}
+
+/// Creates a new [`Scrollable`] with the provided content.
+///
+/// [`Scrollable`]: widget::Scrollable
+pub fn scrollable<'a, Message, Renderer>(
+ content: impl Into<Element<'a, Message, Renderer>>,
+) -> Scrollable<'a, Message, Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: scrollable::StyleSheet,
+{
+ Scrollable::new(content)
+}
+
+/// Creates a new [`Button`] with the provided content.
+///
+/// [`Button`]: widget::Button
+pub fn button<'a, Message, Renderer>(
+ content: impl Into<Element<'a, Message, Renderer>>,
+) -> Button<'a, Message, Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: button::StyleSheet,
+ <Renderer::Theme as button::StyleSheet>::Style: Default,
+{
+ Button::new(content)
+}
+
+/// Creates a new [`Tooltip`] with the provided content, tooltip text, and [`tooltip::Position`].
+///
+/// [`Tooltip`]: widget::Tooltip
+/// [`tooltip::Position`]: widget::tooltip::Position
+pub fn tooltip<'a, Message, Renderer>(
+ content: impl Into<Element<'a, Message, Renderer>>,
+ tooltip: impl ToString,
+ position: tooltip::Position,
+) -> crate::Tooltip<'a, Message, Renderer>
+where
+ Renderer: core::text::Renderer,
+ Renderer::Theme: container::StyleSheet + text::StyleSheet,
+{
+ Tooltip::new(content, tooltip.to_string(), position)
+}
+
+/// Creates a new [`Text`] widget with the provided content.
+///
+/// [`Text`]: widget::Text
+pub fn text<'a, Renderer>(text: impl ToString) -> Text<'a, Renderer>
+where
+ Renderer: core::text::Renderer,
+ Renderer::Theme: text::StyleSheet,
+{
+ Text::new(text.to_string())
+}
+
+/// Creates a new [`Checkbox`].
+///
+/// [`Checkbox`]: widget::Checkbox
+pub fn checkbox<'a, Message, Renderer>(
+ label: impl Into<String>,
+ is_checked: bool,
+ f: impl Fn(bool) -> Message + 'a,
+) -> Checkbox<'a, Message, Renderer>
+where
+ Renderer: core::text::Renderer,
+ Renderer::Theme: checkbox::StyleSheet + text::StyleSheet,
+{
+ Checkbox::new(label, is_checked, f)
+}
+
+/// Creates a new [`Radio`].
+///
+/// [`Radio`]: widget::Radio
+pub fn radio<Message, Renderer, V>(
+ label: impl Into<String>,
+ value: V,
+ selected: Option<V>,
+ on_click: impl FnOnce(V) -> Message,
+) -> Radio<Message, Renderer>
+where
+ Message: Clone,
+ Renderer: core::text::Renderer,
+ Renderer::Theme: radio::StyleSheet,
+ V: Copy + Eq,
+{
+ Radio::new(value, label, selected, on_click)
+}
+
+/// Creates a new [`Toggler`].
+///
+/// [`Toggler`]: widget::Toggler
+pub fn toggler<'a, Message, Renderer>(
+ label: impl Into<Option<String>>,
+ is_checked: bool,
+ f: impl Fn(bool) -> Message + 'a,
+) -> Toggler<'a, Message, Renderer>
+where
+ Renderer: core::text::Renderer,
+ Renderer::Theme: toggler::StyleSheet,
+{
+ Toggler::new(label, is_checked, f)
+}
+
+/// Creates a new [`TextInput`].
+///
+/// [`TextInput`]: widget::TextInput
+pub fn text_input<'a, Message, Renderer>(
+ placeholder: &str,
+ value: &str,
+ on_change: impl Fn(String) -> Message + 'a,
+) -> TextInput<'a, Message, Renderer>
+where
+ Message: Clone,
+ Renderer: core::text::Renderer,
+ Renderer::Theme: text_input::StyleSheet,
+{
+ TextInput::new(placeholder, value, on_change)
+}
+
+/// Creates a new [`Slider`].
+///
+/// [`Slider`]: widget::Slider
+pub fn slider<'a, T, Message, Renderer>(
+ range: std::ops::RangeInclusive<T>,
+ value: T,
+ on_change: impl Fn(T) -> Message + 'a,
+) -> Slider<'a, T, Message, Renderer>
+where
+ T: Copy + From<u8> + std::cmp::PartialOrd,
+ Message: Clone,
+ Renderer: core::Renderer,
+ Renderer::Theme: slider::StyleSheet,
+{
+ Slider::new(range, value, on_change)
+}
+
+/// Creates a new [`VerticalSlider`].
+///
+/// [`VerticalSlider`]: widget::VerticalSlider
+pub fn vertical_slider<'a, T, Message, Renderer>(
+ range: std::ops::RangeInclusive<T>,
+ value: T,
+ on_change: impl Fn(T) -> Message + 'a,
+) -> VerticalSlider<'a, T, Message, Renderer>
+where
+ T: Copy + From<u8> + std::cmp::PartialOrd,
+ Message: Clone,
+ Renderer: core::Renderer,
+ Renderer::Theme: slider::StyleSheet,
+{
+ VerticalSlider::new(range, value, on_change)
+}
+
+/// Creates a new [`PickList`].
+///
+/// [`PickList`]: widget::PickList
+pub fn pick_list<'a, Message, Renderer, T>(
+ options: impl Into<Cow<'a, [T]>>,
+ selected: Option<T>,
+ on_selected: impl Fn(T) -> Message + 'a,
+) -> PickList<'a, T, Message, Renderer>
+where
+ T: ToString + Eq + 'static,
+ [T]: ToOwned<Owned = Vec<T>>,
+ Renderer: core::text::Renderer,
+ Renderer::Theme: pick_list::StyleSheet
+ + scrollable::StyleSheet
+ + overlay::menu::StyleSheet
+ + container::StyleSheet,
+ <Renderer::Theme as overlay::menu::StyleSheet>::Style:
+ From<<Renderer::Theme as pick_list::StyleSheet>::Style>,
+{
+ PickList::new(options, selected, on_selected)
+}
+
+/// Creates a new horizontal [`Space`] with the given [`Length`].
+///
+/// [`Space`]: widget::Space
+pub fn horizontal_space(width: impl Into<Length>) -> Space {
+ Space::with_width(width)
+}
+
+/// Creates a new vertical [`Space`] with the given [`Length`].
+///
+/// [`Space`]: widget::Space
+pub fn vertical_space(height: impl Into<Length>) -> Space {
+ Space::with_height(height)
+}
+
+/// Creates a horizontal [`Rule`] with the given height.
+///
+/// [`Rule`]: widget::Rule
+pub fn horizontal_rule<Renderer>(height: impl Into<Pixels>) -> Rule<Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: rule::StyleSheet,
+{
+ Rule::horizontal(height)
+}
+
+/// Creates a vertical [`Rule`] with the given width.
+///
+/// [`Rule`]: widget::Rule
+pub fn vertical_rule<Renderer>(width: impl Into<Pixels>) -> Rule<Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: rule::StyleSheet,
+{
+ Rule::vertical(width)
+}
+
+/// Creates a new [`ProgressBar`].
+///
+/// It expects:
+/// * an inclusive range of possible values, and
+/// * the current value of the [`ProgressBar`].
+///
+/// [`ProgressBar`]: widget::ProgressBar
+pub fn progress_bar<Renderer>(
+ range: RangeInclusive<f32>,
+ value: f32,
+) -> ProgressBar<Renderer>
+where
+ Renderer: core::Renderer,
+ Renderer::Theme: progress_bar::StyleSheet,
+{
+ ProgressBar::new(range, value)
+}
+
+/// Creates a new [`Image`].
+///
+/// [`Image`]: widget::Image
+#[cfg(feature = "image")]
+#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
+pub fn image<Handle>(handle: impl Into<Handle>) -> crate::Image<Handle> {
+ crate::Image::new(handle.into())
+}
+
+/// Creates a new [`Svg`] widget from the given [`Handle`].
+///
+/// [`Svg`]: widget::Svg
+/// [`Handle`]: widget::svg::Handle
+#[cfg(feature = "svg")]
+#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
+pub fn svg<Renderer>(
+ handle: impl Into<core::svg::Handle>,
+) -> crate::Svg<Renderer>
+where
+ Renderer: core::svg::Renderer,
+ Renderer::Theme: crate::svg::StyleSheet,
+{
+ crate::Svg::new(handle)
+}
+
+/// Creates a new [`Canvas`].
+#[cfg(feature = "canvas")]
+#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
+pub fn canvas<P, Message, Renderer>(
+ program: P,
+) -> crate::Canvas<P, Message, Renderer>
+where
+ Renderer: crate::graphics::geometry::Renderer,
+ P: crate::canvas::Program<Message, Renderer>,
+{
+ crate::Canvas::new(program)
+}
+
+/// Focuses the previous focusable widget.
+pub fn focus_previous<Message>() -> Command<Message>
+where
+ Message: 'static,
+{
+ Command::widget(operation::focusable::focus_previous())
+}
+
+/// Focuses the next focusable widget.
+pub fn focus_next<Message>() -> Command<Message>
+where
+ Message: 'static,
+{
+ Command::widget(operation::focusable::focus_next())
+}
diff --git a/native/src/widget/image.rs b/widget/src/image.rs
index 73257a74..22a3a1a1 100644
--- a/native/src/widget/image.rs
+++ b/widget/src/image.rs
@@ -2,16 +2,18 @@
pub mod viewer;
pub use viewer::Viewer;
-use crate::image;
-use crate::layout;
-use crate::renderer;
-use crate::widget::Tree;
-use crate::{
+use crate::core::image;
+use crate::core::layout;
+use crate::core::renderer;
+use crate::core::widget::Tree;
+use crate::core::{
ContentFit, Element, Layout, Length, Point, Rectangle, Size, Vector, Widget,
};
use std::hash::Hash;
+pub use image::Handle;
+
/// Creates a new [`Viewer`] with the given image `Handle`.
pub fn viewer<Handle>(handle: Handle) -> Viewer<Handle> {
Viewer::new(handle)
@@ -22,8 +24,7 @@ pub fn viewer<Handle>(handle: Handle) -> Viewer<Handle> {
/// # Example
///
/// ```
-/// # use iced_native::widget::Image;
-/// # use iced_native::image;
+/// # use iced_widget::image::{self, Image};
/// #
/// let image = Image::<image::Handle>::new("resources/ferris.png");
/// ```
diff --git a/native/src/widget/image/viewer.rs b/widget/src/image/viewer.rs
index 1f8d5d7a..0d60d818 100644
--- a/native/src/widget/image/viewer.rs
+++ b/widget/src/image/viewer.rs
@@ -1,11 +1,11 @@
//! Zoom and pan on an image.
-use crate::event::{self, Event};
-use crate::image;
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::widget::tree::{self, Tree};
-use crate::{
+use crate::core::event::{self, Event};
+use crate::core::image;
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size,
Vector, Widget,
};
diff --git a/lazy/src/lazy.rs b/widget/src/lazy.rs
index 5e909a49..b08ed8cb 100644
--- a/lazy/src/lazy.rs
+++ b/widget/src/lazy.rs
@@ -1,12 +1,25 @@
-use iced_native::event;
-use iced_native::layout::{self, Layout};
-use iced_native::mouse;
-use iced_native::overlay;
-use iced_native::renderer;
-use iced_native::widget::tree::{self, Tree};
-use iced_native::widget::{self, Widget};
-use iced_native::Element;
-use iced_native::{Clipboard, Hasher, Length, Point, Rectangle, Shell, Size};
+#![allow(clippy::await_holding_refcell_ref, clippy::type_complexity)]
+pub(crate) mod helpers;
+
+pub mod component;
+pub mod responsive;
+
+pub use component::Component;
+pub use responsive::Responsive;
+
+mod cache;
+
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::widget::{self, Widget};
+use crate::core::Element;
+use crate::core::{
+ self, Clipboard, Hasher, Length, Point, Rectangle, Shell, Size,
+};
use ouroboros::self_referencing;
use std::cell::RefCell;
@@ -41,7 +54,7 @@ where
fn with_element<T>(
&self,
- f: impl FnOnce(&Element<Message, Renderer>) -> T,
+ f: impl FnOnce(&Element<'_, Message, Renderer>) -> T,
) -> T {
f(self
.element
@@ -55,7 +68,7 @@ where
fn with_element_mut<T>(
&self,
- f: impl FnOnce(&mut Element<Message, Renderer>) -> T,
+ f: impl FnOnce(&mut Element<'_, Message, Renderer>) -> T,
) -> T {
f(self
.element
@@ -79,7 +92,7 @@ where
View: Into<Element<'static, Message, Renderer>> + 'static,
Dependency: Hash + 'a,
Message: 'static,
- Renderer: iced_native::Renderer + 'static,
+ Renderer: core::Renderer + 'static,
{
fn tag(&self) -> tree::Tag {
struct Tag<T>(T);
@@ -163,7 +176,7 @@ where
fn on_event(
&mut self,
tree: &mut Tree,
- event: iced_native::Event,
+ event: Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
@@ -304,7 +317,7 @@ impl<'a, Message, Renderer> Overlay<'a, Message, Renderer> {
impl<'a, Message, Renderer> overlay::Overlay<Message, Renderer>
for Overlay<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
fn layout(
&self,
@@ -353,7 +366,7 @@ where
fn on_event(
&mut self,
- event: iced_native::Event,
+ event: Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
@@ -370,7 +383,7 @@ where
shell,
)
})
- .unwrap_or(iced_native::event::Status::Ignored)
+ .unwrap_or(event::Status::Ignored)
}
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
@@ -386,7 +399,7 @@ impl<'a, Message, Renderer, Dependency, View>
for Element<'a, Message, Renderer>
where
View: Into<Element<'static, Message, Renderer>> + 'static,
- Renderer: iced_native::Renderer + 'static,
+ Renderer: core::Renderer + 'static,
Message: 'static,
Dependency: Hash + 'a,
{
diff --git a/lazy/src/cache.rs b/widget/src/lazy/cache.rs
index 5b4a39f6..e7b87614 100644
--- a/lazy/src/cache.rs
+++ b/widget/src/lazy/cache.rs
@@ -1,5 +1,5 @@
-use iced_native::overlay;
-use iced_native::Element;
+use crate::core::overlay;
+use crate::core::Element;
use ouroboros::self_referencing;
diff --git a/lazy/src/component.rs b/widget/src/lazy/component.rs
index b23da9f7..0b8070af 100644
--- a/lazy/src/component.rs
+++ b/widget/src/lazy/component.rs
@@ -1,13 +1,13 @@
//! Build and reuse custom widgets using The Elm Architecture.
-use iced_native::event;
-use iced_native::layout::{self, Layout};
-use iced_native::mouse;
-use iced_native::overlay;
-use iced_native::renderer;
-use iced_native::widget;
-use iced_native::widget::tree::{self, Tree};
-use iced_native::{
- Clipboard, Element, Length, Point, Rectangle, Shell, Size, Widget,
+use crate::core::event;
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
+ self, Clipboard, Element, Length, Point, Rectangle, Shell, Size, Widget,
};
use ouroboros::self_referencing;
@@ -67,7 +67,7 @@ where
C: Component<Message, Renderer> + 'a,
C::State: 'static,
Message: 'a,
- Renderer: iced_native::Renderer + 'a,
+ Renderer: core::Renderer + 'a,
{
Element::new(Instance {
state: RefCell::new(Some(
@@ -159,7 +159,7 @@ impl<'a, Message, Renderer, Event, S> Widget<Message, Renderer>
for Instance<'a, Message, Renderer, Event, S>
where
S: 'static + Default,
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
fn tag(&self) -> tree::Tag {
struct Tag<T>(T);
@@ -203,7 +203,7 @@ where
fn on_event(
&mut self,
tree: &mut Tree,
- event: iced_native::Event,
+ event: core::Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
@@ -447,7 +447,7 @@ impl<'a, 'b, Message, Renderer, Event, S>
impl<'a, 'b, Message, Renderer, Event, S> overlay::Overlay<Message, Renderer>
for OverlayInstance<'a, 'b, Message, Renderer, Event, S>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
S: 'static + Default,
{
fn layout(
@@ -497,13 +497,13 @@ where
fn on_event(
&mut self,
- event: iced_native::Event,
+ event: core::Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
- ) -> iced_native::event::Status {
+ ) -> event::Status {
let mut local_messages = Vec::new();
let mut local_shell = Shell::new(&mut local_messages);
@@ -518,7 +518,7 @@ where
&mut local_shell,
)
})
- .unwrap_or(iced_native::event::Status::Ignored);
+ .unwrap_or(event::Status::Ignored);
local_shell.revalidate_layout(|| shell.invalidate_layout());
diff --git a/lazy/src/lib.rs b/widget/src/lazy/helpers.rs
index 41a28773..be60bb78 100644
--- a/lazy/src/lib.rs
+++ b/widget/src/lazy/helpers.rs
@@ -1,34 +1,7 @@
-#![doc(
- html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
-)]
-#![deny(
- missing_debug_implementations,
- unused_results,
- clippy::extra_unused_lifetimes,
- clippy::from_over_into,
- clippy::needless_borrow,
- clippy::new_without_default,
- clippy::useless_conversion
-)]
-#![forbid(unsafe_code)]
-#![allow(
- clippy::await_holding_refcell_ref,
- clippy::inherent_to_string,
- clippy::type_complexity
-)]
-#![cfg_attr(docsrs, feature(doc_cfg))]
-mod lazy;
+use crate::core::{self, Element, Size};
+use crate::lazy::component::{self, Component};
+use crate::lazy::{Lazy, Responsive};
-pub mod component;
-pub mod responsive;
-
-pub use component::Component;
-pub use lazy::Lazy;
-pub use responsive::Responsive;
-
-mod cache;
-
-use iced_native::{Element, Size};
use std::hash::Hash;
pub fn lazy<'a, Message, Renderer, Dependency, View>(
@@ -51,7 +24,7 @@ where
C: Component<Message, Renderer> + 'a,
C::State: 'static,
Message: 'a,
- Renderer: iced_native::Renderer + 'a,
+ Renderer: core::Renderer + 'a,
{
component::view(component)
}
@@ -60,7 +33,7 @@ pub fn responsive<'a, Message, Renderer>(
f: impl Fn(Size) -> Element<'a, Message, Renderer> + 'a,
) -> Responsive<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
Responsive::new(f)
}
diff --git a/lazy/src/responsive.rs b/widget/src/lazy/responsive.rs
index 57c07de1..7b2fc37c 100644
--- a/lazy/src/responsive.rs
+++ b/widget/src/lazy/responsive.rs
@@ -1,13 +1,14 @@
-use iced_native::event;
-use iced_native::layout::{self, Layout};
-use iced_native::mouse;
-use iced_native::overlay;
-use iced_native::renderer;
-use iced_native::widget::tree::{self, Tree};
-use iced_native::widget::{self, horizontal_space};
-use iced_native::{
- Clipboard, Element, Length, Point, Rectangle, Shell, Size, Widget,
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
+ self, Clipboard, Element, Length, Point, Rectangle, Shell, Size, Widget,
};
+use crate::horizontal_space;
use ouroboros::self_referencing;
use std::cell::{RefCell, RefMut};
@@ -19,14 +20,14 @@ use std::ops::Deref;
/// A [`Responsive`] widget will always try to fill all the available space of
/// its parent.
#[allow(missing_debug_implementations)]
-pub struct Responsive<'a, Message, Renderer> {
+pub struct Responsive<'a, Message, Renderer = crate::Renderer> {
view: Box<dyn Fn(Size) -> Element<'a, Message, Renderer> + 'a>,
content: RefCell<Content<'a, Message, Renderer>>,
}
impl<'a, Message, Renderer> Responsive<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
/// Creates a new [`Responsive`] widget with a closure that produces its
/// contents.
@@ -56,7 +57,7 @@ struct Content<'a, Message, Renderer> {
impl<'a, Message, Renderer> Content<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
fn update(
&mut self,
@@ -114,7 +115,7 @@ struct State {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Responsive<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
fn tag(&self) -> tree::Tag {
tree::Tag::of::<State>()
@@ -168,7 +169,7 @@ where
fn on_event(
&mut self,
tree: &mut Tree,
- event: iced_native::Event,
+ event: Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
@@ -271,7 +272,8 @@ where
content: self.content.borrow_mut(),
tree: state.tree.borrow_mut(),
types: PhantomData,
- overlay_builder: |content: &mut RefMut<Content<_, _>>, tree| {
+ overlay_builder: |content: &mut RefMut<'_, Content<'_, _, _>>,
+ tree| {
content.update(
tree,
renderer,
@@ -309,7 +311,7 @@ where
impl<'a, Message, Renderer> From<Responsive<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
- Renderer: iced_native::Renderer + 'a,
+ Renderer: core::Renderer + 'a,
Message: 'a,
{
fn from(responsive: Responsive<'a, Message, Renderer>) -> Self {
@@ -347,7 +349,7 @@ impl<'a, 'b, Message, Renderer> Overlay<'a, 'b, Message, Renderer> {
impl<'a, 'b, Message, Renderer> overlay::Overlay<Message, Renderer>
for Overlay<'a, 'b, Message, Renderer>
where
- Renderer: iced_native::Renderer,
+ Renderer: core::Renderer,
{
fn layout(
&self,
@@ -396,7 +398,7 @@ where
fn on_event(
&mut self,
- event: iced_native::Event,
+ event: Event,
layout: Layout<'_>,
cursor_position: Point,
renderer: &Renderer,
@@ -413,7 +415,7 @@ where
shell,
)
})
- .unwrap_or(iced_native::event::Status::Ignored)
+ .unwrap_or(event::Status::Ignored)
}
fn is_over(&self, layout: Layout<'_>, cursor_position: Point) -> bool {
diff --git a/widget/src/lib.rs b/widget/src/lib.rs
new file mode 100644
index 00000000..4c1e7c1c
--- /dev/null
+++ b/widget/src/lib.rs
@@ -0,0 +1,122 @@
+//! Use the built-in widgets or create your own.
+#![doc(
+ html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
+)]
+#![deny(
+ missing_debug_implementations,
+ //missing_docs,
+ unused_results,
+ clippy::extra_unused_lifetimes,
+ clippy::from_over_into,
+ clippy::needless_borrow,
+ clippy::new_without_default,
+ clippy::useless_conversion
+)]
+#![forbid(unsafe_code, rust_2018_idioms)]
+#![allow(clippy::inherent_to_string, clippy::type_complexity)]
+pub use iced_native as native;
+pub use iced_native::core;
+pub use iced_renderer as renderer;
+pub use iced_renderer::graphics;
+pub use iced_style as style;
+
+mod column;
+mod row;
+
+pub mod button;
+pub mod checkbox;
+pub mod container;
+pub mod overlay;
+pub mod pane_grid;
+pub mod pick_list;
+pub mod progress_bar;
+pub mod radio;
+pub mod rule;
+pub mod scrollable;
+pub mod slider;
+pub mod space;
+pub mod text;
+pub mod text_input;
+pub mod toggler;
+pub mod tooltip;
+pub mod vertical_slider;
+
+mod helpers;
+
+pub use helpers::*;
+
+#[cfg(feature = "lazy")]
+mod lazy;
+
+#[cfg(feature = "lazy")]
+pub use crate::lazy::{Component, Lazy, Responsive};
+
+#[cfg(feature = "lazy")]
+pub use crate::lazy::helpers::*;
+
+#[doc(no_inline)]
+pub use button::Button;
+#[doc(no_inline)]
+pub use checkbox::Checkbox;
+#[doc(no_inline)]
+pub use column::Column;
+#[doc(no_inline)]
+pub use container::Container;
+#[doc(no_inline)]
+pub use pane_grid::PaneGrid;
+#[doc(no_inline)]
+pub use pick_list::PickList;
+#[doc(no_inline)]
+pub use progress_bar::ProgressBar;
+#[doc(no_inline)]
+pub use radio::Radio;
+#[doc(no_inline)]
+pub use row::Row;
+#[doc(no_inline)]
+pub use rule::Rule;
+#[doc(no_inline)]
+pub use scrollable::Scrollable;
+#[doc(no_inline)]
+pub use slider::Slider;
+#[doc(no_inline)]
+pub use space::Space;
+#[doc(no_inline)]
+pub use text::Text;
+#[doc(no_inline)]
+pub use text_input::TextInput;
+#[doc(no_inline)]
+pub use toggler::Toggler;
+#[doc(no_inline)]
+pub use tooltip::Tooltip;
+#[doc(no_inline)]
+pub use vertical_slider::VerticalSlider;
+
+#[cfg(feature = "svg")]
+pub mod svg;
+
+#[cfg(feature = "svg")]
+#[doc(no_inline)]
+pub use svg::Svg;
+
+#[cfg(feature = "image")]
+pub mod image;
+
+#[cfg(feature = "image")]
+#[doc(no_inline)]
+pub use image::Image;
+
+#[cfg(feature = "canvas")]
+pub mod canvas;
+
+#[cfg(feature = "canvas")]
+#[doc(no_inline)]
+pub use canvas::Canvas;
+
+#[cfg(feature = "qr_code")]
+pub mod qr_code;
+
+#[cfg(feature = "qr_code")]
+#[doc(no_inline)]
+pub use qr_code::QRCode;
+
+type Renderer<Theme = style::Theme> = renderer::Renderer<Theme>;
diff --git a/widget/src/overlay.rs b/widget/src/overlay.rs
new file mode 100644
index 00000000..b9a0e3e0
--- /dev/null
+++ b/widget/src/overlay.rs
@@ -0,0 +1 @@
+pub mod menu;
diff --git a/native/src/overlay/menu.rs b/widget/src/overlay/menu.rs
index bd58a122..c322c8ba 100644
--- a/native/src/overlay/menu.rs
+++ b/widget/src/overlay/menu.rs
@@ -1,25 +1,25 @@
//! Build and show dropdown menus.
-use crate::alignment;
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::text::{self, Text};
-use crate::touch;
-use crate::widget::container::{self, Container};
-use crate::widget::scrollable::{self, Scrollable};
-use crate::widget::Tree;
-use crate::{
- Clipboard, Color, Element, Layout, Length, Padding, Pixels, Point,
- Rectangle, Shell, Size, Vector, Widget,
+use crate::container::{self, Container};
+use crate::core::alignment;
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::text::{self, Text};
+use crate::core::touch;
+use crate::core::widget::Tree;
+use crate::core::{
+ Clipboard, Color, Length, Padding, Pixels, Point, Rectangle, Size, Vector,
};
+use crate::core::{Element, Shell, Widget};
+use crate::scrollable::{self, Scrollable};
pub use iced_style::menu::{Appearance, StyleSheet};
/// A list of selectable options.
#[allow(missing_debug_implementations)]
-pub struct Menu<'a, T, Renderer>
+pub struct Menu<'a, T, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet,
@@ -137,7 +137,7 @@ impl Default for State {
struct Overlay<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
state: &'a mut Tree,
@@ -193,7 +193,7 @@ where
}
}
-impl<'a, Message, Renderer> crate::Overlay<Message, Renderer>
+impl<'a, Message, Renderer> crate::core::Overlay<Message, Renderer>
for Overlay<'a, Message, Renderer>
where
Renderer: text::Renderer,
diff --git a/native/src/widget/pane_grid.rs b/widget/src/pane_grid.rs
index bcb17ebd..a97cef60 100644
--- a/native/src/widget/pane_grid.rs
+++ b/widget/src/pane_grid.rs
@@ -30,18 +30,18 @@ pub use split::Split;
pub use state::State;
pub use title_bar::TitleBar;
-pub use iced_style::pane_grid::{Line, StyleSheet};
-
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay::{self, Group};
-use crate::renderer;
-use crate::touch;
-use crate::widget;
-use crate::widget::container;
-use crate::widget::tree::{self, Tree};
-use crate::{
+pub use crate::style::pane_grid::{Line, StyleSheet};
+
+use crate::container;
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay::{self, Group};
+use crate::core::renderer;
+use crate::core::touch;
+use crate::core::widget;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell,
Size, Vector, Widget,
};
@@ -68,10 +68,10 @@ use crate::{
/// ## Example
///
/// ```
-/// # use iced_native::widget::{pane_grid, text};
+/// # use iced_widget::{pane_grid, text};
/// #
/// # type PaneGrid<'a, Message> =
-/// # iced_native::widget::PaneGrid<'a, Message, iced_native::renderer::Null>;
+/// # iced_widget::PaneGrid<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// enum PaneState {
/// SomePane,
@@ -96,9 +96,9 @@ use crate::{
/// .on_resize(10, Message::PaneResized);
/// ```
#[allow(missing_debug_implementations)]
-pub struct PaneGrid<'a, Message, Renderer>
+pub struct PaneGrid<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
contents: Contents<'a, Content<'a, Message, Renderer>>,
@@ -113,7 +113,7 @@ where
impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
/// Creates a [`PaneGrid`] with the given [`State`] and view function.
@@ -232,7 +232,7 @@ where
impl<'a, Message, Renderer> Widget<Message, Renderer>
for PaneGrid<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
fn tag(&self) -> tree::Tag {
@@ -468,7 +468,7 @@ impl<'a, Message, Renderer> From<PaneGrid<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
fn from(
@@ -755,7 +755,7 @@ pub fn draw<Renderer, T>(
&Rectangle,
),
) where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
let picked_pane = action.picked_pane();
diff --git a/native/src/widget/pane_grid/axis.rs b/widget/src/pane_grid/axis.rs
index 02bde064..a3049230 100644
--- a/native/src/widget/pane_grid/axis.rs
+++ b/widget/src/pane_grid/axis.rs
@@ -1,4 +1,4 @@
-use crate::Rectangle;
+use crate::core::Rectangle;
/// A fixed reference line for the measurement of coordinates.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
diff --git a/native/src/widget/pane_grid/configuration.rs b/widget/src/pane_grid/configuration.rs
index 7d68fb46..ddbc3bc2 100644
--- a/native/src/widget/pane_grid/configuration.rs
+++ b/widget/src/pane_grid/configuration.rs
@@ -1,4 +1,4 @@
-use crate::widget::pane_grid::Axis;
+use crate::pane_grid::Axis;
/// The arrangement of a [`PaneGrid`].
///
diff --git a/native/src/widget/pane_grid/content.rs b/widget/src/pane_grid/content.rs
index c9b0df07..035ef05b 100644
--- a/native/src/widget/pane_grid/content.rs
+++ b/widget/src/pane_grid/content.rs
@@ -1,20 +1,20 @@
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::widget::container;
-use crate::widget::pane_grid::{Draggable, TitleBar};
-use crate::widget::{self, Tree};
-use crate::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size};
+use crate::container;
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::{self, Tree};
+use crate::core::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size};
+use crate::pane_grid::{Draggable, TitleBar};
/// The content of a [`Pane`].
///
/// [`Pane`]: crate::widget::pane_grid::Pane
#[allow(missing_debug_implementations)]
-pub struct Content<'a, Message, Renderer>
+pub struct Content<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
title_bar: Option<TitleBar<'a, Message, Renderer>>,
@@ -24,7 +24,7 @@ where
impl<'a, Message, Renderer> Content<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
/// Creates a new [`Content`] with the provided body.
@@ -57,7 +57,7 @@ where
impl<'a, Message, Renderer> Content<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
pub(super) fn state(&self) -> Tree {
@@ -342,7 +342,7 @@ where
impl<'a, Message, Renderer> Draggable for &Content<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
fn can_be_dragged_at(
@@ -364,7 +364,7 @@ where
impl<'a, T, Message, Renderer> From<T> for Content<'a, Message, Renderer>
where
T: Into<Element<'a, Message, Renderer>>,
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
fn from(element: T) -> Self {
diff --git a/native/src/widget/pane_grid/direction.rs b/widget/src/pane_grid/direction.rs
index b31a8737..b31a8737 100644
--- a/native/src/widget/pane_grid/direction.rs
+++ b/widget/src/pane_grid/direction.rs
diff --git a/native/src/widget/pane_grid/draggable.rs b/widget/src/pane_grid/draggable.rs
index 6044871d..a9274dad 100644
--- a/native/src/widget/pane_grid/draggable.rs
+++ b/widget/src/pane_grid/draggable.rs
@@ -1,4 +1,4 @@
-use crate::{Layout, Point};
+use crate::core::{Layout, Point};
/// A pane that can be dragged.
pub trait Draggable {
diff --git a/native/src/widget/pane_grid/node.rs b/widget/src/pane_grid/node.rs
index cc304b96..3976acd8 100644
--- a/native/src/widget/pane_grid/node.rs
+++ b/widget/src/pane_grid/node.rs
@@ -1,5 +1,5 @@
-use crate::widget::pane_grid::{Axis, Pane, Split};
-use crate::{Rectangle, Size};
+use crate::core::{Rectangle, Size};
+use crate::pane_grid::{Axis, Pane, Split};
use std::collections::BTreeMap;
diff --git a/native/src/widget/pane_grid/pane.rs b/widget/src/pane_grid/pane.rs
index d6fbab83..d6fbab83 100644
--- a/native/src/widget/pane_grid/pane.rs
+++ b/widget/src/pane_grid/pane.rs
diff --git a/native/src/widget/pane_grid/split.rs b/widget/src/pane_grid/split.rs
index 8132272a..8132272a 100644
--- a/native/src/widget/pane_grid/split.rs
+++ b/widget/src/pane_grid/split.rs
diff --git a/native/src/widget/pane_grid/state.rs b/widget/src/pane_grid/state.rs
index c4ae0a0e..a6e2ec7f 100644
--- a/native/src/widget/pane_grid/state.rs
+++ b/widget/src/pane_grid/state.rs
@@ -1,10 +1,8 @@
//! The state of a [`PaneGrid`].
//!
//! [`PaneGrid`]: crate::widget::PaneGrid
-use crate::widget::pane_grid::{
- Axis, Configuration, Direction, Node, Pane, Split,
-};
-use crate::{Point, Size};
+use crate::core::{Point, Size};
+use crate::pane_grid::{Axis, Configuration, Direction, Node, Pane, Split};
use std::collections::HashMap;
diff --git a/native/src/widget/pane_grid/title_bar.rs b/widget/src/pane_grid/title_bar.rs
index 107078ef..2129937b 100644
--- a/native/src/widget/pane_grid/title_bar.rs
+++ b/widget/src/pane_grid/title_bar.rs
@@ -1,11 +1,11 @@
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::widget::container;
-use crate::widget::{self, Tree};
-use crate::{
+use crate::container;
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::{self, Tree};
+use crate::core::{
Clipboard, Element, Layout, Padding, Point, Rectangle, Shell, Size,
};
@@ -13,9 +13,9 @@ use crate::{
///
/// [`Pane`]: crate::widget::pane_grid::Pane
#[allow(missing_debug_implementations)]
-pub struct TitleBar<'a, Message, Renderer>
+pub struct TitleBar<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
content: Element<'a, Message, Renderer>,
@@ -27,7 +27,7 @@ where
impl<'a, Message, Renderer> TitleBar<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
/// Creates a new [`TitleBar`] with the given content.
@@ -84,7 +84,7 @@ where
impl<'a, Message, Renderer> TitleBar<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: container::StyleSheet,
{
pub(super) fn state(&self) -> Tree {
diff --git a/native/src/widget/pick_list.rs b/widget/src/pick_list.rs
index 8ff82f3b..cd23cdd2 100644
--- a/native/src/widget/pick_list.rs
+++ b/widget/src/pick_list.rs
@@ -1,28 +1,29 @@
//! Display a dropdown list of selectable values.
-use crate::alignment;
-use crate::event::{self, Event};
-use crate::keyboard;
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::overlay::menu::{self, Menu};
-use crate::renderer;
-use crate::text::{self, Text};
-use crate::touch;
-use crate::widget::container;
-use crate::widget::scrollable;
-use crate::widget::tree::{self, Tree};
-use crate::{
+use crate::container;
+use crate::core::alignment;
+use crate::core::event::{self, Event};
+use crate::core::keyboard;
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::text::{self, Text};
+use crate::core::touch;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
Clipboard, Element, Layout, Length, Padding, Pixels, Point, Rectangle,
Shell, Size, Widget,
};
+use crate::overlay::menu::{self, Menu};
+use crate::scrollable;
+
use std::borrow::Cow;
-pub use iced_style::pick_list::{Appearance, StyleSheet};
+pub use crate::style::pick_list::{Appearance, StyleSheet};
/// A widget for selecting a single value from a list of options.
#[allow(missing_debug_implementations)]
-pub struct PickList<'a, T, Message, Renderer>
+pub struct PickList<'a, T, Message, Renderer = crate::Renderer>
where
[T]: ToOwned<Owned = Vec<T>>,
Renderer: text::Renderer,
diff --git a/native/src/widget/progress_bar.rs b/widget/src/progress_bar.rs
index dd46fa76..896d40fe 100644
--- a/native/src/widget/progress_bar.rs
+++ b/widget/src/progress_bar.rs
@@ -1,8 +1,10 @@
//! Provide progress feedback to your users.
-use crate::layout;
-use crate::renderer;
-use crate::widget::Tree;
-use crate::{Color, Element, Layout, Length, Point, Rectangle, Size, Widget};
+use crate::core::layout;
+use crate::core::renderer;
+use crate::core::widget::Tree;
+use crate::core::{
+ Color, Element, Layout, Length, Point, Rectangle, Size, Widget,
+};
use std::ops::RangeInclusive;
@@ -12,7 +14,9 @@ pub use iced_style::progress_bar::{Appearance, StyleSheet};
///
/// # Example
/// ```
-/// # type ProgressBar = iced_native::widget::ProgressBar<iced_native::renderer::Null>;
+/// # type ProgressBar =
+/// # iced_widget::ProgressBar<iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
+/// #
/// let value = 50.0;
///
/// ProgressBar::new(0.0..=100.0, value);
@@ -20,9 +24,9 @@ pub use iced_style::progress_bar::{Appearance, StyleSheet};
///
/// ![Progress bar drawn with `iced_wgpu`](https://user-images.githubusercontent.com/18618951/71662391-a316c200-2d51-11ea-9cef-52758cab85e3.png)
#[allow(missing_debug_implementations)]
-pub struct ProgressBar<Renderer>
+pub struct ProgressBar<Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
range: RangeInclusive<f32>,
@@ -34,7 +38,7 @@ where
impl<Renderer> ProgressBar<Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// The default height of a [`ProgressBar`].
@@ -79,7 +83,7 @@ where
impl<Message, Renderer> Widget<Message, Renderer> for ProgressBar<Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn width(&self) -> Length {
@@ -157,7 +161,7 @@ impl<'a, Message, Renderer> From<ProgressBar<Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(
diff --git a/src/widget/qr_code.rs b/widget/src/qr_code.rs
index 66442d5d..7709125f 100644
--- a/src/widget/qr_code.rs
+++ b/widget/src/qr_code.rs
@@ -1,13 +1,12 @@
//! Encode and display information in a QR code.
-use crate::widget::canvas;
-use crate::Renderer;
-
-use iced_native::layout;
-use iced_native::renderer;
-use iced_native::widget::Tree;
-use iced_native::{
+use crate::canvas;
+use crate::core::layout;
+use crate::core::renderer::{self, Renderer as _};
+use crate::core::widget::Tree;
+use crate::core::{
Color, Element, Layout, Length, Point, Rectangle, Size, Vector, Widget,
};
+use crate::Renderer;
use thiserror::Error;
const DEFAULT_CELL_SIZE: u16 = 4;
@@ -78,8 +77,6 @@ impl<'a, Message, Theme> Widget<Message, Renderer<Theme>> for QRCode<'a> {
_cursor_position: Point,
_viewport: &Rectangle,
) {
- use iced_native::Renderer as _;
-
let bounds = layout.bounds();
let side_length = self.state.width + 2 * QUIET_ZONE;
diff --git a/native/src/widget/radio.rs b/widget/src/radio.rs
index 5f60eaef..e5c67f3d 100644
--- a/native/src/widget/radio.rs
+++ b/widget/src/radio.rs
@@ -1,16 +1,17 @@
//! Create choices using radio buttons.
-use crate::alignment;
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::text;
-use crate::touch;
-use crate::widget::{self, Row, Text, Tree};
-use crate::{
+use crate::core::alignment;
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::text;
+use crate::core::touch;
+use crate::core::widget::Tree;
+use crate::core::{
Alignment, Clipboard, Color, Element, Layout, Length, Pixels, Point,
Rectangle, Shell, Widget,
};
+use crate::{Row, Text};
pub use iced_style::radio::{Appearance, StyleSheet};
@@ -19,7 +20,7 @@ pub use iced_style::radio::{Appearance, StyleSheet};
/// # Example
/// ```
/// # type Radio<Message> =
-/// # iced_native::widget::Radio<Message, iced_native::renderer::Null>;
+/// # iced_widget::Radio<Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// pub enum Choice {
@@ -41,7 +42,7 @@ pub use iced_style::radio::{Appearance, StyleSheet};
///
/// ![Radio buttons drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/radio.png?raw=true)
#[allow(missing_debug_implementations)]
-pub struct Radio<Message, Renderer>
+pub struct Radio<Message, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet,
@@ -144,7 +145,7 @@ impl<Message, Renderer> Widget<Message, Renderer> for Radio<Message, Renderer>
where
Message: Clone,
Renderer: text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn width(&self) -> Length {
self.width
@@ -269,14 +270,14 @@ where
{
let label_layout = children.next().unwrap();
- widget::text::draw(
+ crate::text::draw(
renderer,
style,
label_layout,
&self.label,
self.text_size,
self.font,
- widget::text::Appearance {
+ crate::text::Appearance {
color: custom_style.text_color,
},
alignment::Horizontal::Left,
@@ -291,7 +292,7 @@ impl<'a, Message, Renderer> From<Radio<Message, Renderer>>
where
Message: 'a + Clone,
Renderer: 'a + text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn from(radio: Radio<Message, Renderer>) -> Element<'a, Message, Renderer> {
Element::new(radio)
diff --git a/native/src/widget/row.rs b/widget/src/row.rs
index 286c1c2d..3ce363f8 100644
--- a/native/src/widget/row.rs
+++ b/widget/src/row.rs
@@ -1,18 +1,18 @@
//! Distribute content horizontally.
-use crate::event::{self, Event};
-use crate::layout::{self, Layout};
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::widget::{Operation, Tree};
-use crate::{
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::widget::{Operation, Tree};
+use crate::core::{
Alignment, Clipboard, Element, Length, Padding, Pixels, Point, Rectangle,
Shell, Widget,
};
/// A container that distributes its contents horizontally.
#[allow(missing_debug_implementations)]
-pub struct Row<'a, Message, Renderer> {
+pub struct Row<'a, Message, Renderer = crate::Renderer> {
spacing: f32,
padding: Padding,
width: Length,
@@ -94,7 +94,7 @@ impl<'a, Message, Renderer> Default for Row<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Row<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
{
fn children(&self) -> Vec<Tree> {
self.children.iter().map(Tree::new).collect()
@@ -245,7 +245,7 @@ impl<'a, Message, Renderer> From<Row<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: crate::Renderer + 'a,
+ Renderer: crate::core::Renderer + 'a,
{
fn from(row: Row<'a, Message, Renderer>) -> Self {
Self::new(row)
diff --git a/native/src/widget/rule.rs b/widget/src/rule.rs
index 1ab6a0d3..3749d7ce 100644
--- a/native/src/widget/rule.rs
+++ b/widget/src/rule.rs
@@ -1,18 +1,18 @@
//! Display a horizontal or vertical rule for dividing content.
-use crate::layout;
-use crate::renderer;
-use crate::widget::Tree;
-use crate::{
+use crate::core::layout;
+use crate::core::renderer;
+use crate::core::widget::Tree;
+use crate::core::{
Color, Element, Layout, Length, Pixels, Point, Rectangle, Size, Widget,
};
-pub use iced_style::rule::{Appearance, FillMode, StyleSheet};
+pub use crate::style::rule::{Appearance, FillMode, StyleSheet};
/// Display a horizontal or vertical rule for dividing content.
#[allow(missing_debug_implementations)]
-pub struct Rule<Renderer>
+pub struct Rule<Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
width: Length,
@@ -23,7 +23,7 @@ where
impl<Renderer> Rule<Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a horizontal [`Rule`] with the given height.
@@ -58,7 +58,7 @@ where
impl<Message, Renderer> Widget<Message, Renderer> for Rule<Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn width(&self) -> Length {
@@ -138,7 +138,7 @@ impl<'a, Message, Renderer> From<Rule<Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(rule: Rule<Renderer>) -> Element<'a, Message, Renderer> {
diff --git a/native/src/widget/scrollable.rs b/widget/src/scrollable.rs
index c1df8c39..49c780de 100644
--- a/native/src/widget/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -1,35 +1,29 @@
//! Navigate an endless amount of content with a scrollbar.
-use crate::event::{self, Event};
-use crate::keyboard;
-use crate::layout;
-use crate::mouse;
-use crate::overlay;
-use crate::renderer;
-use crate::touch;
-use crate::widget;
-use crate::widget::operation::{self, Operation};
-use crate::widget::tree::{self, Tree};
-use crate::{
- Background, Clipboard, Color, Command, Element, Layout, Length, Pixels,
- Point, Rectangle, Shell, Size, Vector, Widget,
+use crate::core::event::{self, Event};
+use crate::core::keyboard;
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::touch;
+use crate::core::widget;
+use crate::core::widget::operation::{self, Operation};
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
+ Background, Clipboard, Color, Element, Layout, Length, Pixels, Point,
+ Rectangle, Shell, Size, Vector, Widget,
};
+use crate::native::Command;
-pub use iced_style::scrollable::StyleSheet;
+pub use crate::style::scrollable::{Scrollbar, Scroller, StyleSheet};
pub use operation::scrollable::RelativeOffset;
-pub mod style {
- //! The styles of a [`Scrollable`].
- //!
- //! [`Scrollable`]: crate::widget::Scrollable
- pub use iced_style::scrollable::{Scrollbar, Scroller};
-}
-
/// A widget that can vertically display an infinite amount of content with a
/// scrollbar.
#[allow(missing_debug_implementations)]
-pub struct Scrollable<'a, Message, Renderer>
+pub struct Scrollable<'a, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
id: Option<Id>,
@@ -43,7 +37,7 @@ where
impl<'a, Message, Renderer> Scrollable<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Scrollable`].
@@ -153,7 +147,7 @@ impl Properties {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Scrollable<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn tag(&self) -> tree::Tag {
@@ -345,7 +339,7 @@ impl<'a, Message, Renderer> From<Scrollable<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Message: 'a,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(
@@ -763,7 +757,7 @@ pub fn draw<Renderer>(
style: &<Renderer::Theme as StyleSheet>::Style,
draw_content: impl FnOnce(&mut Renderer, Layout<'_>, Point, &Rectangle),
) where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
let bounds = layout.bounds();
@@ -809,8 +803,8 @@ pub fn draw<Renderer>(
let draw_scrollbar =
|renderer: &mut Renderer,
- style: style::Scrollbar,
- scrollbar: &Scrollbar| {
+ style: Scrollbar,
+ scrollbar: &internals::Scrollbar| {
//track
if style.background.is_some()
|| (style.border_color != Color::TRANSPARENT
@@ -1068,8 +1062,8 @@ impl State {
#[derive(Debug)]
/// State of both [`Scrollbar`]s.
struct Scrollbars {
- y: Option<Scrollbar>,
- x: Option<Scrollbar>,
+ y: Option<internals::Scrollbar>,
+ x: Option<internals::Scrollbar>,
}
impl Scrollbars {
@@ -1139,10 +1133,10 @@ impl Scrollbars {
height: scroller_height,
};
- Some(Scrollbar {
+ Some(internals::Scrollbar {
total_bounds: total_scrollbar_bounds,
bounds: scrollbar_bounds,
- scroller: Scroller {
+ scroller: internals::Scroller {
bounds: scroller_bounds,
},
})
@@ -1199,10 +1193,10 @@ impl Scrollbars {
height: scroller_width,
};
- Some(Scrollbar {
+ Some(internals::Scrollbar {
total_bounds: total_scrollbar_bounds,
bounds: scrollbar_bounds,
- scroller: Scroller {
+ scroller: internals::Scroller {
bounds: scroller_bounds,
},
})
@@ -1264,64 +1258,68 @@ impl Scrollbars {
}
}
-/// The scrollbar of a [`Scrollable`].
-#[derive(Debug, Copy, Clone)]
-struct Scrollbar {
- /// The total bounds of the [`Scrollbar`], including the scrollbar, the scroller,
- /// and the scrollbar margin.
- total_bounds: Rectangle,
+pub(super) mod internals {
+ use crate::core::{Point, Rectangle};
- /// The bounds of just the [`Scrollbar`].
- bounds: Rectangle,
+ /// The scrollbar of a [`Scrollable`].
+ #[derive(Debug, Copy, Clone)]
+ pub struct Scrollbar {
+ /// The total bounds of the [`Scrollbar`], including the scrollbar, the scroller,
+ /// and the scrollbar margin.
+ pub total_bounds: Rectangle,
- /// The state of this scrollbar's [`Scroller`].
- scroller: Scroller,
-}
+ /// The bounds of just the [`Scrollbar`].
+ pub bounds: Rectangle,
-impl Scrollbar {
- /// Returns whether the mouse is over the scrollbar or not.
- fn is_mouse_over(&self, cursor_position: Point) -> bool {
- self.total_bounds.contains(cursor_position)
+ /// The state of this scrollbar's [`Scroller`].
+ pub scroller: Scroller,
}
- /// Returns the y-axis scrolled percentage from the cursor position.
- fn scroll_percentage_y(
- &self,
- grabbed_at: f32,
- cursor_position: Point,
- ) -> f32 {
- if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
- // cursor position is unavailable! Set to either end or beginning of scrollbar depending
- // on where the thumb currently is in the track
- (self.scroller.bounds.y / self.total_bounds.height).round()
- } else {
- (cursor_position.y
- - self.bounds.y
- - self.scroller.bounds.height * grabbed_at)
- / (self.bounds.height - self.scroller.bounds.height)
+ impl Scrollbar {
+ /// Returns whether the mouse is over the scrollbar or not.
+ pub fn is_mouse_over(&self, cursor_position: Point) -> bool {
+ self.total_bounds.contains(cursor_position)
}
- }
- /// Returns the x-axis scrolled percentage from the cursor position.
- fn scroll_percentage_x(
- &self,
- grabbed_at: f32,
- cursor_position: Point,
- ) -> f32 {
- if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
- (self.scroller.bounds.x / self.total_bounds.width).round()
- } else {
- (cursor_position.x
- - self.bounds.x
- - self.scroller.bounds.width * grabbed_at)
- / (self.bounds.width - self.scroller.bounds.width)
+ /// Returns the y-axis scrolled percentage from the cursor position.
+ pub fn scroll_percentage_y(
+ &self,
+ grabbed_at: f32,
+ cursor_position: Point,
+ ) -> f32 {
+ if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
+ // cursor position is unavailable! Set to either end or beginning of scrollbar depending
+ // on where the thumb currently is in the track
+ (self.scroller.bounds.y / self.total_bounds.height).round()
+ } else {
+ (cursor_position.y
+ - self.bounds.y
+ - self.scroller.bounds.height * grabbed_at)
+ / (self.bounds.height - self.scroller.bounds.height)
+ }
+ }
+
+ /// Returns the x-axis scrolled percentage from the cursor position.
+ pub fn scroll_percentage_x(
+ &self,
+ grabbed_at: f32,
+ cursor_position: Point,
+ ) -> f32 {
+ if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
+ (self.scroller.bounds.x / self.total_bounds.width).round()
+ } else {
+ (cursor_position.x
+ - self.bounds.x
+ - self.scroller.bounds.width * grabbed_at)
+ / (self.bounds.width - self.scroller.bounds.width)
+ }
}
}
-}
-/// The handle of a [`Scrollbar`].
-#[derive(Debug, Clone, Copy)]
-struct Scroller {
- /// The bounds of the [`Scroller`].
- bounds: Rectangle,
+ /// The handle of a [`Scrollbar`].
+ #[derive(Debug, Clone, Copy)]
+ pub struct Scroller {
+ /// The bounds of the [`Scroller`].
+ pub bounds: Rectangle,
+ }
}
diff --git a/native/src/widget/slider.rs b/widget/src/slider.rs
index d3715b1c..70a84fc6 100644
--- a/native/src/widget/slider.rs
+++ b/widget/src/slider.rs
@@ -1,13 +1,13 @@
//! Display an interactive selector of a single value from a range of values.
//!
//! A [`Slider`] has some local [`State`].
-use crate::event::{self, Event};
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::touch;
-use crate::widget::tree::{self, Tree};
-use crate::{
+use crate::core::event::{self, Event};
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::touch;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
Background, Clipboard, Color, Element, Layout, Length, Pixels, Point,
Rectangle, Shell, Size, Widget,
};
@@ -26,10 +26,8 @@ pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet};
///
/// # Example
/// ```
-/// # use iced_native::widget::slider;
-/// # use iced_native::renderer::Null;
-/// #
-/// # type Slider<'a, T, Message> = slider::Slider<'a, T, Message, Null>;
+/// # type Slider<'a, T, Message> =
+/// # iced_widget::Slider<'a, Message, T, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// #[derive(Clone)]
/// pub enum Message {
@@ -43,9 +41,9 @@ pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet};
///
/// ![Slider drawn by Coffee's renderer](https://github.com/hecrj/coffee/blob/bda9818f823dfcb8a7ad0ff4940b4d4b387b5208/images/ui/slider.png?raw=true)
#[allow(missing_debug_implementations)]
-pub struct Slider<'a, T, Message, Renderer>
+pub struct Slider<'a, T, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
range: RangeInclusive<T>,
@@ -62,7 +60,7 @@ impl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer>
where
T: Copy + From<u8> + std::cmp::PartialOrd,
Message: Clone,
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
/// The default height of a [`Slider`].
@@ -148,7 +146,7 @@ impl<'a, T, Message, Renderer> Widget<Message, Renderer>
where
T: Copy + Into<f64> + num_traits::FromPrimitive,
Message: Clone,
- Renderer: crate::Renderer,
+ Renderer: crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn tag(&self) -> tree::Tag {
@@ -245,7 +243,7 @@ impl<'a, T, Message, Renderer> From<Slider<'a, T, Message, Renderer>>
where
T: 'a + Copy + Into<f64> + num_traits::FromPrimitive,
Message: 'a + Clone,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + crate::core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(
@@ -354,7 +352,7 @@ pub fn draw<T, R>(
style: &<R::Theme as StyleSheet>::Style,
) where
T: Into<f64> + Copy,
- R: crate::Renderer,
+ R: crate::core::Renderer,
R::Theme: StyleSheet,
{
let bounds = layout.bounds();
diff --git a/native/src/widget/space.rs b/widget/src/space.rs
index a6fc977e..e1e09d5a 100644
--- a/native/src/widget/space.rs
+++ b/widget/src/space.rs
@@ -1,8 +1,9 @@
//! Distribute content vertically.
-use crate::layout;
-use crate::renderer;
-use crate::widget::Tree;
-use crate::{Element, Layout, Length, Point, Rectangle, Size, Widget};
+use crate::core;
+use crate::core::layout;
+use crate::core::renderer;
+use crate::core::widget::Tree;
+use crate::core::{Element, Layout, Length, Point, Rectangle, Size, Widget};
/// An amount of empty space.
///
@@ -41,7 +42,7 @@ impl Space {
impl<Message, Renderer> Widget<Message, Renderer> for Space
where
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
{
fn width(&self) -> Length {
self.width
@@ -76,7 +77,7 @@ where
impl<'a, Message, Renderer> From<Space> for Element<'a, Message, Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
Message: 'a,
{
fn from(space: Space) -> Element<'a, Message, Renderer> {
diff --git a/native/src/widget/svg.rs b/widget/src/svg.rs
index f5ed0a6c..89017fcf 100644
--- a/native/src/widget/svg.rs
+++ b/widget/src/svg.rs
@@ -1,15 +1,15 @@
//! Display vector graphics in your application.
-use crate::layout;
-use crate::renderer;
-use crate::svg;
-use crate::widget::Tree;
-use crate::{
+use crate::core::layout;
+use crate::core::renderer;
+use crate::core::svg;
+use crate::core::widget::Tree;
+use crate::core::{
ContentFit, Element, Layout, Length, Point, Rectangle, Size, Vector, Widget,
};
use std::path::PathBuf;
-pub use iced_style::svg::{Appearance, StyleSheet};
+pub use crate::style::svg::{Appearance, StyleSheet};
pub use svg::Handle;
/// A vector graphics image.
@@ -19,7 +19,7 @@ pub use svg::Handle;
/// [`Svg`] images can have a considerable rendering cost when resized,
/// specially when they are complex.
#[allow(missing_debug_implementations)]
-pub struct Svg<Renderer>
+pub struct Svg<Renderer = crate::Renderer>
where
Renderer: svg::Renderer,
Renderer::Theme: StyleSheet,
diff --git a/widget/src/text.rs b/widget/src/text.rs
new file mode 100644
index 00000000..04c31edc
--- /dev/null
+++ b/widget/src/text.rs
@@ -0,0 +1,4 @@
+pub use crate::core::widget::text::*;
+
+pub type Text<'a, Renderer = crate::Renderer> =
+ crate::core::widget::Text<'a, Renderer>;
diff --git a/native/src/widget/text_input.rs b/widget/src/text_input.rs
index 65a9bd3b..67d80e2b 100644
--- a/native/src/widget/text_input.rs
+++ b/widget/src/text_input.rs
@@ -11,23 +11,24 @@ pub use value::Value;
use editor::Editor;
-use crate::alignment;
-use crate::event::{self, Event};
-use crate::keyboard;
-use crate::layout;
-use crate::mouse::{self, click};
-use crate::renderer;
-use crate::text::{self, Text};
-use crate::time::{Duration, Instant};
-use crate::touch;
-use crate::widget;
-use crate::widget::operation::{self, Operation};
-use crate::widget::tree::{self, Tree};
-use crate::window;
-use crate::{
- Clipboard, Color, Command, Element, Layout, Length, Padding, Pixels, Point,
+use crate::core::alignment;
+use crate::core::event::{self, Event};
+use crate::core::keyboard;
+use crate::core::layout;
+use crate::core::mouse::{self, click};
+use crate::core::renderer;
+use crate::core::text::{self, Text};
+use crate::core::time::{Duration, Instant};
+use crate::core::touch;
+use crate::core::widget;
+use crate::core::widget::operation::{self, Operation};
+use crate::core::widget::tree::{self, Tree};
+use crate::core::window;
+use crate::core::{
+ Clipboard, Color, Element, Layout, Length, Padding, Pixels, Point,
Rectangle, Shell, Size, Vector, Widget,
};
+use crate::native::Command;
pub use iced_style::text_input::{Appearance, StyleSheet};
@@ -35,7 +36,9 @@ pub use iced_style::text_input::{Appearance, StyleSheet};
///
/// # Example
/// ```
-/// # pub type TextInput<'a, Message> = iced_native::widget::TextInput<'a, Message, iced_native::renderer::Null>;
+/// # pub type TextInput<'a, Message> =
+/// # iced_widget::TextInput<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
+/// #
/// #[derive(Debug, Clone)]
/// enum Message {
/// TextInputChanged(String),
@@ -52,7 +55,7 @@ pub use iced_style::text_input::{Appearance, StyleSheet};
/// ```
/// ![Text input drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/text_input.png?raw=true)
#[allow(missing_debug_implementations)]
-pub struct TextInput<'a, Message, Renderer>
+pub struct TextInput<'a, Message, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet,
@@ -1109,7 +1112,7 @@ impl operation::TextInput for State {
}
mod platform {
- use crate::keyboard;
+ use crate::core::keyboard;
pub fn is_jump_modifier_pressed(modifiers: keyboard::Modifiers) -> bool {
if cfg!(target_os = "macos") {
diff --git a/native/src/widget/text_input/cursor.rs b/widget/src/text_input/cursor.rs
index 4f3b159b..9680dfd7 100644
--- a/native/src/widget/text_input/cursor.rs
+++ b/widget/src/text_input/cursor.rs
@@ -1,5 +1,5 @@
//! Track the cursor of a text input.
-use crate::widget::text_input::Value;
+use crate::text_input::Value;
/// The cursor of a text input.
#[derive(Debug, Copy, Clone)]
diff --git a/native/src/widget/text_input/editor.rs b/widget/src/text_input/editor.rs
index d53fa8d9..f1fd641f 100644
--- a/native/src/widget/text_input/editor.rs
+++ b/widget/src/text_input/editor.rs
@@ -1,4 +1,4 @@
-use crate::widget::text_input::{Cursor, Value};
+use crate::text_input::{Cursor, Value};
pub struct Editor<'a> {
value: &'a mut Value,
diff --git a/native/src/widget/text_input/value.rs b/widget/src/text_input/value.rs
index cf4da562..cf4da562 100644
--- a/native/src/widget/text_input/value.rs
+++ b/widget/src/text_input/value.rs
diff --git a/native/src/widget/toggler.rs b/widget/src/toggler.rs
index d9c80ebe..f23f9b27 100644
--- a/native/src/widget/toggler.rs
+++ b/widget/src/toggler.rs
@@ -1,24 +1,26 @@
//! Show toggle controls using togglers.
-use crate::alignment;
-use crate::event;
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::text;
-use crate::widget::{self, Row, Text, Tree};
-use crate::{
+use crate::core::alignment;
+use crate::core::event;
+use crate::core::layout;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::text;
+use crate::core::widget::Tree;
+use crate::core::{
Alignment, Clipboard, Element, Event, Layout, Length, Pixels, Point,
Rectangle, Shell, Widget,
};
+use crate::{Row, Text};
-pub use iced_style::toggler::{Appearance, StyleSheet};
+pub use crate::style::toggler::{Appearance, StyleSheet};
/// A toggler widget.
///
/// # Example
///
/// ```
-/// # type Toggler<'a, Message> = iced_native::widget::Toggler<'a, Message, iced_native::renderer::Null>;
+/// # type Toggler<'a, Message> =
+/// # iced_widget::Toggler<'a, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// pub enum Message {
/// TogglerToggled(bool),
@@ -29,7 +31,7 @@ pub use iced_style::toggler::{Appearance, StyleSheet};
/// Toggler::new(String::from("Toggle me!"), is_toggled, |b| Message::TogglerToggled(b));
/// ```
#[allow(missing_debug_implementations)]
-pub struct Toggler<'a, Message, Renderer>
+pub struct Toggler<'a, Message, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet,
@@ -136,7 +138,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
for Toggler<'a, Message, Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn width(&self) -> Length {
self.width
@@ -237,7 +239,7 @@ where
if let Some(label) = &self.label {
let label_layout = children.next().unwrap();
- crate::widget::text::draw(
+ crate::text::draw(
renderer,
style,
label_layout,
@@ -314,7 +316,7 @@ impl<'a, Message, Renderer> From<Toggler<'a, Message, Renderer>>
where
Message: 'a,
Renderer: 'a + text::Renderer,
- Renderer::Theme: StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: StyleSheet + crate::text::StyleSheet,
{
fn from(
toggler: Toggler<'a, Message, Renderer>,
diff --git a/native/src/widget/tooltip.rs b/widget/src/tooltip.rs
index 2a24c055..084650d1 100644
--- a/native/src/widget/tooltip.rs
+++ b/widget/src/tooltip.rs
@@ -1,26 +1,27 @@
//! Display a widget over another.
-use crate::event;
-use crate::layout;
-use crate::mouse;
-use crate::renderer;
-use crate::text;
-use crate::widget;
-use crate::widget::container;
-use crate::widget::overlay;
-use crate::widget::{Text, Tree};
-use crate::{
- Clipboard, Element, Event, Layout, Length, Padding, Pixels, Point,
- Rectangle, Shell, Size, Vector, Widget,
+use crate::container;
+use crate::core;
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::overlay;
+use crate::core::renderer;
+use crate::core::text;
+use crate::core::widget::Tree;
+use crate::core::{
+ Clipboard, Element, Length, Padding, Pixels, Point, Rectangle, Shell, Size,
+ Vector, Widget,
};
+use crate::Text;
use std::borrow::Cow;
/// An element to display a widget over another.
#[allow(missing_debug_implementations)]
-pub struct Tooltip<'a, Message, Renderer: text::Renderer>
+pub struct Tooltip<'a, Message, Renderer = crate::Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: container::StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: container::StyleSheet + crate::text::StyleSheet,
{
content: Element<'a, Message, Renderer>,
tooltip: Text<'a, Renderer>,
@@ -34,7 +35,7 @@ where
impl<'a, Message, Renderer> Tooltip<'a, Message, Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: container::StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: container::StyleSheet + crate::text::StyleSheet,
{
/// The default padding of a [`Tooltip`] drawn by this renderer.
const DEFAULT_PADDING: f32 = 5.0;
@@ -104,7 +105,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
for Tooltip<'a, Message, Renderer>
where
Renderer: text::Renderer,
- Renderer::Theme: container::StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: container::StyleSheet + crate::text::StyleSheet,
{
fn children(&self) -> Vec<Tree> {
vec![Tree::new(&self.content)]
@@ -239,7 +240,7 @@ impl<'a, Message, Renderer> From<Tooltip<'a, Message, Renderer>>
where
Message: 'a,
Renderer: 'a + text::Renderer,
- Renderer::Theme: container::StyleSheet + widget::text::StyleSheet,
+ Renderer::Theme: container::StyleSheet + crate::text::StyleSheet,
{
fn from(
tooltip: Tooltip<'a, Message, Renderer>,
@@ -285,7 +286,7 @@ pub fn draw<Renderer>(
&Rectangle,
),
) where
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
Renderer::Theme: container::StyleSheet,
{
use container::StyleSheet;
diff --git a/native/src/widget/vertical_slider.rs b/widget/src/vertical_slider.rs
index f1687e38..64a9583c 100644
--- a/native/src/widget/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -3,13 +3,18 @@
//! A [`VerticalSlider`] has some local [`State`].
use std::ops::RangeInclusive;
-pub use iced_style::slider::{Appearance, Handle, HandleShape, StyleSheet};
-
-use crate::event::{self, Event};
-use crate::widget::tree::{self, Tree};
-use crate::{
- layout, mouse, renderer, touch, Background, Clipboard, Color, Element,
- Layout, Length, Pixels, Point, Rectangle, Shell, Size, Widget,
+pub use crate::style::slider::{Appearance, Handle, HandleShape, StyleSheet};
+
+use crate::core;
+use crate::core::event::{self, Event};
+use crate::core::layout::{self, Layout};
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::touch;
+use crate::core::widget::tree::{self, Tree};
+use crate::core::{
+ Background, Clipboard, Color, Element, Length, Pixels, Point, Rectangle,
+ Shell, Size, Widget,
};
/// An vertical bar and a handle that selects a single value from a range of
@@ -22,10 +27,8 @@ use crate::{
///
/// # Example
/// ```
-/// # use iced_native::widget::vertical_slider;
-/// # use iced_native::renderer::Null;
-/// #
-/// # type VerticalSlider<'a, T, Message> = vertical_slider::VerticalSlider<'a, T, Message, Null>;
+/// # type VerticalSlider<'a, T, Message> =
+/// # iced_widget::VerticalSlider<'a, T, Message, iced_widget::renderer::Renderer<iced_widget::style::Theme>>;
/// #
/// #[derive(Clone)]
/// pub enum Message {
@@ -37,9 +40,9 @@ use crate::{
/// VerticalSlider::new(0.0..=100.0, value, Message::SliderChanged);
/// ```
#[allow(missing_debug_implementations)]
-pub struct VerticalSlider<'a, T, Message, Renderer>
+pub struct VerticalSlider<'a, T, Message, Renderer = crate::Renderer>
where
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
range: RangeInclusive<T>,
@@ -56,7 +59,7 @@ impl<'a, T, Message, Renderer> VerticalSlider<'a, T, Message, Renderer>
where
T: Copy + From<u8> + std::cmp::PartialOrd,
Message: Clone,
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// The default width of a [`VerticalSlider`].
@@ -142,7 +145,7 @@ impl<'a, T, Message, Renderer> Widget<Message, Renderer>
where
T: Copy + Into<f64> + num_traits::FromPrimitive,
Message: Clone,
- Renderer: crate::Renderer,
+ Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
fn tag(&self) -> tree::Tag {
@@ -239,7 +242,7 @@ impl<'a, T, Message, Renderer> From<VerticalSlider<'a, T, Message, Renderer>>
where
T: 'a + Copy + Into<f64> + num_traits::FromPrimitive,
Message: 'a + Clone,
- Renderer: 'a + crate::Renderer,
+ Renderer: 'a + core::Renderer,
Renderer::Theme: StyleSheet,
{
fn from(
@@ -349,7 +352,7 @@ pub fn draw<T, R>(
style: &<R::Theme as StyleSheet>::Style,
) where
T: Into<f64> + Copy,
- R: crate::Renderer,
+ R: core::Renderer,
R::Theme: StyleSheet,
{
let bounds = layout.bounds();
diff --git a/winit/Cargo.toml b/winit/Cargo.toml
index 60e464c6..21c14f68 100644
--- a/winit/Cargo.toml
+++ b/winit/Cargo.toml
@@ -35,9 +35,9 @@ path = "../native"
version = "0.7"
path = "../graphics"
-[dependencies.iced_futures]
-version = "0.6"
-path = "../futures"
+[dependencies.iced_style]
+version = "0.7"
+path = "../style"
[dependencies.tracing]
version = "0.1.37"
diff --git a/winit/src/application.rs b/winit/src/application.rs
index b52f0197..c8162c9b 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -5,25 +5,25 @@ mod state;
pub use state::State;
-use crate::clipboard::{self, Clipboard};
use crate::conversion;
-use crate::mouse;
-use crate::renderer;
-use crate::widget::operation;
-use crate::{
- Command, Debug, Error, Event, Executor, Proxy, Runtime, Settings, Size,
- Subscription,
-};
-
-use iced_futures::futures;
-use iced_futures::futures::channel::mpsc;
-use iced_graphics::window;
-use iced_graphics::window::compositor;
-use iced_native::program::Program;
-use iced_native::time::Instant;
-use iced_native::user_interface::{self, UserInterface};
-
-pub use iced_native::application::{Appearance, StyleSheet};
+use crate::core;
+use crate::core::mouse;
+use crate::core::renderer;
+use crate::core::time::Instant;
+use crate::core::widget::operation;
+use crate::core::window;
+use crate::core::{Event, Size};
+use crate::futures::futures;
+use crate::futures::Executor;
+use crate::graphics::compositor::{self, Compositor};
+use crate::native::clipboard;
+use crate::native::program::Program;
+use crate::native::user_interface::{self, UserInterface};
+use crate::native::{Command, Debug, Runtime, Subscription};
+use crate::style::application::{Appearance, StyleSheet};
+use crate::{Clipboard, Error, Proxy, Settings};
+
+use futures::channel::mpsc;
use std::mem::ManuallyDrop;
@@ -45,7 +45,7 @@ use tracing::{info_span, instrument::Instrument};
/// can be toggled by pressing `F12`.
pub trait Application: Program
where
- <Self::Renderer as crate::Renderer>::Theme: StyleSheet,
+ <Self::Renderer as core::Renderer>::Theme: StyleSheet,
{
/// The data needed to initialize your [`Application`].
type Flags;
@@ -67,12 +67,12 @@ where
fn title(&self) -> String;
/// Returns the current `Theme` of the [`Application`].
- fn theme(&self) -> <Self::Renderer as crate::Renderer>::Theme;
+ fn theme(&self) -> <Self::Renderer as core::Renderer>::Theme;
/// Returns the `Style` variation of the `Theme`.
fn style(
&self,
- ) -> <<Self::Renderer as crate::Renderer>::Theme as StyleSheet>::Style {
+ ) -> <<Self::Renderer as core::Renderer>::Theme as StyleSheet>::Style {
Default::default()
}
@@ -112,8 +112,8 @@ pub fn run<A, E, C>(
where
A: Application + 'static,
E: Executor + 'static,
- C: window::Compositor<Renderer = A::Renderer> + 'static,
- <A::Renderer as crate::Renderer>::Theme: StyleSheet,
+ C: Compositor<Renderer = A::Renderer> + 'static,
+ <A::Renderer as core::Renderer>::Theme: StyleSheet,
{
use futures::task;
use futures::Future;
@@ -278,10 +278,10 @@ async fn run_instance<A, E, C>(
) where
A: Application + 'static,
E: Executor + 'static,
- C: window::Compositor<Renderer = A::Renderer> + 'static,
- <A::Renderer as crate::Renderer>::Theme: StyleSheet,
+ C: Compositor<Renderer = A::Renderer> + 'static,
+ <A::Renderer as core::Renderer>::Theme: StyleSheet,
{
- use iced_futures::futures::stream::StreamExt;
+ use futures::stream::StreamExt;
use winit::event;
use winit::event_loop::ControlFlow;
@@ -411,7 +411,7 @@ async fn run_instance<A, E, C>(
// Then, we can use the `interface_state` here to decide if a redraw
// is needed right away, or simply wait until a specific time.
let redraw_event = Event::Window(
- crate::window::Event::RedrawRequested(Instant::now()),
+ window::Event::RedrawRequested(Instant::now()),
);
let (interface_state, _) = user_interface.update(
@@ -442,17 +442,14 @@ async fn run_instance<A, E, C>(
}
window.request_redraw();
- runtime
- .broadcast((redraw_event, crate::event::Status::Ignored));
+ runtime.broadcast((redraw_event, core::event::Status::Ignored));
let _ = control_sender.start_send(match interface_state {
user_interface::State::Updated {
redraw_request: Some(redraw_request),
} => match redraw_request {
- crate::window::RedrawRequest::NextFrame => {
- ControlFlow::Poll
- }
- crate::window::RedrawRequest::At(at) => {
+ window::RedrawRequest::NextFrame => ControlFlow::Poll,
+ window::RedrawRequest::At(at) => {
ControlFlow::WaitUntil(at)
}
},
@@ -464,9 +461,9 @@ async fn run_instance<A, E, C>(
event::Event::PlatformSpecific(event::PlatformSpecific::MacOS(
event::MacOS::ReceivedUrl(url),
)) => {
- use iced_native::event;
+ use crate::core::event;
- events.push(iced_native::Event::PlatformSpecific(
+ events.push(Event::PlatformSpecific(
event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(
url,
)),
@@ -615,7 +612,7 @@ pub fn build_user_interface<'a, A: Application>(
debug: &mut Debug,
) -> UserInterface<'a, A::Message, A::Renderer>
where
- <A::Renderer as crate::Renderer>::Theme: StyleSheet,
+ <A::Renderer as core::Renderer>::Theme: StyleSheet,
{
#[cfg(feature = "trace")]
let view_span = info_span!("Application", "VIEW").entered();
@@ -656,7 +653,7 @@ pub fn update<A: Application, E: Executor>(
window: &winit::window::Window,
graphics_info: impl FnOnce() -> compositor::Information + Copy,
) where
- <A::Renderer as crate::Renderer>::Theme: StyleSheet,
+ <A::Renderer as core::Renderer>::Theme: StyleSheet,
{
for message in messages.drain(..) {
#[cfg(feature = "trace")]
@@ -708,7 +705,7 @@ pub fn run_command<A, E>(
) where
A: Application,
E: Executor,
- <A::Renderer as crate::Renderer>::Theme: StyleSheet,
+ <A::Renderer as core::Renderer>::Theme: StyleSheet,
{
use iced_native::command;
use iced_native::system;
@@ -767,7 +764,7 @@ pub fn run_command<A, E>(
let mode = if window.is_visible().unwrap_or(true) {
conversion::mode(window.fullscreen())
} else {
- window::Mode::Hidden
+ core::window::Mode::Hidden
};
proxy
@@ -849,7 +846,7 @@ pub fn run_command<A, E>(
*cache = current_cache;
}
command::Action::LoadFont { bytes, tagger } => {
- use crate::text::Renderer;
+ use crate::core::text::Renderer;
// TODO: Error handling (?)
renderer.load_font(bytes);
diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs
index 8d6a1df1..b727e03c 100644
--- a/winit/src/application/state.rs
+++ b/winit/src/application/state.rs
@@ -1,6 +1,10 @@
use crate::application::{self, StyleSheet as _};
use crate::conversion;
-use crate::{Application, Color, Debug, Point, Size, Viewport};
+use crate::core;
+use crate::core::{Color, Point, Size};
+use crate::graphics::Viewport;
+use crate::native::Debug;
+use crate::Application;
use std::marker::PhantomData;
use winit::event::{Touch, WindowEvent};
@@ -10,7 +14,7 @@ use winit::window::Window;
#[allow(missing_debug_implementations)]
pub struct State<A: Application>
where
- <A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
+ <A::Renderer as core::Renderer>::Theme: application::StyleSheet,
{
title: String,
scale_factor: f64,
@@ -18,14 +22,14 @@ where
viewport_version: usize,
cursor_position: winit::dpi::PhysicalPosition<f64>,
modifiers: winit::event::ModifiersState,
- theme: <A::Renderer as crate::Renderer>::Theme,
+ theme: <A::Renderer as core::Renderer>::Theme,
appearance: application::Appearance,
application: PhantomData<A>,
}
impl<A: Application> State<A>
where
- <A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
+ <A::Renderer as core::Renderer>::Theme: application::StyleSheet,
{
/// Creates a new [`State`] for the provided [`Application`] and window.
pub fn new(application: &A, window: &Window) -> Self {
@@ -98,7 +102,7 @@ where
}
/// Returns the current theme of the [`State`].
- pub fn theme(&self) -> &<A::Renderer as crate::Renderer>::Theme {
+ pub fn theme(&self) -> &<A::Renderer as core::Renderer>::Theme {
&self.theme
}
diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs
index c1fd8813..22509130 100644
--- a/winit/src/clipboard.rs
+++ b/winit/src/clipboard.rs
@@ -1,7 +1,6 @@
//! Access the clipboard.
-pub use iced_native::clipboard::Action;
-
-use crate::command::{self, Command};
+use crate::native::clipboard::Action;
+use crate::native::command::{self, Command};
/// A buffer for short-term storage and transfer within and between
/// applications.
@@ -56,7 +55,7 @@ impl Clipboard {
}
}
-impl iced_native::Clipboard for Clipboard {
+impl crate::core::Clipboard for Clipboard {
fn read(&self) -> Option<String> {
self.read()
}
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 1b2ead36..0759ad9d 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -2,11 +2,12 @@
//!
//! [`winit`]: https://github.com/rust-windowing/winit
//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
-use crate::keyboard;
-use crate::mouse;
-use crate::touch;
-use crate::window;
-use crate::{Event, Point, Position};
+use crate::core::keyboard;
+use crate::core::mouse;
+use crate::core::touch;
+use crate::core::window;
+use crate::core::{Event, Point};
+use crate::Position;
/// Converts a winit window event into an iced event.
pub fn window_event(
diff --git a/winit/src/error.rs b/winit/src/error.rs
index eaeafd51..7687fb17 100644
--- a/winit/src/error.rs
+++ b/winit/src/error.rs
@@ -1,4 +1,5 @@
-use iced_futures::futures;
+use crate::futures::futures;
+use crate::graphics;
/// An error that occurred while running an application.
#[derive(Debug, thiserror::Error)]
@@ -13,10 +14,10 @@ pub enum Error {
/// The application graphics context could not be created.
#[error("the application graphics context could not be created")]
- GraphicsCreationFailed(iced_graphics::Error),
+ GraphicsCreationFailed(graphics::Error),
}
-impl From<iced_graphics::Error> for Error {
+impl From<graphics::Error> for Error {
fn from(error: iced_graphics::Error) -> Error {
Error::GraphicsCreationFailed(error)
}
diff --git a/winit/src/lib.rs b/winit/src/lib.rs
index 3a33e174..0d8c04d3 100644
--- a/winit/src/lib.rs
+++ b/winit/src/lib.rs
@@ -30,9 +30,11 @@
#![forbid(rust_2018_idioms, unsafe_code)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
-
-#[doc(no_inline)]
-pub use iced_native::*;
+pub use iced_graphics as graphics;
+pub use iced_native as native;
+pub use iced_native::core;
+pub use iced_native::futures;
+pub use iced_style as style;
pub use winit;
#[cfg(feature = "application")]
diff --git a/winit/src/proxy.rs b/winit/src/proxy.rs
index 7b9074d7..1d6c48bb 100644
--- a/winit/src/proxy.rs
+++ b/winit/src/proxy.rs
@@ -1,4 +1,4 @@
-use iced_native::futures::{
+use crate::futures::futures::{
channel::mpsc,
task::{Context, Poll},
Sink,
diff --git a/winit/src/system.rs b/winit/src/system.rs
index 8a7b2a11..3a6a8a8e 100644
--- a/winit/src/system.rs
+++ b/winit/src/system.rs
@@ -1,8 +1,7 @@
//! Access the native system.
-use crate::command::{self, Command};
-pub use iced_native::system::*;
-
-use iced_graphics::window::compositor;
+use crate::graphics::compositor;
+use crate::native::command::{self, Command};
+use crate::native::system::{Action, Information};
/// Query for available system information.
pub fn fetch_information<Message>(
diff --git a/winit/src/window.rs b/winit/src/window.rs
index 961562bd..6ac58e20 100644
--- a/winit/src/window.rs
+++ b/winit/src/window.rs
@@ -1,68 +1,58 @@
//! Interact with the window of your application.
-use crate::command::{self, Command};
-use iced_native::window;
-
-pub use window::{frames, Event, Mode, RedrawRequest, UserAttention};
+use crate::core::window::{Mode, UserAttention};
+use crate::native::command::{self, Command};
+use crate::native::window::Action;
/// Closes the current window and exits the application.
pub fn close<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Close))
+ Command::single(command::Action::Window(Action::Close))
}
/// Begins dragging the window while the left mouse button is held.
pub fn drag<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Drag))
+ Command::single(command::Action::Window(Action::Drag))
}
/// Resizes the window to the given logical dimensions.
pub fn resize<Message>(width: u32, height: u32) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Resize {
- width,
- height,
- }))
+ Command::single(command::Action::Window(Action::Resize { width, height }))
}
/// Maximizes the window.
pub fn maximize<Message>(maximized: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Maximize(
- maximized,
- )))
+ Command::single(command::Action::Window(Action::Maximize(maximized)))
}
/// Minimes the window.
pub fn minimize<Message>(minimized: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Minimize(
- minimized,
- )))
+ Command::single(command::Action::Window(Action::Minimize(minimized)))
}
/// Moves a window to the given logical coordinates.
pub fn move_to<Message>(x: i32, y: i32) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::Move { x, y }))
+ Command::single(command::Action::Window(Action::Move { x, y }))
}
/// Sets the [`Mode`] of the window.
pub fn change_mode<Message>(mode: Mode) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ChangeMode(mode)))
+ Command::single(command::Action::Window(Action::ChangeMode(mode)))
}
/// Fetches the current [`Mode`] of the window.
pub fn fetch_mode<Message>(
f: impl FnOnce(Mode) -> Message + 'static,
) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::FetchMode(
- Box::new(f),
- )))
+ Command::single(command::Action::Window(Action::FetchMode(Box::new(f))))
}
/// Toggles the window to maximized or back.
pub fn toggle_maximize<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ToggleMaximize))
+ Command::single(command::Action::Window(Action::ToggleMaximize))
}
/// Toggles the window decorations.
pub fn toggle_decorations<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ToggleDecorations))
+ Command::single(command::Action::Window(Action::ToggleDecorations))
}
/// Request user attention to the window, this has no effect if the application
@@ -74,9 +64,9 @@ pub fn toggle_decorations<Message>() -> Command<Message> {
pub fn request_user_attention<Message>(
user_attention: Option<UserAttention>,
) -> Command<Message> {
- Command::single(command::Action::Window(
- window::Action::RequestUserAttention(user_attention),
- ))
+ Command::single(command::Action::Window(Action::RequestUserAttention(
+ user_attention,
+ )))
}
/// Brings the window to the front and sets input focus. Has no effect if the window is
@@ -86,21 +76,17 @@ pub fn request_user_attention<Message>(
/// you are certain that's what the user wants. Focus stealing can cause an extremely disruptive
/// user experience.
pub fn gain_focus<Message>() -> Command<Message> {
- Command::single(command::Action::Window(window::Action::GainFocus))
+ Command::single(command::Action::Window(Action::GainFocus))
}
/// Changes whether or not the window will always be on top of other windows.
pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::ChangeAlwaysOnTop(
- on_top,
- )))
+ Command::single(command::Action::Window(Action::ChangeAlwaysOnTop(on_top)))
}
/// Fetches an identifier unique to the window.
pub fn fetch_id<Message>(
f: impl FnOnce(u64) -> Message + 'static,
) -> Command<Message> {
- Command::single(command::Action::Window(window::Action::FetchId(Box::new(
- f,
- ))))
+ Command::single(command::Action::Window(Action::FetchId(Box::new(f))))
}