From d941c5830d4ac03df961551bd5eb2417b6a99210 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 22 Apr 2020 18:16:06 +0200 Subject: [PATCH] Unify style for buttons and collapsing headers --- emigui/src/style.rs | 13 +++++-------- emigui/src/widgets.rs | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/emigui/src/style.rs b/emigui/src/style.rs index 6d2deaf9..c9b03335 100644 --- a/emigui/src/style.rs +++ b/emigui/src/style.rs @@ -26,9 +26,6 @@ pub struct Style { /// For stuff like check marks in check boxes. pub line_width: f32, - /// buttons etc - pub interaction_corner_radius: f32, - // TODO: add ability to disable animations! /// How many seconds a typical animation should last pub animation_time: f32, @@ -51,7 +48,6 @@ impl Default for Style { clickable_diameter: 28.0, start_icon_width: 20.0, line_width: 1.0, - interaction_corner_radius: 2.0, animation_time: 1.0 / 20.0, window: Window::default(), } @@ -98,6 +94,7 @@ impl Style { } } + /// For lines etc pub fn interact_stroke_width(&self, interact: &InteractInfo) -> f32 { if interact.active { 2.0 @@ -111,10 +108,10 @@ impl Style { /// For rectangles pub fn interact_outline(&self, interact: &InteractInfo) -> Option { if interact.active { - Some(Outline::new( - self.interact_stroke_width(interact), - self.interact_stroke_color(interact), - )) + Some(Outline::new( + self.interact_stroke_width(interact), + self.interact_stroke_color(interact), + )) } else if interact.hovered { None } else { diff --git a/emigui/src/widgets.rs b/emigui/src/widgets.rs index aaf6cea0..c18313ed 100644 --- a/emigui/src/widgets.rs +++ b/emigui/src/widgets.rs @@ -91,9 +91,9 @@ impl Widget for Button { let mut text_cursor = interact.rect.left_center() + vec2(padding.x, -0.5 * text_size.y); text_cursor.y += 2.0; // TODO: why is this needed? region.add_paint_cmd(PaintCmd::Rect { - corner_radius: region.style().interaction_corner_radius, + corner_radius: region.style().interact_corner_radius(&interact), fill_color: region.style().interact_fill_color(&interact), - outline: None, + outline: region.style().interact_outline(&interact), rect: interact.rect, }); let stroke_color = region.style().interact_stroke_color(&interact);