Add text_color to toggler::Style

This commit is contained in:
Osma S. Rautila 2024-12-27 19:09:24 +02:00 committed by Héctor Ramón Jiménez
parent 9ef65db8c9
commit 038063f781
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -388,7 +388,7 @@ where
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
style: &renderer::Style,
defaults: &renderer::Style,
layout: Layout<'_>,
_cursor: mouse::Cursor,
viewport: &Rectangle,
@ -400,6 +400,9 @@ where
let mut children = layout.children();
let toggler_layout = children.next().unwrap();
let style = theme
.style(&self.class, self.last_status.unwrap_or(Status::Disabled));
if self.label.is_some() {
let label_layout = children.next().unwrap();
let state: &widget::text::State<Renderer::Paragraph> =
@ -407,17 +410,17 @@ where
crate::text::draw(
renderer,
style,
defaults,
label_layout.bounds(),
state.raw(),
crate::text::Style::default(),
crate::text::Style {
color: style.text_color,
},
viewport,
);
}
let bounds = toggler_layout.bounds();
let style = theme
.style(&self.class, self.last_status.unwrap_or(Status::Disabled));
let border_radius = bounds.height / 2.0;
let space = (SPACE_RATIO * bounds.height).round();
@ -515,6 +518,8 @@ pub struct Style {
pub foreground_border_width: f32,
/// The [`Color`] of the foreground border of the toggler.
pub foreground_border_color: Color,
/// The text [`Color`] of the toggler.
pub text_color: Option<Color>,
}
/// The theme catalog of a [`Toggler`].
@ -589,5 +594,6 @@ pub fn default(theme: &Theme, status: Status) -> Style {
foreground_border_color: Color::TRANSPARENT,
background_border_width: 0.0,
background_border_color: Color::TRANSPARENT,
text_color: None,
}
}