From 39271c3adfad1e755ed546ee1f5cc1fb41d16af1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 20 Nov 2023 21:54:32 +0100 Subject: [PATCH] CentralPanel: base id on the current viewport (#3593) This means two `CentralPanel`s in different viewports get different ids, avoiding id clashes --- crates/egui/src/containers/panel.rs | 2 +- crates/egui_demo_lib/src/demo/extra_viewport.rs | 4 +--- examples/test_viewports/src/main.rs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index fc5f4299f23..2df79329eaf 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -1062,7 +1062,7 @@ impl CentralPanel { ) -> InnerResponse { let available_rect = ctx.available_rect(); let layer_id = LayerId::background(); - let id = Id::new("central_panel"); + let id = Id::new((ctx.viewport_id(), "central_panel")); let clip_rect = ctx.screen_rect(); let mut panel_ui = Ui::new(ctx.clone(), layer_id, id, available_rect, clip_rect); diff --git a/crates/egui_demo_lib/src/demo/extra_viewport.rs b/crates/egui_demo_lib/src/demo/extra_viewport.rs index 5ecebaa7120..5e1855ca5ed 100644 --- a/crates/egui_demo_lib/src/demo/extra_viewport.rs +++ b/crates/egui_demo_lib/src/demo/extra_viewport.rs @@ -33,9 +33,7 @@ impl super::Demo for ExtraViewport { }); } else { egui::CentralPanel::default().show(ctx, |ui| { - ui.push_id(id, |ui| { - viewport_content(ui, ctx, open); - }) + viewport_content(ui, ctx, open); }); } }, diff --git a/examples/test_viewports/src/main.rs b/examples/test_viewports/src/main.rs index 49277273746..7d85cc49385 100644 --- a/examples/test_viewports/src/main.rs +++ b/examples/test_viewports/src/main.rs @@ -178,7 +178,7 @@ fn show_as_popup( // Not a real viewport egui::Window::new(title).id(id).show(ctx, content); } else { - egui::CentralPanel::default().show(ctx, |ui| ui.push_id(id, content)); + egui::CentralPanel::default().show(ctx, content); } }