From a7d11944039a1b5ea5b72256e8d15367d99e6010 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 5 Oct 2019 03:56:18 +0200 Subject: Add `Renderer` and `Primitive` concepts --- native/src/widget.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index 9b770454..eff098a6 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -20,13 +20,12 @@ //! //! [`Widget`]: trait.Widget.html //! [renderer]: ../renderer/index.html -mod column; -mod row; - pub mod button; pub mod checkbox; +pub mod column; pub mod image; pub mod radio; +pub mod row; pub mod slider; pub mod text; @@ -47,7 +46,7 @@ pub use slider::Slider; #[doc(no_inline)] pub use text::Text; -use crate::{Event, Hasher, Layout, MouseCursor, Node, Point}; +use crate::{Event, Hasher, Layout, Node, Point}; /// A component that displays information and allows interaction. /// @@ -56,7 +55,10 @@ use crate::{Event, Hasher, Layout, MouseCursor, Node, Point}; /// /// [`Widget`]: trait.Widget.html /// [`Element`]: ../struct.Element.html -pub trait Widget: std::fmt::Debug { +pub trait Widget: std::fmt::Debug +where + Renderer: crate::Renderer, +{ /// Returns the [`Node`] of the [`Widget`]. /// /// This [`Node`] is used by the runtime to compute the [`Layout`] of the @@ -69,16 +71,13 @@ pub trait Widget: std::fmt::Debug { /// Draws the [`Widget`] using the associated `Renderer`. /// - /// It must return the [`MouseCursor`] state for the [`Widget`]. - /// /// [`Widget`]: trait.Widget.html - /// [`MouseCursor`]: ../enum.MouseCursor.html fn draw( &self, renderer: &mut Renderer, layout: Layout<'_>, cursor_position: Point, - ) -> MouseCursor; + ) -> Renderer::Primitive; /// Computes the _layout_ hash of the [`Widget`]. /// -- cgit From 10e10e5e06841574425d2633f1c2916733f7b4ff Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 8 Oct 2019 03:13:41 +0200 Subject: Make `iced_core::Button` customizable Now it supports: - Any kind of content - Custom border radius - Custom background --- native/src/widget.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index eff098a6..b7181c1b 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -67,7 +67,7 @@ where /// [`Node`]: ../struct.Node.html /// [`Widget`]: trait.Widget.html /// [`Layout`]: ../struct.Layout.html - fn node(&self, renderer: &mut Renderer) -> Node; + fn node(&self, renderer: &Renderer) -> Node; /// Draws the [`Widget`] using the associated `Renderer`. /// -- cgit From 8846a239cf14edd464b1d09f6d6d57ad9b5c9fc7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 11 Oct 2019 22:15:39 +0200 Subject: Rename `Renderer::Primitive` to `Renderer::Output` --- native/src/widget.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget.rs') diff --git a/native/src/widget.rs b/native/src/widget.rs index b7181c1b..bcef2665 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -77,7 +77,7 @@ where renderer: &mut Renderer, layout: Layout<'_>, cursor_position: Point, - ) -> Renderer::Primitive; + ) -> Renderer::Output; /// Computes the _layout_ hash of the [`Widget`]. /// -- cgit