mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 14:49:06 -04:00
Deprecate using Panel directly on a Context (#7781)
Use `Panel::show_inside(ui)` instead!
This commit is contained in:
@@ -518,6 +518,7 @@ impl Panel {
|
||||
}
|
||||
|
||||
/// Show the panel at the top level.
|
||||
#[deprecated = "Use show_inside() instead"]
|
||||
pub fn show<R>(
|
||||
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<R>(
|
||||
self,
|
||||
ctx: &Context,
|
||||
is_expanded: bool,
|
||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||
) -> Option<InnerResponse<R>> {
|
||||
#![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<R>(
|
||||
ctx: &Context,
|
||||
is_expanded: bool,
|
||||
@@ -579,6 +584,8 @@ impl Panel {
|
||||
expanded_panel: Self,
|
||||
add_contents: impl FnOnce(&mut Ui, f32) -> R,
|
||||
) -> Option<InnerResponse<R>> {
|
||||
#![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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user