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/checkbox.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 3e307f64..1954305a 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -2,7 +2,7 @@ use std::hash::Hash; use crate::input::{mouse, ButtonState}; -use crate::{Element, Event, Hasher, Layout, MouseCursor, Node, Point, Widget}; +use crate::{Element, Event, Hasher, Layout, Node, Point, Widget}; pub use iced_core::Checkbox; @@ -43,7 +43,7 @@ where renderer: &mut Renderer, layout: Layout<'_>, cursor_position: Point, - ) -> MouseCursor { + ) -> Renderer::Primitive { renderer.draw(&self, layout, cursor_position) } @@ -59,7 +59,7 @@ where /// /// [`Checkbox`]: struct.Checkbox.html /// [renderer]: ../../renderer/index.html -pub trait Renderer { +pub trait Renderer: crate::Renderer { /// Creates a [`Node`] for the provided [`Checkbox`]. /// /// [`Node`]: ../../struct.Node.html @@ -80,7 +80,7 @@ pub trait Renderer { checkbox: &Checkbox, layout: Layout<'_>, cursor_position: Point, - ) -> MouseCursor; + ) -> Self::Primitive; } impl<'a, Message, Renderer> From> -- 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/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 1954305a..c069bfdc 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -10,7 +10,7 @@ impl Widget for Checkbox where Renderer: self::Renderer, { - fn node(&self, renderer: &mut Renderer) -> Node { + fn node(&self, renderer: &Renderer) -> Node { renderer.node(&self) } @@ -64,7 +64,7 @@ pub trait Renderer: crate::Renderer { /// /// [`Node`]: ../../struct.Node.html /// [`Checkbox`]: struct.Checkbox.html - fn node(&mut self, checkbox: &Checkbox) -> Node; + fn node(&self, checkbox: &Checkbox) -> Node; /// Draws a [`Checkbox`]. /// -- 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/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index c069bfdc..cb2baedd 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -43,7 +43,7 @@ where renderer: &mut Renderer, layout: Layout<'_>, cursor_position: Point, - ) -> Renderer::Primitive { + ) -> Renderer::Output { renderer.draw(&self, layout, cursor_position) } @@ -80,7 +80,7 @@ pub trait Renderer: crate::Renderer { checkbox: &Checkbox, layout: Layout<'_>, cursor_position: Point, - ) -> Self::Primitive; + ) -> Self::Output; } impl<'a, Message, Renderer> From> -- cgit From ccc463a7c051b1096bc8a9f17ec64c2912a11247 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 13 Oct 2019 18:10:12 +0200 Subject: Draw checkbox in `iced_wgpu` --- native/src/widget/checkbox.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'native/src/widget/checkbox.rs') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index cb2baedd..5393417e 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -26,9 +26,7 @@ where button: mouse::Button::Left, state: ButtonState::Pressed, }) => { - let mouse_over = layout - .children() - .any(|child| child.bounds().contains(cursor_position)); + let mouse_over = layout.bounds().contains(cursor_position); if mouse_over { messages.push((self.on_toggle)(!self.is_checked)); -- cgit