pub struct Element { /* private fields */ }Expand description
A rendered ElementComponent instance.
Implementations§
Source§impl Element
impl Element
Sourcepub fn from_element_component(part: Box<dyn ElementComponent>) -> Element
pub fn from_element_component(part: Box<dyn ElementComponent>) -> Element
Creates a new Element from the given component.
Sourcepub fn vec_of(self) -> Vec<Element>
pub fn vec_of(self) -> Vec<Element>
Convenience method to construct a Vec<Element> from a single Element.
Sourcepub fn with<T>(self, component: Component<T>, value: T) -> Element
pub fn with<T>(self, component: Component<T>, value: T) -> Element
Adds the given component with value to the element.
Sourcepub fn with_default<T>(self, component: Component<T>) -> Element
pub fn with_default<T>(self, component: Component<T>) -> Element
Adds the given component with the default value for the component’s type to the element.
Sourcepub fn init<T>(self, component: Component<T>, value: T) -> Element
pub fn init<T>(self, component: Component<T>, value: T) -> Element
Sets the given component to value on the element during initialization only.
Sourcepub fn init_default<T>(self, component: Component<T>) -> Element
pub fn init_default<T>(self, component: Component<T>) -> Element
Calls Self::init with the default value for the component’s type.
Sourcepub fn extend(self, entity_data: Entity) -> Element
pub fn extend(self, entity_data: Entity) -> Element
Extends the element with all of the values from the given Entity.
Sourcepub fn init_extend(self, entity_data: Entity) -> Element
pub fn init_extend(self, entity_data: Entity) -> Element
See Element::init; adds each entry in the Entity to init
Sourcepub fn remove<T>(self, component: Component<T>) -> Elementwhere
T: ComponentValue + Clone,
pub fn remove<T>(self, component: Component<T>) -> Elementwhere
T: ComponentValue + Clone,
Removes the given component from the element.
Warning: this only removes components on the current element.
Sourcepub fn on_spawned<F>(self, handler: F) -> Element
pub fn on_spawned<F>(self, handler: F) -> Element
Set the callback to call when the element is spawned.
Sourcepub fn on_despawn<F>(self, handler: F) -> Element
pub fn on_despawn<F>(self, handler: F) -> Element
Set the callback to call when the element is despawned.
Sourcepub fn key<T>(self, key: T) -> Element
pub fn key<T>(self, key: T) -> Element
Set the unique key used to identify this element.
This is used to disambiguate elements with the same type. This should be used when rendering lists of elements.
Sourcepub fn memoize_subtree(self, memo_key: impl Into<String>) -> Element
pub fn memoize_subtree(self, memo_key: impl Into<String>) -> Element
Avoid rendering the subtree, except when the memo_key is changed.
Sourcepub fn has_component(&self, component: impl Into<ComponentDesc>) -> bool
pub fn has_component(&self, component: impl Into<ComponentDesc>) -> bool
Returns true if the element has the given component.
Sourcepub fn spawn_static(self, world: &mut World) -> EntityId
pub fn spawn_static(self, world: &mut World) -> EntityId
This spawns the element tree as a number of entities, but they won’t react to changes. Returns the root entity
Sourcepub fn spawn_interactive(self, world: &mut World) -> EntityId
pub fn spawn_interactive(self, world: &mut World) -> EntityId
This spawns the element tree plus a handle entity which will have an element_tree component on it. All
element_tree components get updated each frame so this entity tree will be updated
Sourcepub fn spawn_tree(self, world: &mut World) -> ElementTree
pub fn spawn_tree(self, world: &mut World) -> ElementTree
This spawns the elemet tree and returns it. The tree won’t be automatically updated, but can manually be updated
by calling the update method.
Trait Implementations§
Source§impl<T> From<T> for Elementwhere
T: ElementComponent + 'static,
impl<T> From<T> for Elementwhere
T: ElementComponent + 'static,
Source§impl StylesExt for Element
impl StylesExt for Element
Source§fn section_style(self) -> Element
fn section_style(self) -> Element
Source§fn header_style(self) -> Element
fn header_style(self) -> Element
Source§fn small_style(self) -> Element
fn small_style(self) -> Element
Source§fn error_text_style(self) -> Element
fn error_text_style(self) -> Element
Source§fn floating_panel(self) -> Element
fn floating_panel(self) -> Element
Source§impl UIExt for Element
impl UIExt for Element
Source§fn with_clickarea(self) -> ClickArea
fn with_clickarea(self) -> ClickArea
Source§fn with_background(self, background: Vec4) -> Element
fn with_background(self, background: Vec4) -> Element
Source§fn with_padding_even(self, value: f32) -> Element
fn with_padding_even(self, value: f32) -> Element
Source§fn with_margin_even(self, value: f32) -> Element
fn with_margin_even(self, value: f32) -> Element
Auto Trait Implementations§
impl Freeze for Element
impl !RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl !UnwindSafe for Element
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ComponentValueBase for T
impl<T> ComponentValueBase for 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> ElementComponentName for T
impl<T> ElementComponentName for T
Source§fn element_component_name(&self) -> &'static str
fn element_component_name(&self) -> &'static str
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<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().