From 14643b56a846cb92280b86612f60e0783dacf2a7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 16 Dec 2025 17:20:42 +0100 Subject: [PATCH] Deprecate using `Panel` directly on a `Context` (#7781) Use `Panel::show_inside(ui)` instead! --- crates/egui/src/containers/panel.rs | 7 +++++++ examples/puffin_profiler/src/main.rs | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index 30588043f..6ed34fd7c 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -518,6 +518,7 @@ impl Panel { } /// Show the panel at the top level. + #[deprecated = "Use show_inside() instead"] pub fn show( self, ctx: &Context, @@ -528,12 +529,15 @@ impl Panel { /// Show the panel if `is_expanded` is `true`, /// otherwise don't show it, but with a nice animation between collapsed and expanded. + #[deprecated = "Use show_animated_inside() instead"] pub fn show_animated( self, ctx: &Context, is_expanded: bool, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option> { + #![expect(deprecated)] + let how_expanded = animate_expansion(ctx, self.id.with("animation"), is_expanded); let animated_panel = self.get_animated_panel(ctx, is_expanded)?; @@ -572,6 +576,7 @@ impl Panel { } /// Show either a collapsed or a expanded panel, with a nice animation between. + #[deprecated = "Use show_animated_between_inside() instead"] pub fn show_animated_between( ctx: &Context, is_expanded: bool, @@ -579,6 +584,8 @@ impl Panel { expanded_panel: Self, add_contents: impl FnOnce(&mut Ui, f32) -> R, ) -> Option> { + #![expect(deprecated)] + let how_expanded = animate_expansion(ctx, expanded_panel.id.with("animation"), is_expanded); // Get either the fake or the real panel to animate diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index 6888a8b6b..64060889a 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -108,7 +108,7 @@ impl eframe::App for MyApp { egui::ViewportBuilder::default() .with_title("Immediate Viewport") .with_inner_size([200.0, 100.0]), - |ctx, class| { + |ui, class| { puffin::profile_scope!("immediate_viewport"); assert!( @@ -116,11 +116,11 @@ impl eframe::App for MyApp { "This egui backend doesn't support multiple viewports" ); - egui::CentralPanel::default().show(ctx, |ui| { + egui::CentralPanel::default().show_inside(ui, |ui| { ui.label("Hello from immediate viewport"); }); - if ctx.input(|i| i.viewport().close_requested()) { + if ui.input(|i| i.viewport().close_requested()) { // Tell parent viewport that we should not show next frame: self.show_immediate_viewport = false; } @@ -135,7 +135,7 @@ impl eframe::App for MyApp { egui::ViewportBuilder::default() .with_title("Deferred Viewport") .with_inner_size([200.0, 100.0]), - move |ctx, class| { + move |ui, class| { puffin::profile_scope!("deferred_viewport"); assert!( @@ -143,10 +143,10 @@ impl eframe::App for MyApp { "This egui backend doesn't support multiple viewports" ); - egui::CentralPanel::default().show(ctx, |ui| { + egui::CentralPanel::default().show_inside(ui, |ui| { ui.label("Hello from deferred viewport"); }); - if ctx.input(|i| i.viewport().close_requested()) { + if ui.input(|i| i.viewport().close_requested()) { // Tell parent to close us. show_deferred_viewport.store(false, Ordering::Relaxed); }