From 46c13feb9da7bc245342142509947c7a9bd51ce5 Mon Sep 17 00:00:00 2001 From: lucasmerlin Date: Thu, 28 Nov 2024 12:13:27 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Emil Ernerfeldt --- crates/egui/src/containers/modal.rs | 11 +++++++---- crates/egui_demo_lib/src/demo/modals.rs | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/containers/modal.rs b/crates/egui/src/containers/modal.rs index dbcdc73f18d6..b164ae8ab586 100644 --- a/crates/egui/src/containers/modal.rs +++ b/crates/egui/src/containers/modal.rs @@ -7,7 +7,7 @@ use emath::{Align2, Vec2}; /// Similar to a [`crate::Window`] but centered and with a backdrop that /// blocks input to the rest of the UI. /// -/// You can show multiple modals on top of each other. The top most modal will always be +/// You can show multiple modals on top of each other. The topmost modal will always be /// the most recently shown one. pub struct Modal { pub area: Area, @@ -129,13 +129,16 @@ pub struct ModalResponse { /// The response of the modal contents pub response: Response, - /// The response of the modal backdrop + /// The response of the modal backdrop. + /// + /// A click on this means the user clicked outside the modal, + /// in which case you might want to close the modal. pub backdrop_response: Response, /// The inner response from the content closure pub inner: T, - /// Is this the top most modal? + /// Is this the topmost modal? pub is_top_modal: bool, /// Is there any popup open? @@ -148,7 +151,7 @@ impl ModalResponse { /// Should the modal be closed? /// Returns true if: /// - the backdrop was clicked - /// - this is the top most modal, no popup is open and the escape key was pressed + /// - this is the topmost modal, no popup is open and the escape key was pressed pub fn should_close(&self) -> bool { let ctx = &self.response.ctx; let escape_clicked = ctx.input(|i| i.key_pressed(crate::Key::Escape)); diff --git a/crates/egui_demo_lib/src/demo/modals.rs b/crates/egui_demo_lib/src/demo/modals.rs index 75ca2f61161d..dd3f7c489d00 100644 --- a/crates/egui_demo_lib/src/demo/modals.rs +++ b/crates/egui_demo_lib/src/demo/modals.rs @@ -65,7 +65,7 @@ impl crate::View for Modals { 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 \ + "You can show modals on top of each other and close the topmost modal with \ escape or by clicking outside the modal.", ); @@ -129,7 +129,7 @@ impl crate::View for Modals { if let Some(progress) = *save_progress { Modal::new(Id::new("Modal C")).show(ui.ctx(), |ui| { ui.set_width(70.0); - ui.heading("Saving..."); + ui.heading("Saving…"); ProgressBar::new(progress).ui(ui);