pub struct Popup<W: Widget> {
pub inner: W,
/* private fields */
}
Expand description
A popup (e.g. menu or tooltip)
A pop-up is a box used for things like tool-tips and menus which escapes the parent’s rect. This widget is the root of any popup UI.
This widget must be excluded from the parent’s layout.
Depending on the platform, the pop-up may be a special window or emulate this with a layer drawn in an existing window. Both approaches should exhibit similar behaviour except that the former approach allows the popup to escape the bounds of the parent window. NOTE: currently only the emulated approach is implemented.
A popup receives input data from its parent like any other widget.
Fields§
§inner: W
The inner widget
Implementations§
Source§impl<W: Widget> Popup<W>
impl<W: Widget> Popup<W>
Sourcepub fn new(inner: W, direction: Direction) -> Self
pub fn new(inner: W, direction: Direction) -> Self
Construct a popup over a W: Widget
Popup placement is determined by direction
and alignment (see
Self::align
).
Sourcepub fn set_direction(&mut self, direction: Direction)
pub fn set_direction(&mut self, direction: Direction)
Set direction
The popup is placed next to a reference Rect
in this
direction
, if possible; otherwise it is placed in the opposite
direction. See also Self::align
.
Sourcepub fn align(self, align: Align) -> Self
pub fn align(self, align: Align) -> Self
Set alignment (inline)
After the popup is placed to one side of a reference Rect
(see
Self::set_direction
), it is aligned according to align
:
Align::Default
,Align::TL
: align with the top/left edge of the referenceRect
Align::BR
: align with the bottom/right edge of the referenceRect
Align::Center
: center relative to the referenceRect
Align::Stretch
: align likeAlign::Default
but ensuring the popup is no shorter than the referenceRect
on the touching side
Sourcepub fn open(
&mut self,
cx: &mut EventCx<'_>,
data: &W::Data,
parent: Id,
set_focus: bool,
) -> bool
pub fn open( &mut self, cx: &mut EventCx<'_>, data: &W::Data, parent: Id, set_focus: bool, ) -> bool
Open or reposition the popup
The popup is positioned next to the parent
’s rect (see Self::set_direction
,
Self::align
).
The parent
is marked as depressed (pushed down) while the popup is
open.
Returns true
when the popup is newly opened. In this case, the
caller may wish to call EventState::next_nav_focus
next.
Trait Implementations§
Source§impl<W: Widget> Events for Popup<W>
impl<W: Widget> Events for Popup<W>
Source§fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn handle_scroll(&mut self, cx: &mut EventCx<'_>, _: &Self::Data, _: Scroll)
fn handle_scroll(&mut self, cx: &mut EventCx<'_>, _: &Self::Data, _: Scroll)
Source§const REDRAW_ON_MOUSE_OVER: bool = false
const REDRAW_ON_MOUSE_OVER: bool = false
Source§fn mouse_over_icon(&self) -> Option<CursorIcon>
fn mouse_over_icon(&self) -> Option<CursorIcon>
Source§fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§impl<W: Widget> Layout for Popup<W>
impl<W: Widget> Layout for Popup<W>
Source§impl<W: Widget> MacroDefinedLayout for Popup<W>
impl<W: Widget> MacroDefinedLayout for Popup<W>
Source§impl<W: Widget> Tile for Popup<W>
impl<W: Widget> Tile for Popup<W>
Source§fn child_indices(&self) -> ChildIndices
fn child_indices(&self) -> ChildIndices
Source§fn find_child_index(&self, id: &Id) -> Option<usize>
fn find_child_index(&self, id: &Id) -> Option<usize>
id
, if any Read moreSource§fn get_child(&self, index: usize) -> Option<&dyn Tile>
fn get_child(&self, index: usize) -> Option<&dyn Tile>
dyn Tile
, if available Read moreAuto Trait Implementations§
impl<W> Freeze for Popup<W>where
W: Freeze,
impl<W> RefUnwindSafe for Popup<W>where
W: RefUnwindSafe,
impl<W> !Send for Popup<W>
impl<W> !Sync for Popup<W>
impl<W> Unpin for Popup<W>where
W: Unpin,
impl<W> UnwindSafe for Popup<W>where
W: UnwindSafe,
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<W> TileExt for W
impl<W> TileExt for W
Source§fn is_strict_ancestor_of(&self, id: &Id) -> bool
fn is_strict_ancestor_of(&self, id: &Id) -> bool
id
is not self and is a descendant Read more