Struct vizia_core::views::Element
source · pub struct Element;
Expand description
A basic element with no interactivity.
An element has no children and no special rendering logic. It can be used to render a rectangle, a line or a circle using view styling rules.
§Examples
§Element without visible styling
An element can be used without visible styling which displays nothing at all. This is useful to create an invisible spacer between other views.
Element::new(cx)
.width(Pixels(100.0))
.height(Pixels(100.0));
§Element as a rectangle
An element can be used to display a rectangle like this black one with a size of 100 by 100 pixels.
Element::new(cx)
.width(Pixels(100.0))
.height(Pixels(100.0))
.background_color(Color::black());
§Element as a line
An element can be used to display a line like this black one with a size of 100 by 1 pixels.
Element::new(cx)
.width(Pixels(100.0))
.height(Pixels(1.0))
.background_color(Color::black());
§Element as a circle
An element can be used to display a circle like this black one with a diameter of 100 pixels. To create a perfect circle the width and height of the element have to be equal and the border radius has to be set to fifty percent.
Element::new(cx)
.width(Pixels(100.0))
.height(Pixels(100.0))
.border_radius(Percentage(50.0))
.background_color(Color::black());
§Element as an image
An element can be used to display an image like this 100 by 100 pixels one. The image can
be set by using a stylesheet or by using a lens. The image has to be loaded manually by
using the Context::load_image
method.
Element::new(cx)
.width(Pixels(100.0))
.height(Pixels(100.0));
Implementations§
Trait Implementations§
source§impl View for Element
impl View for Element
source§fn element(&self) -> Option<&'static str>
fn element(&self) -> Option<&'static str>
source§fn build<F>(self, cx: &mut Context, content: F) -> Handle<'_, Self>
fn build<F>(self, cx: &mut Context, content: F) -> Handle<'_, Self>
source§fn event(&mut self, cx: &mut EventContext<'_>, event: &mut Event)
fn event(&mut self, cx: &mut EventContext<'_>, event: &mut Event)
source§fn draw(&self, cx: &mut DrawContext<'_>, canvas: &Canvas)
fn draw(&self, cx: &mut DrawContext<'_>, canvas: &Canvas)
fn accessibility(&self, cx: &mut AccessContext<'_>, node: &mut AccessNode)
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.