Improve default styling of Slider widget

This commit is contained in:
Héctor Ramón Jiménez 2024-03-05 22:31:01 +01:00
parent 5824ceb1fe
commit 420f49bef5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 16 additions and 20 deletions

View file

@ -185,7 +185,10 @@ impl Style for Theme {
pub fn primary(theme: &Theme) -> Appearance { pub fn primary(theme: &Theme) -> Appearance {
let palette = theme.extended_palette(); let palette = theme.extended_palette();
styled(palette.background.strong.color, palette.primary.base.color) styled(
palette.background.strong.color,
palette.primary.strong.color,
)
} }
/// The secondary style of a [`ProgressBar`]. /// The secondary style of a [`ProgressBar`].

View file

@ -62,7 +62,7 @@ where
Message: Clone, Message: Clone,
{ {
/// The default height of a [`Slider`]. /// The default height of a [`Slider`].
pub const DEFAULT_HEIGHT: f32 = 22.0; pub const DEFAULT_HEIGHT: f32 = 15.0;
/// Creates a new [`Slider`]. /// Creates a new [`Slider`].
/// ///
@ -566,30 +566,23 @@ impl Style for Theme {
pub fn default(theme: &Theme, status: Status) -> Appearance { pub fn default(theme: &Theme, status: Status) -> Appearance {
let palette = theme.extended_palette(); let palette = theme.extended_palette();
let handle = Handle { let color = match status {
shape: HandleShape::Rectangle { Status::Active => palette.primary.strong.color,
width: 8, Status::Hovered => palette.primary.base.color,
border_radius: 4.0.into(), Status::Dragged => palette.primary.strong.color,
},
color: Color::WHITE,
border_color: Color::WHITE,
border_width: 1.0,
}; };
Appearance { Appearance {
rail: Rail { rail: Rail {
colors: (palette.primary.base.color, palette.secondary.base.color), colors: (color, palette.secondary.base.color),
width: 4.0, width: 6.0,
border_radius: 2.0.into(), border_radius: 3.0.into(),
}, },
handle: Handle { handle: Handle {
color: match status { shape: HandleShape::Circle { radius: 7.0 },
Status::Active => palette.background.base.color, color,
Status::Hovered => palette.primary.weak.color, border_color: Color::TRANSPARENT,
Status::Dragged => palette.primary.base.color, border_width: 0.0,
},
border_color: palette.primary.base.color,
..handle
}, },
} }
} }