From 0ba2d8ca1d0d03f99e437d33f0e7a9a39caeb74b Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 13 Dec 2022 15:44:27 +0100 Subject: [PATCH] Add Visuals::menu_rounding --- crates/egui/src/containers/frame.rs | 6 +++--- crates/egui/src/style.rs | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index b41e75a7..dd00d4dd 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -72,7 +72,7 @@ impl Frame { pub fn menu(style: &Style) -> Self { Self { inner_margin: style.spacing.menu_margin, - rounding: style.visuals.widgets.noninteractive.rounding, + rounding: style.visuals.menu_rounding, shadow: style.visuals.popup_shadow, fill: style.visuals.window_fill(), stroke: style.visuals.window_stroke(), @@ -82,8 +82,8 @@ impl Frame { pub fn popup(style: &Style) -> Self { Self { - inner_margin: style.spacing.window_margin, - rounding: style.visuals.widgets.noninteractive.rounding, + inner_margin: style.spacing.menu_margin, + rounding: style.visuals.menu_rounding, shadow: style.visuals.popup_shadow, fill: style.visuals.window_fill(), stroke: style.visuals.window_stroke(), diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 09271fe1..6623d720 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -471,6 +471,8 @@ pub struct Visuals { pub window_fill: Color32, pub window_stroke: Stroke, + pub menu_rounding: Rounding, + /// Panel background color pub panel_fill: Color32, @@ -722,6 +724,8 @@ impl Visuals { window_fill: Color32::from_gray(27), window_stroke: Stroke::new(1.0, Color32::from_gray(60)), + menu_rounding: Rounding::same(6.0), + panel_fill: Color32::from_gray(27), popup_shadow: Shadow::small_dark(), @@ -1243,6 +1247,8 @@ impl Visuals { window_fill, window_stroke, + menu_rounding, + panel_fill, popup_shadow, @@ -1267,14 +1273,15 @@ impl Visuals { }); ui.collapsing("Window", |ui| { - // Common shortcuts ui_color(ui, window_fill, "Fill"); stroke_ui(ui, window_stroke, "Outline"); - rounding_ui(ui, window_rounding); - shadow_ui(ui, window_shadow, "Shadow"); - shadow_ui(ui, popup_shadow, "Shadow (small menus and popups)"); + }); + + ui.collapsing("Menus and popups", |ui| { + rounding_ui(ui, menu_rounding); + shadow_ui(ui, popup_shadow, "Shadow"); }); ui.collapsing("Widgets", |ui| widgets.ui(ui));