Skip to main content

BoxDecoration

Struct BoxDecoration 

Source
pub struct BoxDecoration {
    pub color: Option<AnyColor>,
    pub border: Option<BoxBorderRef>,
    pub border_radius: Option<BorderRadiusGeometry>,
    pub box_shadow: Option<Vec<BoxShadow>>,
    pub gradient: Option<GradientRef>,
    pub background_blend_mode: Option<BlendMode>,
    pub shape: BoxShape,
}
Expand description

An immutable description of how to paint a box.

The box has a border, a body, and may cast a box_shadow.

image is deferred (see PORTING.md).

Fields§

§color: Option<AnyColor>

The color to fill in the background of the box.

This is ignored if gradient is non-null.

§border: Option<BoxBorderRef>

A border to draw above the background color.

§border_radius: Option<BorderRadiusGeometry>

If non-null, the corners of this box are rounded by this BorderRadius.

Applies only to boxes with rectangular shapes; ignored if shape is not BoxShape::Rectangle.

§box_shadow: Option<Vec<BoxShadow>>

A list of shadows cast by this box behind the box.

§gradient: Option<GradientRef>

A gradient to use when filling the box.

If this is specified, color has no effect.

§background_blend_mode: Option<BlendMode>

The blend mode applied to the color or gradient background of the box.

If no color or gradient is provided then the blend mode has no impact.

§shape: BoxShape

The shape to fill the background color and gradient into and to cast as the box_shadow.

Implementations§

Source§

impl BoxDecoration

Source

pub fn new() -> BoxDecoration

Creates a box decoration.

Chain setters for the fields Dart’s constructor takes as named arguments: BoxDecoration::new().color(c).border_radius(r).

Source

pub fn color(self, color: impl Into<AnyColor>) -> BoxDecoration

The color to fill in the background of the box.

Source

pub fn border(self, border: impl Into<BoxBorderRef>) -> BoxDecoration

A border to draw above the background color.

Source

pub fn border_radius( self, border_radius: impl Into<BorderRadiusGeometry>, ) -> BoxDecoration

If non-null, the corners of this box are rounded by this radius.

Applies only to boxes with rectangular shapes.

Source

pub fn box_shadow(self, box_shadow: Vec<BoxShadow>) -> BoxDecoration

A list of shadows cast by this box behind the box.

Source

pub fn gradient(self, gradient: impl Into<GradientRef>) -> BoxDecoration

A gradient to use when filling the box.

Source

pub fn background_blend_mode( self, background_blend_mode: BlendMode, ) -> BoxDecoration

The blend mode applied to the color or gradient background.

A color or gradient must already be set.

Source

pub fn shape(self, shape: BoxShape) -> BoxDecoration

The shape to fill the background into and to cast as the box shadow.

Source

pub fn copy_with(&self) -> BoxDecoration

Creates a copy of this object. Chain setters to replace fields (decoration.copy_with().color(c)).

Source

pub fn scale(&self, factor: f64) -> BoxDecoration

Returns a new box decoration that is scaled by the given factor.

Source

pub fn lerp( a: Option<&BoxDecoration>, b: Option<&BoxDecoration>, t: f64, ) -> Option<BoxDecoration>

Linearly interpolate between two box decorations.

Interpolates each parameter of the box decoration separately.

The shape is not interpolated.

Trait Implementations§

Source§

impl Clone for BoxDecoration

Source§

fn clone(&self) -> BoxDecoration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BoxDecoration

Source§

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

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

impl Decoration for BoxDecoration

Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Dart’s Decoration.debugFillProperties, inherited from Diagnosticable: a subclass adds its own properties and calls this first, as Dart’s super does.
Source§

fn debug_assert_is_valid(&self) -> bool

In debug mode, panics if the object is not in a valid configuration. Otherwise, returns true.
Source§

fn padding(&self) -> EdgeInsetsGeometry

