pub enum OverlayBand {
Floating,
Tooltip,
}Expand description
The overlay portal’s own vocabulary, flat-re-exported from frust-core:
which z-band a floated surface sits in, whether the pointer reaches it, and
what a press landing outside it delivers.
overlay_portal floats a surface above the whole app, anchored to its
child’s bounds and painted after the entire main tree — so it escapes both
the child’s paint order and every ancestor’s clip, and follows the child
across scroll and relayout with nothing subscribed. The surface is mounted
while OverlayPortalView::overlay is Some; a widget that hosts a
surface of its own instead reaches for authoring::OverlaySlot.
Lifted flat for EditCommand’s reason: an app or design system naming a
band, an input class or a light-dismiss policy is configuring a portal, not
authoring a widget.
use frust::{
OverlayBand, OverlayInput, OverlayPlacement, OverlaySide, View, any, overlay_portal, text,
};
struct App {
hovering: bool,
}
// A tooltip: above its trigger, in the topmost band, and transparent to the
// pointer so hovering the trigger is never interrupted by its own tip.
fn trigger(state: &mut App) -> impl View<App> + use<> {
overlay_portal(text("Save"))
.overlay(state.hovering.then(|| any(text("Save the document"))))
.placement(OverlayPlacement::on(OverlaySide::Top))
.band(OverlayBand::Tooltip)
.input(OverlayInput::Transparent)
}Which z-band a registered surface paints and hit-tests in.
Two bands, ordered Floating below Tooltip: a tooltip explaining a
menu item must never be painted under the menu, and — because hit testing
walks the bands in reverse — must never steal the pointer from it either
(a tooltip is normally registered OverlayInput::Transparent anyway).
Registration order breaks ties within a band; the band itself always wins.
Variants§
Floating
Menus, popovers, dropdowns, selection toolbars — anything the user can interact with. Painted first, hit-tested last.
Tooltip
Tooltips and other explanatory chrome that must sit above everything else. Painted last, hit-tested first.
Trait Implementations§
Source§impl Clone for OverlayBand
impl Clone for OverlayBand
Source§fn clone(&self) -> OverlayBand
fn clone(&self) -> OverlayBand
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 OverlayBand
Source§impl Debug for OverlayBand
impl Debug for OverlayBand
impl Eq for OverlayBand
Source§impl Hash for OverlayBand
impl Hash for OverlayBand
Source§impl Ord for OverlayBand
impl Ord for OverlayBand
Source§fn cmp(&self, other: &OverlayBand) -> Ordering
fn cmp(&self, other: &OverlayBand) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for OverlayBand
impl PartialEq for OverlayBand
Source§impl PartialOrd for OverlayBand
impl PartialOrd for OverlayBand
impl StructuralPartialEq for OverlayBand
Auto Trait Implementations§
impl Freeze for OverlayBand
impl RefUnwindSafe for OverlayBand
impl Send for OverlayBand
impl Sync for OverlayBand
impl Unpin for OverlayBand
impl UnsafeUnpin for OverlayBand
impl UnwindSafe for OverlayBand
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.