Skip to content

Commit

Permalink
Make the demo a bit more pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmerlin committed Nov 14, 2024
1 parent 3517f7c commit b0f91a7
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions crates/egui_demo_lib/src/demo/modals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use egui::{vec2, Align, ComboBox, Context, Id, Layout, Modal, ProgressBar, Ui, Widget, Window};
use egui::{Align, ComboBox, Context, Id, Layout, Modal, ProgressBar, Ui, Widget, Window};

#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
Expand Down Expand Up @@ -36,8 +36,8 @@ impl crate::Demo for Modals {
use crate::View as _;
Window::new(self.name())
.open(open)
.default_size(vec2(512.0, 512.0))
.vscroll(false)
.resizable(false)
.show(ctx, |ui| self.ui(ui));
}
}
Expand All @@ -52,13 +52,22 @@ impl crate::View for Modals {
name,
} = self;

if ui.button("Open User Modal").clicked() {
*user_modal_open = true;
}
ui.horizontal(|ui| {
if ui.button("Open User Modal").clicked() {
*user_modal_open = true;
}

if ui.button("Open Save Modal").clicked() {
*save_modal_open = true;
}
if ui.button("Open Save Modal").clicked() {
*save_modal_open = true;
}
});

ui.label("Click one of the buttons to open a modal.");
ui.label("Modals have a backdrop and prevent interaction with the rest of the UI.");
ui.label(
"You can show modals on top of each other and close the top most modal with \
escape or by clicking outside the modal.",
);

if *user_modal_open {
let modal = Modal::new(Id::new("Modal A")).show(ui.ctx(), |ui| {
Expand Down Expand Up @@ -134,6 +143,10 @@ impl crate::View for Modals {
}
});
}

ui.vertical_centered(|ui| {
ui.add(crate::egui_github_link_file!());
});
}
}

Expand Down

0 comments on commit b0f91a7

Please sign in to comment.