Returns the insets to apply when using this decoration on a box that has contents, so that the contents do not overlap the edges of the decoration.
Source§

fn get_clip_path(&self, rect: Rect, text_direction: TextDirection) -> Path

Returns a closed Path that describes the outer edge of this decoration. Read more
Source§

fn is_complex(&self) -> bool

Whether this decoration is complex enough to benefit from caching its painting.
Source§

fn lerp_from( &self, a: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>

Linearly interpolates from another Decoration (which may be of a different class) to this. Read more
Source§

fn lerp_to( &self, b: Option<&(dyn Decoration + 'static)>, t: f64, ) -> Option<DecorationRef>

Linearly interpolates from this to another Decoration (which may be of a different class).
Source§

fn hit_test( &self, size: Size, position: Offset, text_direction: Option<TextDirection>, ) -> bool

Tests whether the given point, on a rectangle of a given size, would be considered to hit the decoration or not.
Source§

fn create_box_painter( &self, on_changed: Option<Rc<dyn Fn(&mut App)>>, ) -> Box<dyn BoxPainter>

Returns a BoxPainter that will paint this decoration.
Source§

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

Downcast support for is / as in Dart.
Source§

fn eq_decoration(&self, other: &(dyn Decoration + 'static)) -> bool

Field equality. Dart’s default == is identity; subclasses that override == implement this.
Source§

fn diagnostics_node(&self, name: Option<String>) -> DiagnosticableNode

Dart’s Decoration.toDiagnosticsNode(name:), inherited from Diagnosticable; a dyn Decoration cannot name the Sized Diagnosticable, so the bridge lives here.
Source§

fn to_string_short(&self) -> String

Dart’s Decoration.toStringShort: the runtime type.
Source§

impl Default for BoxDecoration

Source§

fn default() -> BoxDecoration

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

impl Diagnosticable for BoxDecoration

Source§

fn to_string_short(&self) -> String

A brief description of this object, usually just the type and the hash.
Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Add additional properties associated with the node.
Source§

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

Dart’s Object.runtimeType as diagnostics print it: the last segment of the Rust type path, without generic arguments.
Source§

fn identity_hash(&self) -> u64

Dart’s Object.hashCode as diagnostics print it: the object’s address.
Source§

fn to_diagnostics_node(&self) -> DiagnosticableNode

Returns a debug representation of the object used by debugging tools and by DiagnosticsNode::to_string_deep.
Source§

fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode

Dart toDiagnosticsNode(name:, style:).
Source§

fn to_string(&self) -> String

Dart’s toString: a single-line description with properties and no children. Read more
Source§

fn to_string_at(&self, min_level: DiagnosticLevel) -> String

Dart’s toString(minLevel:).
Source§

impl Display for BoxDecoration

Source§

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

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

impl PartialEq for BoxDecoration

Source§

fn eq(&self, other: &BoxDecoration) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for BoxDecoration

§

impl !Send for BoxDecoration

§

impl !Sync for BoxDecoration

§

impl !UnwindSafe for BoxDecoration

§

impl Forget for BoxDecoration

§

impl Freeze for BoxDecoration
where &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const RcInner<dyn BoxBorder> is !null: Freeze, PhantomData<RcInner<dyn BoxBorder>>: Freeze, *const u8 is !null: Freeze, PhantomData<BoxShadow>: Freeze, *const RcInner<dyn Gradient> is !null: Freeze, PhantomData<RcInner<dyn Gradient>>: Freeze,

§

impl Move for BoxDecoration

§

impl Unpin for BoxDecoration
where &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, Rc<dyn BoxBorder>: Unpin, *const u8 is !null: Unpin, Rc<dyn Gradient>: Unpin,

§

impl UnsafeUnpin for BoxDecoration
where &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, *const RcInner<dyn BoxBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn BoxBorder>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<BoxShadow>: UnsafeUnpin, *const RcInner<dyn Gradient> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Gradient>>: UnsafeUnpin,

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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>