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` --- graphics/src/widget/radio.rs | 58 +------------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'graphics/src/widget/radio.rs') diff --git a/graphics/src/widget/radio.rs b/graphics/src/widget/radio.rs index fd3d8145..cd83f2ff 100644 --- a/graphics/src/widget/radio.rs +++ b/graphics/src/widget/radio.rs @@ -1,8 +1,6 @@ //! Create choices using radio buttons. -use crate::{Backend, Primitive, Renderer}; -use iced_native::mouse; +use crate::{Backend, Renderer}; use iced_native::radio; -use iced_native::{Background, Color, Rectangle}; pub use iced_style::radio::{Style, StyleSheet}; @@ -21,58 +19,4 @@ where const DEFAULT_SIZE: u16 = 28; const DEFAULT_SPACING: u16 = 15; - - fn draw( - &mut self, - bounds: Rectangle, - is_selected: bool, - is_mouse_over: bool, - (label, _): Self::Output, - style_sheet: &Self::Style, - ) -> Self::Output { - let style = if is_mouse_over { - style_sheet.hovered() - } else { - style_sheet.active() - }; - - let size = bounds.width; - let dot_size = size / 2.0; - - let radio = Primitive::Quad { - bounds, - background: style.background, - border_radius: size / 2.0, - border_width: style.border_width, - border_color: style.border_color, - }; - - ( - Primitive::Group { - primitives: if is_selected { - let radio_circle = Primitive::Quad { - bounds: Rectangle { - x: bounds.x + dot_size / 2.0, - y: bounds.y + dot_size / 2.0, - width: bounds.width - dot_size, - height: bounds.height - dot_size, - }, - background: Background::Color(style.dot_color), - border_radius: dot_size / 2.0, - border_width: 0.0, - border_color: Color::TRANSPARENT, - }; - - vec![radio, radio_circle, label] - } else { - vec![radio, label] - }, - }, - if is_mouse_over { - mouse::Interaction::Pointer - } else { - mouse::Interaction::default() - }, - ) - } } -- cgit From d39ad717ed0ab85acbe935d7ab883166b36e7bc7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 19:06:53 +0700 Subject: Wire up styling to `Radio` in `iced_native` --- graphics/src/widget/radio.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'graphics/src/widget/radio.rs') diff --git a/graphics/src/widget/radio.rs b/graphics/src/widget/radio.rs index cd83f2ff..4185bd61 100644 --- a/graphics/src/widget/radio.rs +++ b/graphics/src/widget/radio.rs @@ -1,6 +1,5 @@ //! Create choices using radio buttons. -use crate::{Backend, Renderer}; -use iced_native::radio; +use crate::Renderer; pub use iced_style::radio::{Style, StyleSheet}; @@ -8,15 +7,5 @@ pub use iced_style::radio::{Style, StyleSheet}; /// /// This is an alias of an `iced_native` radio button with an /// `iced_wgpu::Renderer`. -pub type Radio = - iced_native::Radio>; - -impl radio::Renderer for Renderer -where - B: Backend, -{ - type Style = Box; - - const DEFAULT_SIZE: u16 = 28; - const DEFAULT_SPACING: u16 = 15; -} +pub type Radio<'a, Message, Backend> = + iced_native::Radio<'a, Message, Renderer>; -- cgit From 0aafcde0ef1533c9eeba0379de8c0082e30c7504 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 15:35:12 +0700 Subject: Remove `widget` module re-exports in `iced_native` --- graphics/src/widget/radio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/widget/radio.rs') diff --git a/graphics/src/widget/radio.rs b/graphics/src/widget/radio.rs index 4185bd61..20d72747 100644 --- a/graphics/src/widget/radio.rs +++ b/graphics/src/widget/radio.rs @@ -8,4 +8,4 @@ pub use iced_style::radio::{Style, StyleSheet}; /// This is an alias of an `iced_native` radio button with an /// `iced_wgpu::Renderer`. pub type Radio<'a, Message, Backend> = - iced_native::Radio<'a, Message, Renderer>; + iced_native::widget::Radio<'a, Message, Renderer>; -- cgit