From ee2d40d77f6ac3a7f6e72163d484f2801e4922fe Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 26 Aug 2019 04:07:52 +0200 Subject: Make `Color` optional instead of `Default` --- src/widget/checkbox.rs | 11 ++++------- src/widget/radio.rs | 11 ++++------- src/widget/text.rs | 13 +++++-------- 3 files changed, 13 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/widget/checkbox.rs b/src/widget/checkbox.rs index c30b8308..f7902d20 100644 --- a/src/widget/checkbox.rs +++ b/src/widget/checkbox.rs @@ -47,7 +47,7 @@ pub struct Checkbox { is_checked: bool, on_toggle: Box Message>, label: String, - label_color: Color, + label_color: Option, } impl std::fmt::Debug for Checkbox @@ -63,10 +63,7 @@ where } } -impl Checkbox -where - Color: Default, -{ +impl Checkbox { /// Creates a new [`Checkbox`]. /// /// It expects: @@ -85,7 +82,7 @@ where is_checked, on_toggle: Box::new(f), label: String::from(label), - label_color: Color::default(), + label_color: None, } } @@ -94,7 +91,7 @@ where /// [`Color`]: ../../../../graphics/struct.Color.html /// [`Checkbox`]: struct.Checkbox.html pub fn label_color(mut self, color: Color) -> Self { - self.label_color = color; + self.label_color = Some(color); self } } diff --git a/src/widget/radio.rs b/src/widget/radio.rs index 75ddd35d..2f34b5e4 100644 --- a/src/widget/radio.rs +++ b/src/widget/radio.rs @@ -54,7 +54,7 @@ pub struct Radio { is_selected: bool, on_click: Message, label: String, - label_color: Color, + label_color: Option, } impl std::fmt::Debug for Radio @@ -72,10 +72,7 @@ where } } -impl Radio -where - Color: Default, -{ +impl Radio { /// Creates a new [`Radio`] button. /// /// It expects: @@ -95,7 +92,7 @@ where is_selected: Some(value) == selected, on_click: f(value), label: String::from(label), - label_color: Color::default(), + label_color: None, } } @@ -104,7 +101,7 @@ where /// [`Color`]: ../../../../graphics/struct.Color.html /// [`Radio`]: struct.Radio.html pub fn label_color(mut self, color: Color) -> Self { - self.label_color = color; + self.label_color = Some(color); self } } diff --git a/src/widget/text.rs b/src/widget/text.rs index bf5c1624..018c7cc5 100644 --- a/src/widget/text.rs +++ b/src/widget/text.rs @@ -27,16 +27,13 @@ use std::hash::Hash; pub struct Text { content: String, size: u16, - color: Color, + color: Option, style: Style, horizontal_alignment: HorizontalAlignment, vertical_alignment: VerticalAlignment, } -impl Text -where - Color: Default, -{ +impl Text { /// Create a new fragment of [`Text`] with the given contents. /// /// [`Text`]: struct.Text.html @@ -44,7 +41,7 @@ where Text { content: String::from(label), size: 20, - color: Color::default(), + color: None, style: Style::default().fill_width(), horizontal_alignment: HorizontalAlignment::Left, vertical_alignment: VerticalAlignment::Top, @@ -64,7 +61,7 @@ where /// [`Text`]: struct.Text.html /// [`Color`]: ../../../graphics/struct.Color.html pub fn color(mut self, color: Color) -> Self { - self.color = color; + self.color = Some(color); self } @@ -180,7 +177,7 @@ pub trait Renderer { bounds: Rectangle, content: &str, size: f32, - color: Color, + color: Option, horizontal_alignment: HorizontalAlignment, vertical_alignment: VerticalAlignment, ); -- cgit