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

Rename Panel methods (#8192)

The three methods for showing a `Panel` are now:

* `panel.show`: always show the panel.
* `panel.show_collapsible`: show or hide the panel, with a slide
animation in between.
* `Panel::show_switched`: animate between two different panels: a
thin/collapsed one and a thick/expanded one.
This commit is contained in:
Emil Ernerfeldt
2026-05-24 12:22:32 +02:00
committed by GitHub
parent 3cf844c542
commit 27559ef3fd
44 changed files with 159 additions and 99 deletions

View File

@@ -24,7 +24,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("Try to close the window");
});

View File

@@ -44,7 +44,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("The triangle is being painted using ");

View File

@@ -87,7 +87,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("egui using custom fonts");
ui.text_edit_multiline(&mut self.text);
});

View File

@@ -66,7 +66,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, content);
egui::CentralPanel::default().show(ui, content);
}
}

View File

@@ -58,7 +58,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("egui using a customized style");
ui.label("Switch between dark and light mode to see the different styles in action.");
global_theme_preference_buttons(ui);

View File

@@ -45,7 +45,7 @@ impl Default for MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("My External Eventloop Application");
ui.horizontal(|ui| {

View File

@@ -81,7 +81,7 @@ impl Default for MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("My External Eventloop Application");
ui.horizontal(|ui| {

View File

@@ -26,7 +26,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Drag-and-drop files onto the window!");
if ui.button("Open file…").clicked()

View File

@@ -77,7 +77,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("Font Variations (Recursive)");
ui.add_space(4.0);

View File

@@ -41,11 +41,11 @@ impl eframe::App for MyApp {
// TODO(lucasmerlin): This is a pretty big hack, should be fixed once safe_area implemented
// for android:
// https://github.com/rust-windowing/winit/issues/3910
egui::Panel::top("status_bar_space").show_inside(ui, |ui| {
egui::Panel::top("status_bar_space").show(ui, |ui| {
ui.set_height(32.0);
});
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
self.demo.ui(ui);
});
}

View File

@@ -37,7 +37,7 @@ impl Default for MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
let name_label = ui.label("Your name: ");

View File

@@ -16,7 +16,7 @@ fn main() -> eframe::Result {
let mut age = 42;
eframe::run_ui_native("My egui App", options, move |ui, _frame| {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
let name_label = ui.label("Your name: ");

View File

@@ -25,7 +25,7 @@ struct MyApp {}
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
egui::ScrollArea::both().show(ui, |ui| {
ui.image(egui::include_image!("cat.webp"))
.on_hover_text_at_pointer("WebP");

View File

@@ -21,7 +21,7 @@ struct Content {
impl eframe::App for Content {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("Press/Hold/Release example. Press A to test.");
if ui.button("Clear").clicked() {
self.text.clear();

View File

@@ -36,7 +36,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Hello from the root viewport");
ui.checkbox(
@@ -72,7 +72,7 @@ impl eframe::App for MyApp {
"This viewport is embedded in the parent window, and cannot be moved outside of it.",
);
} else {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Hello from immediate viewport");
if ui.input(|i| i.viewport().close_requested()) {
@@ -98,7 +98,7 @@ impl eframe::App for MyApp {
"This viewport is embedded in the parent window, and cannot be moved outside of it.",
);
} else {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Hello from deferred viewport");
if ui.input(|i| i.viewport().close_requested()) {

View File

@@ -19,7 +19,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut eframe::egui::Ui, _frame: &mut eframe::Frame) {
CentralPanel::default().show_inside(ui, |ui| {
CentralPanel::default().show(ui, |ui| {
ui.label("PopupCloseBehavior::CloseOnClick popup");
ComboBox::from_label("ComboBox")
.selected_text(format!("{}", self.number))

View File

@@ -55,7 +55,7 @@ impl Default for MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.heading("Example of how to use the puffin profiler with egui");
ui.separator();
@@ -116,7 +116,7 @@ impl eframe::App for MyApp {
"This egui backend doesn't support multiple viewports"
);
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Hello from immediate viewport");
});
@@ -143,7 +143,7 @@ impl eframe::App for MyApp {
"This egui backend doesn't support multiple viewports"
);
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
ui.label("Hello from deferred viewport");
});
if ui.input(|i| i.viewport().close_requested()) {

View File

@@ -28,7 +28,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
if let Some(screenshot) = self.screenshot.take() {
self.texture = Some(ui.ctx().load_texture(
"screenshot",

View File

@@ -44,7 +44,7 @@ struct MyApp {
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show_inside(ui, |ui| {
egui::CentralPanel::default().show(ui, |ui| {
let label_text = if self.has_next {
"When this window is closed the next will be opened after a short delay"
} else {

View File

@@ -76,7 +76,7 @@ impl eframe::App for Application {
));
}
CentralPanel::default().show_inside(ui, |ui| {
CentralPanel::default().show(ui, |ui| {
ui.vertical(|ui| {
ui.horizontal(|ui| {
ui.label("Attention type:");