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
impl Modifier
pub const fn width(self, dp: f32) -> Self
pub const fn height(self, dp: f32) -> Self
Sourcepub const fn width_if(self, dp: Option<f32>) -> Self
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.
pub const fn fill_max_width(self) -> Self
pub const fn fill_max_height(self) -> Self
pub const fn fill_max_size(self) -> Self
Sourcepub const fn fill_max_width_if(self, fill: bool) -> Self
pub const fn fill_max_width_if(self, fill: bool) -> Self
Fills the width only when fill is true.
Sourcepub const fn padding_role(self, role: SpaceRole) -> Self
pub const fn padding_role(self, role: SpaceRole) -> Self
An inset from the design system’s spacing ladder. Wins over padding.
Sourcepub const fn padding_role_if(self, role: Option<SpaceRole>) -> Self
pub const fn padding_role_if(self, role: Option<SpaceRole>) -> Self
The same, when the inset may be unset.
pub const fn background(self, paint: Paint) -> Self
Sourcepub const fn background_if(self, paint: Option<Paint>) -> Self
pub const fn background_if(self, paint: Option<Paint>) -> Self
The same, when there may be no background.
Sourcepub const fn shape_role(self, role: ShapeRole) -> Self
pub const fn shape_role(self, role: ShapeRole) -> Self
A shape from the design system’s ladder.
Sourcepub const fn corner_radius(self, dp: f32) -> Self
pub const fn corner_radius(self, dp: f32) -> Self
A literal corner, in dp. Wins over shape_role.
pub const fn border(self, width: f32, paint: Paint) -> Self
Sourcepub const fn elevation(self, dp: f32) -> Self
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.
Sourcepub const fn observe_size(self, token: i64) -> Self
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.
Sourcepub const fn motion(self, role: MotionRole) -> Self
pub const fn motion(self, role: MotionRole) -> Self
How important this node’s changes are. The curve is the design system’s.
Sourcepub const fn material(self, role: MaterialRole) -> Self
pub const fn material(self, role: MaterialRole) -> Self
What this node’s surface is made of. The effect is the design system’s.
Sourcepub const fn alpha(self, alpha: f32) -> Self
pub const fn alpha(self, alpha: f32) -> Self
An opacity for the node and everything in it, faded as one group.
Sourcepub fn graphics_layer(self, layer: GraphicsLayer) -> Self
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.
Sourcepub const fn animated_alpha(self, value: Animated<f32>) -> Self
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.
Sourcepub const fn animated_background(self, value: Animated<Paint>) -> Self
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.
Sourcepub const fn animated_offset(self, value: Animated<(f32, f32)>) -> Self
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.
Sourcepub const fn cursor(self, cursor: Cursor) -> Self
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.
Sourcepub const fn user_select(self, user_select: UserSelect) -> Self
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.