Skip to content

Commit f7b820a

Browse files
authored
Add text_color to toggler Style
1 parent f2c9b6b commit f7b820a

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

widget/src/toggler.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ where
380380
tree: &Tree,
381381
renderer: &mut Renderer,
382382
theme: &Theme,
383-
style: &renderer::Style,
383+
defaults: &renderer::Style,
384384
layout: Layout<'_>,
385385
_cursor: mouse::Cursor,
386386
viewport: &Rectangle,
@@ -395,24 +395,27 @@ where
395395
let mut children = layout.children();
396396
let toggler_layout = children.next().unwrap();
397397

398+
let style = theme
399+
.style(&self.class, self.last_status.unwrap_or(Status::Disabled));
400+
398401
if self.label.is_some() {
399402
let label_layout = children.next().unwrap();
400403
let state: &widget::text::State<Renderer::Paragraph> =
401404
tree.state.downcast_ref();
402405

403406
crate::text::draw(
404407
renderer,
405-
style,
408+
defaults,
406409
label_layout,
407410
state.0.raw(),
408-
crate::text::Style::default(),
411+
crate::text::Style {
412+
color: style.text_color,
413+
},
409414
viewport,
410415
);
411416
}
412417

413418
let bounds = toggler_layout.bounds();
414-
let style = theme
415-
.style(&self.class, self.last_status.unwrap_or(Status::Disabled));
416419

417420
let border_radius = bounds.height / BORDER_RADIUS_RATIO;
418421
let space = SPACE_RATIO * bounds.height;
@@ -510,6 +513,8 @@ pub struct Style {
510513
pub foreground_border_width: f32,
511514
/// The [`Color`] of the foreground border of the toggler.
512515
pub foreground_border_color: Color,
516+
/// The text [`Color`] of the toggler.
517+
pub text_color: Option<Color>,
513518
}
514519

515520
/// The theme catalog of a [`Toggler`].
@@ -584,5 +589,6 @@ pub fn default(theme: &Theme, status: Status) -> Style {
584589
foreground_border_color: Color::TRANSPARENT,
585590
background_border_width: 0.0,
586591
background_border_color: Color::TRANSPARENT,
592+
text_color: None,
587593
}
588594
}

0 commit comments

Comments
 (0)