mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Panel collapse/expansion animation (#2190)
* Add API for querying the size of a panel * demo app: animate backend panel collapse * Add helper function for animating panels * More animation functions * Add line to changelog
This commit is contained in:
@@ -200,19 +200,8 @@ impl eframe::App for WrapApp {
|
||||
|
||||
self.state.backend_panel.update(ctx, frame);
|
||||
|
||||
if !is_mobile(ctx)
|
||||
&& (self.state.backend_panel.open || ctx.memory().everything_is_visible())
|
||||
{
|
||||
egui::SidePanel::left("backend_panel")
|
||||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.heading("💻 Backend");
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
self.backend_panel_contents(ui, frame);
|
||||
});
|
||||
if !is_mobile(ctx) {
|
||||
self.backend_panel(ctx, frame);
|
||||
}
|
||||
|
||||
self.show_selected_app(ctx, frame);
|
||||
@@ -236,6 +225,23 @@ impl eframe::App for WrapApp {
|
||||
}
|
||||
|
||||
impl WrapApp {
|
||||
fn backend_panel(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
// 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 || ctx.memory().everything_is_visible();
|
||||
|
||||
egui::SidePanel::left("backend_panel")
|
||||
.resizable(false)
|
||||
.show_animated(ctx, is_open, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.heading("💻 Backend");
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
self.backend_panel_contents(ui, frame);
|
||||
});
|
||||
}
|
||||
|
||||
fn backend_panel_contents(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
|
||||
self.state.backend_panel.ui(ui, frame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user