Element

Struct Element 

Source
pub struct Element { /* private fields */ }
Expand description

A rendered ElementComponent instance.

Implementations§

Source§

impl Element

Source

pub fn new() -> Element

Creates a new Element with no children.

Source

pub fn from_element_component(part: Box<dyn ElementComponent>) -> Element

Creates a new Element from the given component.

Source

pub fn vec_of(self) -> Vec<Element>

Convenience method to construct a Vec<Element> from a single Element.

Source

pub fn with<T>(self, component: Component<T>, value: T) -> Element
where T: ComponentValue + Sync + Send + Clone + 'static,

Adds the given component with value to the element.

Source

pub fn with_default<T>(self, component: Component<T>) -> Element
where T: ComponentValue + Sync + Send + Clone + Default + 'static,

Adds the given component with the default value for the component’s type to the element.

Source

pub fn init<T>(self, component: Component<T>, value: T) -> Element
where T: ComponentValue + Sync + Send + Clone + 'static,

Sets the given component to value on the element during initialization only.

Source

pub fn init_default<T>(self, component: Component<T>) -> Element
where T: ComponentValue + Sync + Send + Clone + Default + 'static,

Calls Self::init with the default value for the component’s type.

Source

pub fn extend(self, entity_data: Entity) -> Element

Extends the element with all of the values from the given Entity.

Source

pub fn init_extend(self, entity_data: Entity) -> Element

See Element::init; adds each entry in the Entity to init

Source

pub fn remove<T>(self, component: Component<T>) -> Element
where T: ComponentValue + Clone,

Removes the given component from the element.

Warning: this only removes components on the current element.

Source

pub fn children(self, children: Vec<Element>) -> Element

Sets the children of the element.

Source

pub fn spawner<F>(self, handler: F) -> Element
where F: Fn(&mut World, Entity) -> EntityId + Sync + Send + 'static,

Set the function used to spawn the element.

Source

pub fn despawner<F>(self, handler: F) -> Element
where F: Fn(&mut World, EntityId) + Sync + Send + 'static,

Set the function used to despawn the element.

Source

pub fn on_spawned<F>(self, handler: F) -> Element
where F: Fn(&mut World, EntityId, &str) + Sync + Send + 'static,

Set the callback to call when the element is spawned.

Source

pub fn on_despawn<F>(self, handler: F) -> Element
where F: Fn(&mut World, EntityId, &str) + Sync + Send + 'static,

Set the callback to call when the element is despawned.

Source

pub fn key<T>(self, key: T) -> Element
where T: Into<String>,

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.

Source

pub fn memoize_subtree(self, memo_key: impl Into<String>) -> Element

Avoid rendering the subtree, except when the memo_key is changed.

Source

pub fn has_component(&self, component: impl Into<ComponentDesc>) -> bool

Returns true if the element has the given component.

Source

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

Source

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

Source

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 Clone for Element

Source§

fn clone(&self) -> Element

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Element

Source§

fn default() -> Element

Returns the “default value” for a type. Read more
Source§

impl From<Element> for UIElement

Source§

fn from(el: Element) -> UIElement

Converts to this type from the input type.
Source§

impl<T> From<T> for Element
where T: ElementComponent + 'static,

Source§

fn from(part: T) -> Element

Converts to this type from the input type.
Source§

impl StylesExt for Element

Source§

fn section_style(self) -> Element

Apply the default style for a section header.
Source§

fn header_style(self) -> Element

Apply the default style for a header.
Source§

fn small_style(self) -> Element

Apply the default style for a small text.
Source§

fn error_text_style(self) -> Element

Apply the default style for an error text.
Source§

fn floating_panel(self) -> Element

Apply the default style for a floating panel.
Source§

fn panel(self) -> Element

Apply the default style for a panel.
Source§

fn keyboard(self) -> Element

A list of items with some space between them.
Source§

impl UIExt for Element

Source§

fn with_clickarea(self) -> ClickArea

Wraps this element in a ClickArea element.
Source§

fn with_background(self, background: Vec4) -> Element

Adds a background color to this element.
Source§

fn with_padding_even(self, value: f32) -> Element

Adds padding to all sides of this element.
Source§

fn with_margin_even(self, value: f32) -> Element

Adds margin to all sides of this element.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ComponentValueBase for T
where T: Send + Sync + 'static,

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ElementComponentName for T

Source§

fn element_component_name(&self) -> &'static str

Returns the name of the type implementing ElementComponent.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AnyCloneable for T
where T: Clone + Debug + Any + 'static,

Source§

impl<T> ComponentValue for T

Source§

impl<T> ErasedDestructor for T
where T: 'static,