Skip to main content

Modifier

Struct Modifier 

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

What sits around a widget: its size, its surface, its outline, how far its content is inset, and what the Renderer reports about it. Compose’s Modifier.

Written the way Compose writes it, from the empty value Modifier:

ⓘ
Card().modifier(Modifier.fill_max_width().padding(16.0).background(Paint::Role(ColorRole::Surface)))

The order of the calls does not matter. Each kind of Modifier has a fixed slot in the node’s chain, outside in: size, shape, fill, outline, lift, press, inset. That is what the rsx! attributes do too, so the same Modifier draws the same either way.

Implementations§

Source§

impl Modifier

Source

pub const fn new() -> Self

The empty Modifier. The same as the value Modifier.

Source

pub const fn weight(self, weight: f32) -> Self

A share of the space left in a Row or Column.

Source

pub const fn width(self, dp: f32) -> Self

Source

pub const fn height(self, dp: f32) -> Self

Source

pub const fn size(self, width: f32, height: f32) -> Self

Both at once.

Source

pub const fn width_if(self, dp: Option<f32>) -> Self

A width that may be unset, for a screen whose measure depends on the window.

Source

pub const fn fill_max_width(self) -> Self

Source

pub const fn fill_max_height(self) -> Self

Source

pub const fn fill_max_size(self) -> Self

Source

pub const fn fill_max_width_if(self, fill: bool) -> Self

Fills the width only when fill is true.

Source

pub const fn padding(self, dp: f32) -> Self

The same inset on every side, in dp.

Source

pub const fn padding_role(self, role: SpaceRole) -> Self

An inset from the design system’s spacing ladder. Wins over padding.

Source

pub const fn padding_role_if(self, role: Option<SpaceRole>) -> Self

The same, when the inset may be unset.

Source

pub const fn background(self, paint: Paint) -> Self

Source

pub const fn background_if(self, paint: Option<Paint>) -> Self

The same, when there may be no background.

Source

pub const fn shape_role(self, role: ShapeRole) -> Self

A shape from the design system’s ladder.

Source

pub const fn corner_radius(self, dp: f32) -> Self

A literal corner, in dp. Wins over shape_role.

Source

pub const fn border(self, width: f32, paint: Paint) -> Self

Source

pub const fn elevation(self, dp: f32) -> Self

A resting height above the default, in dp. How it is drawn is the design system’s.

Source

pub const fn observe_size(self, token: i64) -> Self

Asks the Renderer to report this node’s size under the token from crate::runtime::remember_node_size.

Source

pub const fn motion(self, role: MotionRole) -> Self

How important this node’s changes are. The curve is the design system’s.

Source

pub const fn material(self, role: MaterialRole) -> Self

What this node’s surface is made of. The effect is the design system’s.

Source

pub const fn alpha(self, alpha: f32) -> Self

An opacity for the node and everything in it, faded as one group.

Source

pub fn graphics_layer(self, layer: GraphicsLayer) -> Self

Compose’s graphicsLayer: a rotation, a scale and a translation about an origin, drawn without moving the layout, and an opacity for the whole group. A pointer is tested against the shape that is drawn.

Source

pub const fn animated_alpha(self, value: Animated<f32>) -> Self

An opacity the Renderer animates to, from crate::animate_float_as_state. It takes the place of alpha.

Source

pub const fn animated_background(self, value: Animated<Paint>) -> Self

A background the Renderer animates to, from crate::animate_color_as_state. It takes the place of background.

Source

pub const fn animated_offset(self, value: Animated<(f32, f32)>) -> Self

A translation the Renderer animates to, from crate::animate_offset_as_state. It takes the place of the transform a graphics_layer would draw.

Source

pub const fn cursor(self, cursor: Cursor) -> Self

The cursor the platform shows over the node. CSS cursor: the deepest node under the pointer that names one other than Cursor::Auto wins, and while a node holds a pointer capture its cursor stays.

Source

pub const fn user_select(self, user_select: UserSelect) -> Self

Whether the text under the node can be selected. CSS user-select; Auto follows the parent.

Trait Implementations§

Source§

impl Clone for Modifier

Source§

fn clone(&self) -> Self

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 Copy for Modifier

Source§

impl Debug for Modifier

Source§

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

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

impl Default for Modifier

Source§

fn default() -> Self

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

impl PartialEq for Modifier

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Modifier

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> 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> 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> 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 = !

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.