Skip to content

Commit

Permalink
CentralPanel: base id on the current viewport (#3593)
Browse files Browse the repository at this point in the history
This means two `CentralPanel`s in different viewports get different ids,
avoiding id clashes
  • Loading branch information
emilk authored Nov 20, 2023
1 parent 44ff29b commit 39271c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ impl CentralPanel {
) -> InnerResponse<R> {
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);
Expand Down
4 changes: 1 addition & 3 deletions crates/egui_demo_lib/src/demo/extra_viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/test_viewports/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 39271c3

Please sign in to comment.