Make Color optional instead of Default
This commit is contained in:
parent
8879ccb5f5
commit
ee2d40d77f
4 changed files with 15 additions and 24 deletions
|
|
@ -72,7 +72,7 @@ impl text::Renderer<Color> for Renderer<'_> {
|
|||
bounds: iced::Rectangle<f32>,
|
||||
content: &str,
|
||||
size: f32,
|
||||
color: Color,
|
||||
color: Option<Color>,
|
||||
horizontal_alignment: text::HorizontalAlignment,
|
||||
_vertical_alignment: text::VerticalAlignment,
|
||||
) {
|
||||
|
|
@ -101,7 +101,7 @@ impl text::Renderer<Color> for Renderer<'_> {
|
|||
x: bounds.x,
|
||||
y: bounds.y,
|
||||
},
|
||||
Some(color),
|
||||
color,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue