From 7a50e9e8fbb8d37e53a42c1dd5936b97463ead53 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 21 Jan 2024 17:56:01 +0100 Subject: Convert `Renderer::Theme` to generic `Widget` type --- widget/src/radio.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'widget/src/radio.rs') diff --git a/widget/src/radio.rs b/widget/src/radio.rs index ceb51ead..68e9bc7e 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -20,7 +20,7 @@ pub use iced_style::radio::{Appearance, StyleSheet}; /// # Example /// ```no_run /// # type Radio = -/// # iced_widget::Radio>; +/// # iced_widget::Radio; /// # /// # use iced_widget::column; /// #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -69,10 +69,10 @@ pub use iced_style::radio::{Appearance, StyleSheet}; /// let content = column![a, b, c, all]; /// ``` #[allow(missing_debug_implementations)] -pub struct Radio +pub struct Radio where + Theme: StyleSheet, Renderer: text::Renderer, - Renderer::Theme: StyleSheet, { is_selected: bool, on_click: Message, @@ -84,14 +84,14 @@ where text_line_height: text::LineHeight, text_shaping: text::Shaping, font: Option, - style: ::Style, + style: Theme::Style, } -impl Radio +impl Radio where Message: Clone, + Theme: StyleSheet, Renderer: text::Renderer, - Renderer::Theme: StyleSheet, { /// The default size of a [`Radio`] button. pub const DEFAULT_SIZE: f32 = 28.0; @@ -178,20 +178,18 @@ where } /// Sets the style of the [`Radio`] button. - pub fn style( - mut self, - style: impl Into<::Style>, - ) -> Self { + pub fn style(mut self, style: impl Into) -> Self { self.style = style.into(); self } } -impl Widget for Radio +impl Widget + for Radio where Message: Clone, + Theme: StyleSheet + crate::text::StyleSheet, Renderer: text::Renderer, - Renderer::Theme: StyleSheet + crate::text::StyleSheet, { fn tag(&self) -> tree::Tag { tree::Tag::of::>() @@ -286,7 +284,7 @@ where &self, tree: &Tree, renderer: &mut Renderer, - theme: &Renderer::Theme, + theme: &Theme, style: &renderer::Style, layout: Layout<'_>, cursor: mouse::Cursor, @@ -356,14 +354,16 @@ where } } -impl<'a, Message, Renderer> From> - for Element<'a, Message, Renderer> +impl<'a, Message, Theme, Renderer> From> + for Element<'a, Message, Theme, Renderer> where Message: 'a + Clone, + Theme: StyleSheet + crate::text::StyleSheet + 'a, Renderer: 'a + text::Renderer, - Renderer::Theme: StyleSheet + crate::text::StyleSheet, { - fn from(radio: Radio) -> Element<'a, Message, Renderer> { + fn from( + radio: Radio, + ) -> Element<'a, Message, Theme, Renderer> { Element::new(radio) } } -- cgit