diff --git a/egui/src/containers/frame.rs b/egui/src/containers/frame.rs index 4a19634d..6ccca4cf 100644 --- a/egui/src/containers/frame.rs +++ b/egui/src/containers/frame.rs @@ -18,7 +18,17 @@ impl Frame { Self::default() } - pub(crate) fn panel(style: &Style) -> Self { + /// For when you want to group a few widgets together within a frame. + pub fn group(style: &Style) -> Self { + Self { + margin: Vec2::new(8.0, 8.0), + corner_radius: 4.0, + stroke: style.visuals.widgets.noninteractive.bg_stroke, + ..Default::default() + } + } + + pub(crate) fn side_top_panel(style: &Style) -> Self { Self { margin: Vec2::new(8.0, 2.0), corner_radius: 0.0, @@ -28,7 +38,7 @@ impl Frame { } } - pub fn central_panel(style: &Style) -> Self { + pub(crate) fn central_panel(style: &Style) -> Self { Self { margin: Vec2::new(8.0, 8.0), corner_radius: 0.0, diff --git a/egui/src/containers/panel.rs b/egui/src/containers/panel.rs index ac864fb0..9513f182 100644 --- a/egui/src/containers/panel.rs +++ b/egui/src/containers/panel.rs @@ -46,7 +46,7 @@ impl SidePanel { let clip_rect = ctx.input().screen_rect(); let mut panel_ui = Ui::new(ctx.clone(), layer_id, id, panel_rect, clip_rect); - let frame = Frame::panel(&ctx.style()); + let frame = Frame::side_top_panel(&ctx.style()); let (r, used_space) = frame.show(&mut panel_ui, |ui| { let r = add_contents(ui); let used_space = ui.min_rect(); @@ -109,7 +109,7 @@ impl TopPanel { let clip_rect = ctx.input().screen_rect(); let mut panel_ui = Ui::new(ctx.clone(), layer_id, id, panel_rect, clip_rect); - let frame = Frame::panel(&ctx.style()); + let frame = Frame::side_top_panel(&ctx.style()); let (r, used_space) = frame.show(&mut panel_ui, |ui| { let r = add_contents(ui); let used_space = ui.min_rect(); diff --git a/egui_demo_lib/src/apps/demo/widgets.rs b/egui_demo_lib/src/apps/demo/widgets.rs index 9beedd9a..b5026e9b 100644 --- a/egui_demo_lib/src/apps/demo/widgets.rs +++ b/egui_demo_lib/src/apps/demo/widgets.rs @@ -104,8 +104,7 @@ impl Widgets { ui.label(format!("The button has been clicked {} times.", self.count)); }); - ui.separator(); - { + egui::Frame::group(ui.style()).show(ui, |ui| { ui.horizontal(|ui| { ui.label("Drag this value to change it:"); ui.add(DragValue::f64(&mut self.sliders.value).speed(0.01)); @@ -122,7 +121,7 @@ impl Widgets { .show(ui, |ui| { self.sliders.ui(ui); }); - } + }); ui.separator();