1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Deprecate using Panel directly on a Context (#7781)

Use `Panel::show_inside(ui)` instead!
This commit is contained in:
Emil Ernerfeldt
2025-12-16 17:20:42 +01:00
committed by GitHub
parent 2f6fe9c572
commit 14643b56a8
2 changed files with 13 additions and 6 deletions

View File

@@ -518,6 +518,7 @@ impl Panel {
} }
/// Show the panel at the top level. /// Show the panel at the top level.
#[deprecated = "Use show_inside() instead"]
pub fn show<R>( pub fn show<R>(
self, self,
ctx: &Context, ctx: &Context,
@@ -528,12 +529,15 @@ impl Panel {
/// Show the panel if `is_expanded` is `true`, /// Show the panel if `is_expanded` is `true`,
/// otherwise don't show it, but with a nice animation between collapsed and expanded. /// otherwise don't show it, but with a nice animation between collapsed and expanded.
#[deprecated = "Use show_animated_inside() instead"]
pub fn show_animated<R>( pub fn show_animated<R>(
self, self,
ctx: &Context, ctx: &Context,
is_expanded: bool, is_expanded: bool,
add_contents: impl FnOnce(&mut Ui) -> R, add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<InnerResponse<R>> { ) -> Option<InnerResponse<R>> {
#![expect(deprecated)]
let how_expanded = animate_expansion(ctx, self.id.with("animation"), is_expanded); let how_expanded = animate_expansion(ctx, self.id.with("animation"), is_expanded);
let animated_panel = self.get_animated_panel(ctx, 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. /// 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<R>( pub fn show_animated_between<R>(
ctx: &Context, ctx: &Context,
is_expanded: bool, is_expanded: bool,
@@ -579,6 +584,8 @@ impl Panel {
expanded_panel: Self, expanded_panel: Self,
add_contents: impl FnOnce(&mut Ui, f32) -> R, add_contents: impl FnOnce(&mut Ui, f32) -> R,
) -> Option<InnerResponse<R>> { ) -> Option<InnerResponse<R>> {
#![expect(deprecated)]
let how_expanded = animate_expansion(ctx, expanded_panel.id.with("animation"), is_expanded); let how_expanded = animate_expansion(ctx, expanded_panel.id.with("animation"), is_expanded);
// Get either the fake or the real panel to animate // Get either the fake or the real panel to animate

View File

@@ -108,7 +108,7 @@ impl eframe::App for MyApp {
egui::ViewportBuilder::default() egui::ViewportBuilder::default()
.with_title("Immediate Viewport") .with_title("Immediate Viewport")
.with_inner_size([200.0, 100.0]), .with_inner_size([200.0, 100.0]),
|ctx, class| { |ui, class| {
puffin::profile_scope!("immediate_viewport"); puffin::profile_scope!("immediate_viewport");
assert!( assert!(
@@ -116,11 +116,11 @@ impl eframe::App for MyApp {
"This egui backend doesn't support multiple viewports" "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"); 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: // Tell parent viewport that we should not show next frame:
self.show_immediate_viewport = false; self.show_immediate_viewport = false;
} }
@@ -135,7 +135,7 @@ impl eframe::App for MyApp {
egui::ViewportBuilder::default() egui::ViewportBuilder::default()
.with_title("Deferred Viewport") .with_title("Deferred Viewport")
.with_inner_size([200.0, 100.0]), .with_inner_size([200.0, 100.0]),
move |ctx, class| { move |ui, class| {
puffin::profile_scope!("deferred_viewport"); puffin::profile_scope!("deferred_viewport");
assert!( assert!(
@@ -143,10 +143,10 @@ impl eframe::App for MyApp {
"This egui backend doesn't support multiple viewports" "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"); 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. // Tell parent to close us.
show_deferred_viewport.store(false, Ordering::Relaxed); show_deferred_viewport.store(false, Ordering::Relaxed);
} }