pub enum OverlayAnchor {
Owner,
Rect(Rect),
Window {
point: Point,
offset: Vec2,
},
}Expand description
The overlay-portal authoring surface: the slot a widget that floats its own surface holds, what that surface is anchored to, and the placement geometry every anchored pattern needs.
Promoted here rather than left to each design system because all three of
them had derived the same geometry independently: a design system’s popover,
menu, tooltip and context menu place a surface through place and host it
through OverlaySlot, reaching both through frust::authoring alone.
What a slot places its surface against.
Owner and Rect resolve to a window-space rect in the owner’s
paint, where the owner’s absolute origin is finally known; nothing is
subscribed to and nothing is cached across frames, so an anchor follows
its owner across scroll, relayout and animation for free. Window is
already window-space and skips that resolution entirely — see its own
docs for why it is updated from event instead.
Variants§
Owner
The owner’s own bounds — a trigger floating a menu under itself.
Rect(Rect)
A rect in the owner’s local space: a caret, a selection’s bounding
box, a press point, one row of a list. Translated by the owner’s paint
origin, so a caller states it in the same coordinates its layout and
event already speak.
Window
An absolute window-space point the surface’s top-left tracks directly — a drag ghost following the pointer rather than an owner’s bounds.
The placed rect is always point + offset, sized to the pod’s own
content size: no side, alignment or collision flip applies, because
there is no anchor rect to place against, only a point — so none of
OverlayPlacement’s side/align/flip/clamp fields apply to it either
(place is never called for this variant). The rect is clamped into
the window area when OverlaySlot::set_clamp_to_window has turned
that on (default false, so the ghost may trail off the window’s edge
with the pointer).
Set once (with whatever offset the gesture’s grab point needs) via
OverlaySlot::set_anchor, then updated every pointer Move/Down
with OverlaySlot::set_window_anchor, which keeps offset and only
moves point — see that method for why the update belongs in the
owner’s event rather than waiting for the next paint.
Trait Implementations§
Source§impl Clone for OverlayAnchor
impl Clone for OverlayAnchor
Source§fn clone(&self) -> OverlayAnchor
fn clone(&self) -> OverlayAnchor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for OverlayAnchor
Source§impl Debug for OverlayAnchor
impl Debug for OverlayAnchor
Source§impl Default for OverlayAnchor
impl Default for OverlayAnchor
Source§fn default() -> OverlayAnchor
fn default() -> OverlayAnchor
Source§impl PartialEq for OverlayAnchor
impl PartialEq for OverlayAnchor
impl StructuralPartialEq for OverlayAnchor
Auto Trait Implementations§
impl Freeze for OverlayAnchor
impl RefUnwindSafe for OverlayAnchor
impl Send for OverlayAnchor
impl Sync for OverlayAnchor
impl Unpin for OverlayAnchor
impl UnsafeUnpin for OverlayAnchor
impl UnwindSafe for OverlayAnchor
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<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.