Skip to main content

StyleExt

Trait StyleExt 

pub trait StyleExt: Sized {
    // Required method
    fn get_style(&mut self) -> &mut StyleState;

    // Provided methods
    fn background<S>(self, background: S) -> Self
       where S: Into<Color> { ... }
    fn background_conic_gradient<S>(self, background: S) -> Self
       where S: Into<ConicGradient> { ... }
    fn background_linear_gradient<S>(self, background: S) -> Self
       where S: Into<LinearGradient> { ... }
    fn background_radial_gradient<S>(self, background: S) -> Self
       where S: Into<RadialGradient> { ... }
    fn background_shader(self, background: impl Into<ShaderFill>) -> Self { ... }
    fn border(self, border: impl Into<Option<Border>>) -> Self { ... }
    fn shadow(self, shadow: impl Into<Shadow>) -> Self { ... }
    fn corner_radius(self, corner_radius: impl Into<CornerRadius>) -> Self { ... }
}
Expand description

Methods for styling an element’s box: background, borders, shadows and corners.

Required Methods§

fn get_style(&mut self) -> &mut StyleState

Returns a mutable reference to the element’s style data.

Provided Methods§

fn background<S>(self, background: S) -> Self
where S: Into<Color>,

Set the background to a solid Color.

fn background_conic_gradient<S>(self, background: S) -> Self
where S: Into<ConicGradient>,

Paint the background with a ConicGradient.

fn background_linear_gradient<S>(self, background: S) -> Self
where S: Into<LinearGradient>,

Paint the background with a LinearGradient.

fn background_radial_gradient<S>(self, background: S) -> Self
where S: Into<RadialGradient>,

Paint the background with a RadialGradient.

fn background_shader(self, background: impl Into<ShaderFill>) -> Self

Paint the background with a custom shader. See ShaderFill.

fn border(self, border: impl Into<Option<Border>>) -> Self

Add an outline around the element. See Border.

fn shadow(self, shadow: impl Into<Shadow>) -> Self

Add a shadow cast by the element. See Shadow.

fn corner_radius(self, corner_radius: impl Into<CornerRadius>) -> Self

Round the element’s corners. See CornerRadius.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl StyleExt for Rect