Fix consistency of with_background for button::Appearance

This commit is contained in:
Héctor Ramón Jiménez 2024-03-07 21:13:23 +01:00
parent 7ece5eea50
commit 1f46fd871b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -397,7 +397,7 @@ pub enum Status {
}
/// The appearance of a button.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Appearance {
/// The amount of offset to apply to the shadow of the button.
pub shadow_offset: Vector,
@ -412,11 +412,11 @@ pub struct Appearance {
}
impl Appearance {
/// Creates an [`Appearance`] with the given [`Background`].
pub fn with_background(background: impl Into<Background>) -> Self {
/// Updates the [`Appearance`] with the given [`Background`].
pub fn with_background(self, background: impl Into<Background>) -> Self {
Self {
background: Some(background.into()),
..Self::default()
..self
}
}
}
@ -456,7 +456,7 @@ impl DefaultStyle for Appearance {
impl DefaultStyle for Color {
fn default_style() -> Style<Self> {
|color, _status| Appearance::with_background(*color)
|color, _status| Appearance::default().with_background(*color)
}
}