Skip to content

Commit

Permalink
Colored button using color tint
Browse files Browse the repository at this point in the history
  • Loading branch information
PPakalns committed Jan 9, 2025
1 parent 98743d5 commit aa6a6e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ pub trait TuiBuilderLogic<'r>: AsTuiBuilder<'r> + Sized {
#[must_use = "You should check if the user clicked this with `if ….clicked() { … } "]
fn filled_button<T>(
self,
fill: Option<egui::Color32>,
target_tint_color: Option<egui::Color32>,
f: impl FnOnce(&mut Tui) -> T,
) -> TuiInnerResponse<T> {
let tui = self.with_border_style_from_egui_style();
Expand All @@ -1429,12 +1429,12 @@ pub trait TuiBuilderLogic<'r>: AsTuiBuilder<'r> + Sized {

let painter = ui.painter();
let stroke = visuals.bg_stroke;
painter.rect(
rect.shrink(stroke.width),
visuals.rounding,
fill.unwrap_or(visuals.weak_bg_fill),
stroke,
);

let mut bg_fill = visuals.weak_bg_fill;
if let Some(fill) = target_tint_color {
bg_fill = egui::ecolor::tint_color_towards(bg_fill, fill);
}
painter.rect(rect.shrink(stroke.width), visuals.rounding, bg_fill, stroke);

response
},
Expand Down

0 comments on commit aa6a6e1

Please sign in to comment.