summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-08-26 04:07:52 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-08-26 04:07:52 +0200
commitee2d40d77f6ac3a7f6e72163d484f2801e4922fe (patch)
treea47cc74aee303df0f4a1a363af364464fb9fd979 /src
parent8879ccb5f502e2a8ec449486f718e8bd9b2f7a0a (diff)
downloadiced-ee2d40d77f6ac3a7f6e72163d484f2801e4922fe.tar.gz
iced-ee2d40d77f6ac3a7f6e72163d484f2801e4922fe.tar.bz2
iced-ee2d40d77f6ac3a7f6e72163d484f2801e4922fe.zip
Make `Color` optional instead of `Default`
Diffstat (limited to 'src')
-rw-r--r--src/widget/checkbox.rs11
-rw-r--r--src/widget/radio.rs11
-rw-r--r--src/widget/text.rs13
3 files changed, 13 insertions, 22 deletions
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<Color, Message> {
is_checked: bool,
on_toggle: Box<dyn Fn(bool) -> Message>,
label: String,
- label_color: Color,
+ label_color: Option<Color>,
}
impl<Color, Message> std::fmt::Debug for Checkbox<Color, Message>
@@ -63,10 +63,7 @@ where
}
}
-impl<Color, Message> Checkbox<Color, Message>
-where
- Color: Default,
-{
+impl<Color, Message> Checkbox<Color, Message> {
/// 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<Color, Message> {
is_selected: bool,
on_click: Message,
label: String,
- label_color: Color,
+ label_color: Option<Color>,
}
impl<Color, Message> std::fmt::Debug for Radio<Color, Message>
@@ -72,10 +72,7 @@ where
}
}
-impl<Color, Message> Radio<Color, Message>
-where
- Color: Default,
-{
+impl<Color, Message> Radio<Color, Message> {
/// 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<Color> {
content: String,
size: u16,
- color: Color,
+ color: Option<Color>,
style: Style,
horizontal_alignment: HorizontalAlignment,
vertical_alignment: VerticalAlignment,
}
-impl<Color> Text<Color>
-where
- Color: Default,
-{
+impl<Color> Text<Color> {
/// 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<Color> {
bounds: Rectangle<f32>,
content: &str,
size: f32,
- color: Color,
+ color: Option<Color>,
horizontal_alignment: HorizontalAlignment,
vertical_alignment: VerticalAlignment,
);