pub struct Popup<'a> { /* private fields */ }Expand description
A popup container.
Implementations§
Source§impl<'a> Popup<'a>
impl<'a> Popup<'a>
Sourcepub fn new(
id: Id,
ctx: Context,
anchor: impl Into<PopupAnchor>,
layer_id: LayerId,
) -> Popup<'a>
pub fn new( id: Id, ctx: Context, anchor: impl Into<PopupAnchor>, layer_id: LayerId, ) -> Popup<'a>
Create a new popup
Sourcepub fn from_response(response: &Response) -> Popup<'a>
pub fn from_response(response: &Response) -> Popup<'a>
Show a popup relative to some widget. The popup will be always open.
See Self::menu and Self::context_menu for common use cases.
Show a popup relative to some widget, toggling the open state based on the widget’s click state.
See Self::menu and Self::context_menu for common use cases.
Show a popup when the widget was clicked.
Sets the layout to Layout::top_down_justified(Align::Min).
Show a context menu when the widget was secondary clicked.
Sets the layout to Layout::top_down_justified(Align::Min).
In contrast to Self::menu, this will open at the pointer position.
Sourcepub fn kind(self, kind: PopupKind) -> Popup<'a>
pub fn kind(self, kind: PopupKind) -> Popup<'a>
Set the kind of the popup. Used for Area::kind and Area::order.
Sourcepub fn info(self, info: UiStackInfo) -> Popup<'a>
pub fn info(self, info: UiStackInfo) -> Popup<'a>
Set the UiStackInfo of the popup’s Ui.
Sourcepub fn align(self, position_align: RectAlign) -> Popup<'a>
pub fn align(self, position_align: RectAlign) -> Popup<'a>
Set the RectAlign of the popup relative to the PopupAnchor.
This is the default position, and will be used if it fits.
See Self::align_alternatives for more on this.
Sourcepub fn align_alternatives(self, alternatives: &'a [RectAlign]) -> Popup<'a>
pub fn align_alternatives(self, alternatives: &'a [RectAlign]) -> Popup<'a>
Set alternative positions to try if the default one doesn’t fit. Set to an empty slice to
always use the position you set with Self::align.
By default, this will try RectAlign::symmetries and then RectAlign::MENU_ALIGNS.
Sourcepub fn open_memory(
self,
set_state: impl Into<Option<SetOpenCommand>>,
) -> Popup<'a>
pub fn open_memory( self, set_state: impl Into<Option<SetOpenCommand>>, ) -> Popup<'a>
Store the open state via crate::Memory.
You can set the state via the first SetOpenCommand param.
Sourcepub fn open_bool(self, open: &'a mut bool) -> Popup<'a>
pub fn open_bool(self, open: &'a mut bool) -> Popup<'a>
Store the open state via a mutable bool.
Sourcepub fn close_behavior(self, close_behavior: PopupCloseBehavior) -> Popup<'a>
pub fn close_behavior(self, close_behavior: PopupCloseBehavior) -> Popup<'a>
Set the close behavior of the popup.
This will do nothing if Popup::open was called.
Sourcepub fn at_pointer(self) -> Popup<'a>
pub fn at_pointer(self) -> Popup<'a>
Show the popup relative to the pointer.
Sourcepub fn at_pointer_fixed(self) -> Popup<'a>
pub fn at_pointer_fixed(self) -> Popup<'a>
Remember the pointer position at the time of opening the popup, and show the popup relative to that.
Sourcepub fn at_position(self, position: Pos2) -> Popup<'a>
pub fn at_position(self, position: Pos2) -> Popup<'a>
Show the popup relative to a specific position.
Sourcepub fn anchor(self, anchor: impl Into<PopupAnchor>) -> Popup<'a>
pub fn anchor(self, anchor: impl Into<PopupAnchor>) -> Popup<'a>
Show the popup relative to the given PopupAnchor.
Sourcepub fn anchor_widget(self, widget_id: Id) -> Popup<'a>
pub fn anchor_widget(self, widget_id: Id) -> Popup<'a>
The widget this popup belongs to.
The popup is nested under it in the accessibility tree.
Set automatically by Self::from_response and everything built on it.
Sourcepub fn accessible_name(self, name: impl Into<String>) -> Popup<'a>
pub fn accessible_name(self, name: impl Into<String>) -> Popup<'a>
Name the popup in the accessibility tree.
Sourcepub fn interactable(self, interactable: bool) -> Popup<'a>
pub fn interactable(self, interactable: bool) -> Popup<'a>
If false, the pointer goes straight through the popup and it’s widgets to whatever is behind it.
Default: true.
Sourcepub fn width(self, width: f32) -> Popup<'a>
pub fn width(self, width: f32) -> Popup<'a>
The width that will be passed to Area::default_width.
Sourcepub fn sizing_pass(self, sizing_pass: bool) -> Popup<'a>
pub fn sizing_pass(self, sizing_pass: bool) -> Popup<'a>
Force the popup’s underlying Area to run an invisible sizing pass.
Popups automatically run a sizing pass when they open or reopen. Set this to true for
one frame when the contents of an already open popup change and its cached size may no
longer fit. Do not leave it enabled continuously, because the popup would remain invisible.
Default: false.
Sourcepub fn style(self, style: impl Into<StyleModifier>) -> Popup<'a>
pub fn style(self, style: impl Into<StyleModifier>) -> Popup<'a>
Set the style for the popup contents.
Default:
- is
menu_styleforSelf::menuandSelf::context_menu - is
Noneotherwise
Sourcepub fn get_anchor(&self) -> PopupAnchor
pub fn get_anchor(&self) -> PopupAnchor
Return the PopupAnchor of the popup.
Sourcepub fn get_anchor_rect(&self) -> Option<Rect>
pub fn get_anchor_rect(&self) -> Option<Rect>
Return the anchor rect of the popup.
Returns None if the anchor is PopupAnchor::Pointer and there is no pointer.
Sourcepub fn get_popup_rect(&self) -> Option<Rect>
pub fn get_popup_rect(&self) -> Option<Rect>
Get the expected rect the popup will be shown in.
Returns None if the popup wasn’t shown before or anchor is PopupAnchor::Pointer and
there is no pointer.
Sourcepub fn get_expected_size(&self) -> Option<Vec2>
pub fn get_expected_size(&self) -> Option<Vec2>
Get the expected size of the popup.
Sourcepub fn get_best_align(&self) -> RectAlign
pub fn get_best_align(&self) -> RectAlign
Calculate the best alignment for the popup, based on the last size and screen rect.
Source§impl Popup<'_>
§Static methods
impl Popup<'_>
§Static methods
Sourcepub fn default_response_id(response: &Response) -> Id
pub fn default_response_id(response: &Response) -> Id
The default ID when constructing a popup from the Response of e.g. a button.
Sourcepub fn is_id_open(ctx: &Context, popup_id: Id) -> bool
pub fn is_id_open(ctx: &Context, popup_id: Id) -> bool
Is the given popup open?
This assumes the use of either:
The popup id should be the same as either you set with Self::id or the
default one from Self::default_response_id.
Sourcepub fn is_any_open(ctx: &Context) -> bool
pub fn is_any_open(ctx: &Context) -> bool
Is any popup open?
This assumes the egui memory is being used to track the open state of popups.
Sourcepub fn toggle_id(ctx: &Context, popup_id: Id)
pub fn toggle_id(ctx: &Context, popup_id: Id)
Toggle the given popup between closed and open.
Note: At most, only one popup can be open at a time.
Sourcepub fn close_id(ctx: &Context, popup_id: Id)
pub fn close_id(ctx: &Context, popup_id: Id)
Close the given popup, if it is open.
See also Self::close_all if you want to close any / all currently open popups.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Popup<'a>
impl<'a> !UnwindSafe for Popup<'a>
impl<'a> Forget for Popup<'a>
impl<'a> Freeze for Popup<'a>
impl<'a> Move for Popup<'a>
impl<'a> Send for Popup<'a>
impl<'a> Sync for Popup<'a>
impl<'a> Unpin for Popup<'a>
impl<'a> UnsafeUnpin for Popup<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more