pub struct AnyElement(/* private fields */);Expand description
A dynamically typed element that can be used to store any element type.
Implementations§
Source§impl AnyElement
impl AnyElement
Sourcepub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>
Attempt to downcast a reference to the boxed element to a specific type.
Sourcepub fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId
pub fn request_layout(&mut self, window: &mut Window, cx: &mut App) -> LayoutId
Request the layout ID of the element stored in this AnyElement.
Used for laying out child elements in a parent element.
Sourcepub fn prepaint(
&mut self,
window: &mut Window,
cx: &mut App,
) -> Option<FocusHandle>
pub fn prepaint( &mut self, window: &mut Window, cx: &mut App, ) -> Option<FocusHandle>
Prepares the element to be painted by storing its bounds, giving it a chance to draw hitboxes and request autoscroll before the final paint pass is confirmed.
Sourcepub fn paint(&mut self, window: &mut Window, cx: &mut App)
pub fn paint(&mut self, window: &mut Window, cx: &mut App)
Paints the element stored in this AnyElement.
Sourcepub fn layout_as_root(
&mut self,
available_space: Size<AvailableSpace>,
window: &mut Window,
cx: &mut App,
) -> Size<Pixels>
pub fn layout_as_root( &mut self, available_space: Size<AvailableSpace>, window: &mut Window, cx: &mut App, ) -> Size<Pixels>
Performs layout for this element within the given available space and returns its size.
Sourcepub fn prepaint_at(
&mut self,
origin: Point<Pixels>,
window: &mut Window,
cx: &mut App,
) -> Option<FocusHandle>
pub fn prepaint_at( &mut self, origin: Point<Pixels>, window: &mut Window, cx: &mut App, ) -> Option<FocusHandle>
Prepaints this element at the given absolute origin. If any element in the subtree beneath this element is focused, its FocusHandle is returned.
Sourcepub fn prepaint_as_root(
&mut self,
origin: Point<Pixels>,
available_space: Size<AvailableSpace>,
window: &mut Window,
cx: &mut App,
) -> Option<FocusHandle>
pub fn prepaint_as_root( &mut self, origin: Point<Pixels>, available_space: Size<AvailableSpace>, window: &mut Window, cx: &mut App, ) -> Option<FocusHandle>
Performs layout on this element in the available space, then prepaints it at the given absolute origin. If any element in the subtree beneath this element is focused, its FocusHandle is returned.
Trait Implementations§
Source§impl Element for AnyElement
impl Element for AnyElement
Source§type RequestLayoutState = ()
type RequestLayoutState = ()
Element::request_layout. A mutable reference to this state is subsequently
provided to Element::prepaint and Element::paint.Source§type PrepaintState = ()
type PrepaintState = ()
Element::prepaint. A mutable reference to this state is subsequently
provided to Element::paint.Source§fn id(&self) -> Option<ElementId>
fn id(&self) -> Option<ElementId>
Source§fn source_location(&self) -> Option<&'static Location<'static>>
fn source_location(&self) -> Option<&'static Location<'static>>
Source§fn request_layout(
&mut self,
_: Option<&GlobalElementId>,
_inspector_id: Option<&InspectorElementId>,
window: &mut Window,
cx: &mut App,
) -> (LayoutId, Self::RequestLayoutState)
fn request_layout( &mut self, _: Option<&GlobalElementId>, _inspector_id: Option<&InspectorElementId>, window: &mut Window, cx: &mut App, ) -> (LayoutId, Self::RequestLayoutState)
Source§fn prepaint(
&mut self,
_: Option<&GlobalElementId>,
_inspector_id: Option<&InspectorElementId>,
_: Bounds<Pixels>,
_: &mut Self::RequestLayoutState,
window: &mut Window,
cx: &mut App,
)
fn prepaint( &mut self, _: Option<&GlobalElementId>, _inspector_id: Option<&InspectorElementId>, _: Bounds<Pixels>, _: &mut Self::RequestLayoutState, window: &mut Window, cx: &mut App, )
Element::request_layout().Source§fn paint(
&mut self,
_: Option<&GlobalElementId>,
_inspector_id: Option<&InspectorElementId>,
_: Bounds<Pixels>,
_: &mut Self::RequestLayoutState,
_: &mut Self::PrepaintState,
window: &mut Window,
cx: &mut App,
)
fn paint( &mut self, _: Option<&GlobalElementId>, _inspector_id: Option<&InspectorElementId>, _: Bounds<Pixels>, _: &mut Self::RequestLayoutState, _: &mut Self::PrepaintState, window: &mut Window, cx: &mut App, )
Element::request_layout().Source§fn into_any(self) -> AnyElement
fn into_any(self) -> AnyElement
AnyElement.Source§impl IntoElement for AnyElement
impl IntoElement for AnyElement
Source§type Element = AnyElement
type Element = AnyElement
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Auto Trait Implementations§
impl Freeze for AnyElement
impl !RefUnwindSafe for AnyElement
impl !Send for AnyElement
impl !Sync for AnyElement
impl Unpin for AnyElement
impl !UnwindSafe for AnyElement
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
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.Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 more