Clarify what happens when multiple modals are shown in the same frame (#5800)

* Closes #5788 
* [x] I have followed the instructions in the PR template
This commit is contained in:
Lucas Meurer 2025-03-18 11:30:32 +01:00 committed by GitHub
parent d698365dac
commit cf756df14d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -4,11 +4,14 @@ use crate::{
use emath::{Align2, Vec2}; use emath::{Align2, Vec2};
/// A modal dialog. /// A modal dialog.
///
/// Similar to a [`crate::Window`] but centered and with a backdrop that /// Similar to a [`crate::Window`] but centered and with a backdrop that
/// blocks input to the rest of the UI. /// blocks input to the rest of the UI.
/// ///
/// You can show multiple modals on top of each other. The topmost 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. /// the most recently shown one.
/// If multiple modals are newly shown in the same frame, the order of the modals not undefined
/// (either first or second could be top).
pub struct Modal { pub struct Modal {
pub area: Area, pub area: Area,
pub backdrop_color: Color32, pub backdrop_color: Color32,
@ -16,7 +19,9 @@ pub struct Modal {
} }
impl Modal { impl Modal {
/// Create a new Modal. The id is passed to the area. /// Create a new Modal.
///
/// The id is passed to the area.
pub fn new(id: Id) -> Self { pub fn new(id: Id) -> Self {
Self { Self {
area: Self::default_area(id), area: Self::default_area(id),
@ -26,6 +31,7 @@ impl Modal {
} }
/// Returns an area customized for a modal. /// Returns an area customized for a modal.
///
/// Makes these changes to the default area: /// Makes these changes to the default area:
/// - sense: hover /// - sense: hover
/// - anchor: center /// - anchor: center

View File

@ -8,6 +8,7 @@ use emath::{vec2, Align, Pos2, Rect, RectAlign, Vec2};
use std::iter::once; use std::iter::once;
/// What should we anchor the popup to? /// What should we anchor the popup to?
///
/// The final position for the popup will be calculated based on [`RectAlign`] /// The final position for the popup will be calculated based on [`RectAlign`]
/// and can be customized with [`Popup::align`] and [`Popup::align_alternatives`]. /// and can be customized with [`Popup::align`] and [`Popup::align_alternatives`].
/// [`PopupAnchor`] is the parent rect of [`RectAlign`]. /// [`PopupAnchor`] is the parent rect of [`RectAlign`].