1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Drag-to-close panels (#8182)

* Closes https://github.com/emilk/egui/pull/7254

You can now drag-to-close a panel. Also drag-to-expand panels.

This is a breaking change: the animated panel functions now take a
`open: &mut bool` instead of `open: bool`.

This is only enabled for resizable panels
This commit is contained in:
Emil Ernerfeldt
2026-05-22 16:05:39 +02:00
committed by GitHub
parent dcefb2e3b8
commit 3cf844c542
10 changed files with 463 additions and 53 deletions

View File

@@ -343,13 +343,14 @@ impl WrapApp {
fn backend_panel(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) -> Command {
// The backend-panel can be toggled on/off.
// We show a little animation when the user switches it.
let is_open = self.state.backend_panel.open || ui.memory(|mem| mem.everything_is_visible());
let mut is_open =
self.state.backend_panel.open || ui.memory(|mem| mem.everything_is_visible());
let mut cmd = Command::Nothing;
egui::Panel::left("backend_panel")
.resizable(false)
.show_animated_inside(ui, is_open, |ui| {
.show_animated_inside(ui, &mut is_open, |ui| {
ui.add_space(4.0);
ui.vertical_centered(|ui| {
ui.heading("💻 Backend");
@@ -359,6 +360,9 @@ impl WrapApp {
self.backend_panel_contents(ui, frame, &mut cmd);
});
// Allow drag-to-close to close the backend panel:
self.state.backend_panel.open = is_open;
cmd
}