parent
14c2e5d3d5
commit
c0325e9be2
|
|
@ -1,5 +1,13 @@
|
||||||
|
#[expect(unused_imports)]
|
||||||
|
use crate::{Ui, UiBuilder};
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
|
/// A tag to mark a container as closable.
|
||||||
|
///
|
||||||
|
/// Usually set via [`UiBuilder::closable`].
|
||||||
|
///
|
||||||
|
/// [`Ui::close`] will find the closest parent [`ClosableTag`] and set its `close` field to `true`.
|
||||||
|
/// Use [`Ui::should_close`] to check if close has been called.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ClosableTag {
|
pub struct ClosableTag {
|
||||||
pub close: AtomicBool,
|
pub close: AtomicBool,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
//! See [`MenuBar`] for an example
|
//! Popup menus, context menus and menu bars.
|
||||||
|
//!
|
||||||
|
//! Show menus via
|
||||||
|
//! - [`Popup::menu`] and [`Popup::context_menu`]
|
||||||
|
//! - [`Ui::menu_button`], [`MenuButton`] and [`SubMenuButton`]
|
||||||
|
//! - [`MenuBar`]
|
||||||
|
//! - [`Response::context_menu`]
|
||||||
|
//!
|
||||||
|
//! See [`MenuBar`] for an example.
|
||||||
|
|
||||||
use crate::style::StyleModifier;
|
use crate::style::StyleModifier;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -52,6 +60,7 @@ pub fn is_in_menu(ui: &Ui) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configuration and style for menus.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct MenuConfig {
|
pub struct MenuConfig {
|
||||||
/// Is this a menu bar?
|
/// Is this a menu bar?
|
||||||
|
|
@ -122,8 +131,10 @@ impl MenuConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Holds the state of the menu.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MenuState {
|
pub struct MenuState {
|
||||||
|
/// The currently open sub menu in this menu.
|
||||||
pub open_item: Option<Id>,
|
pub open_item: Option<Id>,
|
||||||
last_visible_pass: u64,
|
last_visible_pass: u64,
|
||||||
}
|
}
|
||||||
|
|
@ -359,6 +370,10 @@ impl<'a> SubMenuButton<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show a submenu in a menu.
|
||||||
|
///
|
||||||
|
/// Useful if you want to make custom menu buttons.
|
||||||
|
/// Usually, just use [`MenuButton`] or [`SubMenuButton`] instead.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct SubMenu {
|
pub struct SubMenu {
|
||||||
config: Option<MenuConfig>,
|
config: Option<MenuConfig>,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
//! For instance, a [`Frame`] adds a frame and background to some contained UI.
|
//! For instance, a [`Frame`] adds a frame and background to some contained UI.
|
||||||
|
|
||||||
pub(crate) mod area;
|
pub(crate) mod area;
|
||||||
pub mod close_tag;
|
mod close_tag;
|
||||||
pub mod collapsing_header;
|
pub mod collapsing_header;
|
||||||
mod combo_box;
|
mod combo_box;
|
||||||
pub mod frame;
|
pub mod frame;
|
||||||
|
|
@ -21,6 +21,7 @@ pub(crate) mod window;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
area::{Area, AreaState},
|
area::{Area, AreaState},
|
||||||
|
close_tag::ClosableTag,
|
||||||
collapsing_header::{CollapsingHeader, CollapsingResponse},
|
collapsing_header::{CollapsingHeader, CollapsingResponse},
|
||||||
combo_box::*,
|
combo_box::*,
|
||||||
frame::Frame,
|
frame::Frame,
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ impl From<PopupKind> for UiKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A popup container.
|
||||||
#[must_use = "Call `.show()` to actually display the popup"]
|
#[must_use = "Call `.show()` to actually display the popup"]
|
||||||
pub struct Popup<'a> {
|
pub struct Popup<'a> {
|
||||||
id: Id,
|
id: Id,
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use emath::GuiRounding as _;
|
||||||
use epaint::mutex::RwLock;
|
use epaint::mutex::RwLock;
|
||||||
use std::{any::Any, hash::Hash, sync::Arc};
|
use std::{any::Any, hash::Hash, sync::Arc};
|
||||||
|
|
||||||
|
use crate::ClosableTag;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
use crate::Stroke;
|
use crate::Stroke;
|
||||||
use crate::close_tag::ClosableTag;
|
|
||||||
use crate::containers::menu;
|
use crate::containers::menu;
|
||||||
use crate::{
|
use crate::{
|
||||||
Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms,
|
Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::{hash::Hash, sync::Arc};
|
use std::{hash::Hash, sync::Arc};
|
||||||
|
|
||||||
|
use crate::ClosableTag;
|
||||||
#[expect(unused_imports)] // Used for doclinks
|
#[expect(unused_imports)] // Used for doclinks
|
||||||
use crate::Ui;
|
use crate::Ui;
|
||||||
use crate::close_tag::ClosableTag;
|
|
||||||
use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo};
|
use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo};
|
||||||
|
|
||||||
/// Build a [`Ui`] as the child of another [`Ui`].
|
/// Build a [`Ui`] as the child of another [`Ui`].
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue