From 03b34931383e701c39c653a7662a616fe21a0947 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:07:22 +0700 Subject: Remove trait-specific draw logic in `iced_native` --- native/src/renderer.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 39a6cff1..3784ff24 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -30,12 +30,6 @@ use crate::{layout, Element, Rectangle}; /// A component that can take the state of a user interface and produce an /// output for its users. pub trait Renderer: Sized { - /// The type of output of the [`Renderer`]. - /// - /// If you are implementing a graphical renderer, your output will most - /// likely be a tree of visual primitives. - type Output; - /// The default styling attributes of the [`Renderer`]. /// /// This type can be leveraged to implement style inheritance. @@ -53,12 +47,5 @@ pub trait Renderer: Sized { element.layout(self, limits) } - /// Overlays the `overlay` output with the given bounds on top of the `base` - /// output. - fn overlay( - &mut self, - base: Self::Output, - overlay: Self::Output, - overlay_bounds: Rectangle, - ) -> Self::Output; + fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)); } -- cgit From 3a0c503db99eb3d45ac971132904df419ee566b6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:59:19 +0700 Subject: Implement `Widget::draw` for `Text` --- native/src/renderer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 3784ff24..ca0aecec 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -19,13 +19,17 @@ //! [`text::Renderer`]: crate::widget::text::Renderer //! [`Checkbox`]: crate::widget::Checkbox //! [`checkbox::Renderer`]: crate::widget::checkbox::Renderer +pub mod text; + +pub use text::Text; #[cfg(debug_assertions)] mod null; #[cfg(debug_assertions)] pub use null::Null; -use crate::{layout, Element, Rectangle}; +use crate::layout; +use crate::{Element, Rectangle}; /// A component that can take the state of a user interface and produce an /// output for its users. @@ -48,4 +52,6 @@ pub trait Renderer: Sized { } fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)); + + fn clear(&mut self); } -- cgit From dfceee99aad9462f09ca61081e68e1decb2fed92 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 17:15:29 +0700 Subject: Implement `Widget::draw` for `Scrollable` Rendering the scroller is still WIP --- native/src/renderer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index ca0aecec..5a7a0067 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -29,7 +29,7 @@ mod null; pub use null::Null; use crate::layout; -use crate::{Element, Rectangle}; +use crate::{Element, Rectangle, Vector}; /// A component that can take the state of a user interface and produce an /// output for its users. @@ -51,7 +51,12 @@ pub trait Renderer: Sized { element.layout(self, limits) } - fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)); + fn with_layer( + &mut self, + bounds: Rectangle, + offset: Vector, + f: impl FnOnce(&mut Self), + ); fn clear(&mut self); } -- cgit From a4f4d831615899046d36c96e6a580d5386aa25bf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 14:47:49 +0700 Subject: Introduce `fill_rectangle` to `Renderer` trait --- native/src/renderer.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 5a7a0067..382edb61 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -29,7 +29,7 @@ mod null; pub use null::Null; use crate::layout; -use crate::{Element, Rectangle, Vector}; +use crate::{Background, Color, Element, Rectangle, Vector}; /// A component that can take the state of a user interface and produce an /// output for its users. @@ -59,4 +59,15 @@ pub trait Renderer: Sized { ); fn clear(&mut self); + + fn fill_rectangle(&mut self, quad: Quad); +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Quad { + pub bounds: Rectangle, + pub background: Background, + pub border_radius: f32, + pub border_width: f32, + pub border_color: Color, } -- cgit From edea093350e1b576e2b7db50c525e7fa5c3bea9f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 15:19:04 +0700 Subject: Move `Defaults` from `iced_graphics` to `iced_native` --- native/src/renderer.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 382edb61..e48c701d 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -34,11 +34,6 @@ use crate::{Background, Color, Element, Rectangle, Vector}; /// A component that can take the state of a user interface and produce an /// output for its users. pub trait Renderer: Sized { - /// The default styling attributes of the [`Renderer`]. - /// - /// This type can be leveraged to implement style inheritance. - type Defaults: Default; - /// Lays out the elements of a user interface. /// /// You should override this if you need to perform any operations before or @@ -71,3 +66,18 @@ pub struct Quad { pub border_width: f32, pub border_color: Color, } + +/// The styling attributes of a [`Renderer`]. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Style { + /// The text color + pub text_color: Color, +} + +impl Default for Style { + fn default() -> Self { + Style { + text_color: Color::BLACK, + } + } +} -- cgit From 4a11cbd99445338619dfaf1f327dbc25b2983cb7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 25 Oct 2021 16:16:35 +0700 Subject: Implement `Widget::mouse_interaction` for `PaneGrid` ... and fix rendering of drag interaction in `PaneGrid` by introducing an explicit `with_translation` method to `Renderer` and simplifying the `with_layer` and `Clip` primitive. --- native/src/renderer.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index e48c701d..6d12edae 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -46,10 +46,11 @@ pub trait Renderer: Sized { element.layout(self, limits) } - fn with_layer( + fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)); + + fn with_translation( &mut self, - bounds: Rectangle, - offset: Vector, + translation: Vector, f: impl FnOnce(&mut Self), ); -- cgit From b3a01973c6c726e6539be959659f4306ef3234c6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 16:13:03 +0700 Subject: Introduce first-class `text` module in `iced_native` --- native/src/renderer.rs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 6d12edae..1e518936 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -19,10 +19,6 @@ //! [`text::Renderer`]: crate::widget::text::Renderer //! [`Checkbox`]: crate::widget::Checkbox //! [`checkbox::Renderer`]: crate::widget::checkbox::Renderer -pub mod text; - -pub use text::Text; - #[cfg(debug_assertions)] mod null; #[cfg(debug_assertions)] -- cgit From 023aded2772f0cd6abd716fe5c8624d5d22e21fa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 4 Nov 2021 19:22:29 +0700 Subject: Rename `fill_rectangle` to `fill_quad` in `Renderer` --- native/src/renderer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 1e518936..3b04a5c0 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -42,23 +42,28 @@ pub trait Renderer: Sized { element.layout(self, limits) } + /// Draws the primitives recorded in the given closure in a new layer. + /// + /// The layer will clip its contents to the provided `bounds`. fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)); + /// Applies a `translation` to the primitives recorded in the given closure. fn with_translation( &mut self, translation: Vector, f: impl FnOnce(&mut Self), ); + /// Clears all of the recorded primitives in the [`Renderer`]. fn clear(&mut self); - fn fill_rectangle(&mut self, quad: Quad); + /// Fills a [`Quad`] with the provided [`Background`]. + fn fill_quad(&mut self, quad: Quad, background: impl Into); } #[derive(Debug, Clone, Copy, PartialEq)] pub struct Quad { pub bounds: Rectangle, - pub background: Background, pub border_radius: f32, pub border_width: f32, pub border_color: Color, -- cgit From aca9d414d311f901cfe6494a28a48a563f17320b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 5 Nov 2021 15:31:33 +0700 Subject: Write missing documentation in `iced_native` --- native/src/renderer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'native/src/renderer.rs') diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 3b04a5c0..ca7ad5a2 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -61,11 +61,19 @@ pub trait Renderer: Sized { fn fill_quad(&mut self, quad: Quad, background: impl Into); } +/// A polygon with four sides. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Quad { + /// The bounds of the [`Quad`]. pub bounds: Rectangle, + + /// The border radius of the [`Quad`]. pub border_radius: f32, + + /// The border width of the [`Quad`]. pub border_width: f32, + + /// The border color of the [`Quad`]. pub border_color: Color, } -- cgit