Unify style for buttons and collapsing headers

This commit is contained in:
Emil Ernerfeldt 2020-04-22 18:16:06 +02:00
parent d70ae351c1
commit d941c5830d
2 changed files with 7 additions and 10 deletions

View file

@ -26,9 +26,6 @@ pub struct Style {
/// For stuff like check marks in check boxes. /// For stuff like check marks in check boxes.
pub line_width: f32, pub line_width: f32,
/// buttons etc
pub interaction_corner_radius: f32,
// TODO: add ability to disable animations! // TODO: add ability to disable animations!
/// How many seconds a typical animation should last /// How many seconds a typical animation should last
pub animation_time: f32, pub animation_time: f32,
@ -51,7 +48,6 @@ impl Default for Style {
clickable_diameter: 28.0, clickable_diameter: 28.0,
start_icon_width: 20.0, start_icon_width: 20.0,
line_width: 1.0, line_width: 1.0,
interaction_corner_radius: 2.0,
animation_time: 1.0 / 20.0, animation_time: 1.0 / 20.0,
window: Window::default(), window: Window::default(),
} }
@ -98,6 +94,7 @@ impl Style {
} }
} }
/// For lines etc
pub fn interact_stroke_width(&self, interact: &InteractInfo) -> f32 { pub fn interact_stroke_width(&self, interact: &InteractInfo) -> f32 {
if interact.active { if interact.active {
2.0 2.0

View file

@ -91,9 +91,9 @@ impl Widget for Button {
let mut text_cursor = interact.rect.left_center() + vec2(padding.x, -0.5 * text_size.y); 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? text_cursor.y += 2.0; // TODO: why is this needed?
region.add_paint_cmd(PaintCmd::Rect { 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), fill_color: region.style().interact_fill_color(&interact),
outline: None, outline: region.style().interact_outline(&interact),
rect: interact.rect, rect: interact.rect,
}); });
let stroke_color = region.style().interact_stroke_color(&interact); let stroke_color = region.style().interact_stroke_color(&interact);