pub struct WidgetRef<'w, W: Widget + ?Sized> { /* private fields */ }
Expand description
A rich reference to a Widget
.
Widgets in Masonry are bundled with additional metadata called WidgetState
.
A WidgetRef
to a widget carries both a reference to the widget and to its WidgetState
. It can Deref
to the referenced widget.
This type is mostly used for debugging, to query a certain widget in the widget
graph, get their layout, etc. It also implements std::fmt::Debug
for convenience;
printing it will display its widget subtree (as in, the referenced widget, and its
children, and their children, etc).
This is only for shared access to widgets. For widget mutation, see WidgetMut
.
Implementations§
source§impl<'w, W: Widget + ?Sized> WidgetRef<'w, W>
impl<'w, W: Widget + ?Sized> WidgetRef<'w, W>
sourcepub fn state(self) -> &'w WidgetState
pub fn state(self) -> &'w WidgetState
Get the WidgetState
of the current widget.
source§impl<'w> WidgetRef<'w, dyn Widget>
impl<'w> WidgetRef<'w, dyn Widget>
sourcepub fn find_widget_by_id(
&self,
id: WidgetId
) -> Option<WidgetRef<'w, dyn Widget>>
pub fn find_widget_by_id( &self, id: WidgetId ) -> Option<WidgetRef<'w, dyn Widget>>
Recursively find child widget with given id.
sourcepub fn find_widget_at_pos(
&self,
pos: Point
) -> Option<WidgetRef<'w, dyn Widget>>
pub fn find_widget_at_pos( &self, pos: Point ) -> Option<WidgetRef<'w, dyn Widget>>
Recursively find innermost widget at given position.
pos - the position in local coordinates (zero being the top-left of the inner widget).
sourcepub fn debug_validate(&self, after_layout: bool)
pub fn debug_validate(&self, after_layout: bool)
Recursively check that the Widget tree upholds various invariants.
Can only be called after on_event and lifecycle.
Trait Implementations§
impl<'w, W: Widget + ?Sized> Copy for WidgetRef<'w, W>
Auto Trait Implementations§
impl<'w, W> Freeze for WidgetRef<'w, W>where
W: ?Sized,
impl<'w, W> RefUnwindSafe for WidgetRef<'w, W>where
W: RefUnwindSafe + ?Sized,
impl<'w, W> Send for WidgetRef<'w, W>
impl<'w, W> Sync for WidgetRef<'w, W>
impl<'w, W> Unpin for WidgetRef<'w, W>where
W: ?Sized,
impl<'w, W> UnwindSafe for WidgetRef<'w, W>where
W: RefUnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> AsAny for Twhere
T: Any,
impl<T> AsAny for Twhere
T: Any,
source§fn as_dyn_any(&self) -> &(dyn Any + 'static)
fn as_dyn_any(&self) -> &(dyn Any + 'static)
source§fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)
fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)
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<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.