Skip to main content

Popup

Struct Popup 

Source
pub struct Popup<T> { /* private fields */ }
Expand description

Popup state with an exit phase. gpui unmounts an element the frame its state drops, so a closing animation needs the state held alive while motion::menu_out plays: openbegin_close (render keeps mounting, with the out animation and dead hit-testing) → reap_popup’s timer finish_closees ~motion::MENU_OUT later. Use Self::is_open for logic (a closing popup already reads as closed) and Self::get / Self::is_closing for rendering.

Implementations§

Source§

impl<T> Popup<T>

Source

pub fn open(&mut self, value: T)

Source

pub fn is_open(&self) -> bool

Open and interactive (not closing).

Source

pub fn is_closing(&self) -> bool

Source

pub fn closing_since(&self) -> Option<Instant>

When the exit phase began — what the render path hands to the popover wrappers, which derive the eased exit progress from it each frame.

Source

pub fn get(&self) -> Option<&T>

The state while mounted — open OR playing the exit animation. Render paths use this; logic paths use Self::as_open/Self::open_mut.

Source

pub fn as_open(&self) -> Option<&T>

The state only while genuinely open — None during the exit phase, so event handlers on a dying popup fall through.

Source

pub fn open_mut(&mut self) -> Option<&mut T>

Source

pub fn close(&mut self)

Unmount now, with no exit phase.

For a surface that has no exit animation to play — modal, which takes no closing and paints the same either way. Sending one of those through Self::begin_close buys nothing and costs everything: it stays fully painted for the animation’s span, and if the reap never lands it stays forever, because nothing retries.

Not for a popup something toggles: unmounting on the press erases what Self::note_trigger_press has to read, so the note comes back false and the trigger reopens what it just shut. Those close through close_popup.

Source

pub fn begin_close(&mut self) -> bool

Enter the exit phase. Returns true when this call started it (the caller then schedules reap_popup); false if already closing or closed.

Source

pub fn note_trigger_press(&mut self)

Record, from the trigger’s on_mouse_down, whether this popup is still mounted. The anchored card’s on_mouse_down_out fires on that same press and begins the close, so by click (mouse-up) time the popup already reads as closed — the click handler alone cannot tell “this press dismissed it; stay closed” from “open fresh”, and a plain toggle closes-and-reopens (user report). Both handler orders work: open and mid-exit each count as mounted. Every trigger click is preceded by a trigger mouse-down, so the note is never stale.

menu_trigger wires this and the matching click together. Reach for it directly only when the open is not a click — a gutter handle whose menu belongs to the release of a possible drag.

Source

pub fn note_trigger_press_matching(&mut self, owns: impl FnOnce(&T) -> bool)

Self::note_trigger_press for popups whose state distinguishes which trigger owns them (e.g. one Popup<PickerKind> shared by several triggers): only a press on the OWNING trigger counts, so clicking a different trigger switches menus instead of swallowing.

Source

pub fn take_press_was_open(&mut self) -> bool

Consume the press note: true when the press that produced the current click found the popup mounted — the click should leave it closed rather than reopen it.

Source

pub fn finish_close(&mut self)

Drop the state now the exit phase has run its course. A popup reopened since the matching Self::begin_close is left alone — it is None again in the second slot, and the newer phase’s own reap handles it.

It does not re-check the clock. reap_popup already waited out the span on the executor’s timer, and asking Instant::elapsed to agree makes one deadline depend on two clocks — where they disagree, and a throttled executor is where, the popup is stranded open with nothing left to retry.

Trait Implementations§

Source§

impl<T> Default for Popup<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Popup<T>
where Option<(T, Option<Instant>)>: Freeze,

§

impl<T> RefUnwindSafe for Popup<T>

§

impl<T> Send for Popup<T>
where Option<(T, Option<Instant>)>: Send,

§

impl<T> Sync for Popup<T>
where Option<(T, Option<Instant>)>: Sync,

§

impl<T> Unpin for Popup<T>
where Option<(T, Option<Instant>)>: Unpin,

§

impl<T> UnsafeUnpin for Popup<T>

§

impl<T> UnwindSafe for Popup<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more