diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 364b70cef814..0a317d4c2d28 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -75,7 +75,7 @@ impl Frame { pub fn menu(style: &Style) -> Self { Self { - inner_margin: Margin::same(1.0), + inner_margin: style.spacing.menu_margin, rounding: style.visuals.widgets.noninteractive.rounding, shadow: style.visuals.popup_shadow, fill: style.visuals.window_fill(), diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 2ca8b3ba47ec..6fb5727eb469 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -252,6 +252,9 @@ pub struct Spacing { /// Button size is text size plus this on each side pub button_padding: Vec2, + /// Horizontal and vertical margins within a menu frame. + pub menu_margin: Margin, + /// Indent collapsing regions etc by this much. pub indent: f32, @@ -642,6 +645,7 @@ impl Default for Spacing { Self { item_spacing: vec2(8.0, 3.0), window_margin: Margin::same(6.0), + menu_margin: Margin::same(1.0), button_padding: vec2(4.0, 1.0), indent: 18.0, // match checkbox/radio-button with `button_padding.x + icon_width + icon_spacing` interact_size: vec2(40.0, 18.0), @@ -923,6 +927,7 @@ impl Spacing { let Self { item_spacing, window_margin, + menu_margin, button_padding, indent, interact_size, @@ -963,12 +968,41 @@ impl Spacing { ); ui.add( DragValue::new(&mut window_margin.bottom) - .clamp_range(margin_range) + .clamp_range(margin_range.clone()) .prefix("bottom: "), ); ui.label("Window margins y"); }); + ui.horizontal(|ui| { + ui.add( + DragValue::new(&mut menu_margin.left) + .clamp_range(margin_range.clone()) + .prefix("left: "), + ); + ui.add( + DragValue::new(&mut menu_margin.right) + .clamp_range(margin_range.clone()) + .prefix("right: "), + ); + + ui.label("Menu margins x"); + }); + + ui.horizontal(|ui| { + ui.add( + DragValue::new(&mut menu_margin.top) + .clamp_range(margin_range.clone()) + .prefix("top: "), + ); + ui.add( + DragValue::new(&mut menu_margin.bottom) + .clamp_range(margin_range) + .prefix("bottom: "), + ); + ui.label("Menu margins y"); + }); + ui.add(slider_vec2(button_padding, 0.0..=20.0, "Button padding")); ui.add(slider_vec2(interact_size, 4.0..=60.0, "Interact size")) .on_hover_text("Minimum size of an interactive widget");