Merge pull request #2707 from xosxos/patch-2
Add `text_color` to toggler `Style`
This commit is contained in:
commit
2bbc7385e0
1 changed files with 11 additions and 5 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue