pub struct LayoutStyle {Show 20 fields
pub width: Length,
pub height: Length,
pub padding: Edges,
pub margin: Edges,
pub min_width: f32,
pub max_width: f32,
pub min_height: f32,
pub max_height: f32,
pub flex: f32,
pub flex_shrink: f32,
pub flex_basis: Option<Length>,
pub align_self: Option<Align>,
pub aspect_ratio: Option<f32>,
pub indent_top: Option<f32>,
pub indent_bottom: Option<f32>,
pub indent_left: Option<f32>,
pub indent_right: Option<f32>,
pub position: Position,
pub overflow: Overflow,
pub hit_testable: bool,
}Expand description
Layout properties for a single view.
Fields§
§width: LengthRequested width.
height: LengthRequested height.
padding: EdgesSpace between the border and the content.
margin: EdgesSpace around the view outside its border.
min_width: f32Lower bound for the resolved width.
max_width: f32Upper bound for the resolved width.
min_height: f32Lower bound for the resolved height.
max_height: f32Upper bound for the resolved height.
flex: f32Grow weight along the parent’s main axis.
flex_shrink: f32Shrink weight along the parent’s main axis.
flex_basis: Option<Length>Optional basis used before flex distribution.
align_self: Option<Align>Cross-axis alignment override; None inherits from the container.
aspect_ratio: Option<f32>Preferred width-to-height ratio.
indent_top: Option<f32>Extra indent from the top edge of a docked container.
indent_bottom: Option<f32>Extra indent from the bottom edge of a docked container.
indent_left: Option<f32>Extra indent from the left edge of a docked container.
indent_right: Option<f32>Extra indent from the right edge of a docked container.
position: PositionPositioning mode.
overflow: OverflowOverflow handling for content that exceeds the view.
hit_testable: boolWhether the view participates in hit testing.
Implementations§
Source§impl LayoutStyle
impl LayoutStyle
Sourcepub fn width(self, width: Length) -> LayoutStyle
pub fn width(self, width: Length) -> LayoutStyle
Sets the requested width.
Sourcepub fn height(self, height: Length) -> LayoutStyle
pub fn height(self, height: Length) -> LayoutStyle
Sets the requested height.
Sourcepub fn fit(self) -> LayoutStyle
pub fn fit(self) -> LayoutStyle
Sets both dimensions to fit their content.
Sourcepub fn hit_testable(self, on: bool) -> LayoutStyle
pub fn hit_testable(self, on: bool) -> LayoutStyle
Enables or disables hit testing for this view.
Sourcepub fn padding(self, padding: impl Into<Edges>) -> LayoutStyle
pub fn padding(self, padding: impl Into<Edges>) -> LayoutStyle
Sets the padding on every side.
Sourcepub fn pad(self, padding: impl Into<Edges>) -> LayoutStyle
pub fn pad(self, padding: impl Into<Edges>) -> LayoutStyle
Alias for LayoutStyle::padding.
Sourcepub fn padding_xy(self, x: f32, y: f32) -> LayoutStyle
pub fn padding_xy(self, x: f32, y: f32) -> LayoutStyle
Sets the horizontal and vertical padding.
Sourcepub fn padding_x(self, x: f32) -> LayoutStyle
pub fn padding_x(self, x: f32) -> LayoutStyle
Sets the left and right padding.
Sourcepub fn padding_y(self, y: f32) -> LayoutStyle
pub fn padding_y(self, y: f32) -> LayoutStyle
Sets the top and bottom padding.
Sourcepub fn padding_left(self, v: f32) -> LayoutStyle
pub fn padding_left(self, v: f32) -> LayoutStyle
Sets the left padding.
Sourcepub fn padding_right(self, v: f32) -> LayoutStyle
pub fn padding_right(self, v: f32) -> LayoutStyle
Sets the right padding.
Sourcepub fn padding_top(self, v: f32) -> LayoutStyle
pub fn padding_top(self, v: f32) -> LayoutStyle
Sets the top padding.
Sourcepub fn padding_bottom(self, v: f32) -> LayoutStyle
pub fn padding_bottom(self, v: f32) -> LayoutStyle
Sets the bottom padding.
Sourcepub fn min_width(self, v: f32) -> LayoutStyle
pub fn min_width(self, v: f32) -> LayoutStyle
Sets the minimum width.
Sourcepub fn max_width(self, v: f32) -> LayoutStyle
pub fn max_width(self, v: f32) -> LayoutStyle
Sets the maximum width.
Sourcepub fn min_height(self, v: f32) -> LayoutStyle
pub fn min_height(self, v: f32) -> LayoutStyle
Sets the minimum height.
Sourcepub fn max_height(self, v: f32) -> LayoutStyle
pub fn max_height(self, v: f32) -> LayoutStyle
Sets the maximum height.
Sourcepub fn clamp_width(self, w: f32) -> f32
pub fn clamp_width(self, w: f32) -> f32
Clamps a width to this style’s minimum and maximum.
Sourcepub fn clamp_height(self, h: f32) -> f32
pub fn clamp_height(self, h: f32) -> f32
Clamps a height to this style’s minimum and maximum.
Sourcepub fn clamp_size(self, size: Size) -> Size
pub fn clamp_size(self, size: Size) -> Size
Clamps a size to this style’s minimum and maximum.
Sourcepub fn margin(self, margin: impl Into<Edges>) -> LayoutStyle
pub fn margin(self, margin: impl Into<Edges>) -> LayoutStyle
Sets the margin on every side.
Sourcepub fn margin_xy(self, x: f32, y: f32) -> LayoutStyle
pub fn margin_xy(self, x: f32, y: f32) -> LayoutStyle
Sets the horizontal and vertical margin.
Sourcepub fn margin_x(self, x: f32) -> LayoutStyle
pub fn margin_x(self, x: f32) -> LayoutStyle
Sets the left and right margin.
Sourcepub fn margin_y(self, y: f32) -> LayoutStyle
pub fn margin_y(self, y: f32) -> LayoutStyle
Sets the top and bottom margin.
Sourcepub fn margin_left(self, v: f32) -> LayoutStyle
pub fn margin_left(self, v: f32) -> LayoutStyle
Sets the left margin.
Sourcepub fn margin_right(self, v: f32) -> LayoutStyle
pub fn margin_right(self, v: f32) -> LayoutStyle
Sets the right margin.
Sourcepub fn margin_top(self, v: f32) -> LayoutStyle
pub fn margin_top(self, v: f32) -> LayoutStyle
Sets the top margin.
Sourcepub fn margin_bottom(self, v: f32) -> LayoutStyle
pub fn margin_bottom(self, v: f32) -> LayoutStyle
Sets the bottom margin.
Sourcepub fn flex(self, weight: f32) -> LayoutStyle
pub fn flex(self, weight: f32) -> LayoutStyle
Sets the flex grow weight.
Sourcepub fn flex_grow(self, weight: f32) -> LayoutStyle
pub fn flex_grow(self, weight: f32) -> LayoutStyle
Sets the flex grow weight.
Sourcepub fn flex_shrink(self, shrink: f32) -> LayoutStyle
pub fn flex_shrink(self, shrink: f32) -> LayoutStyle
Sets the flex shrink weight.
Sourcepub fn flex_full(
self,
grow: f32,
shrink: f32,
basis: Option<Length>,
) -> LayoutStyle
pub fn flex_full( self, grow: f32, shrink: f32, basis: Option<Length>, ) -> LayoutStyle
Sets the grow weight, shrink weight, and basis together.
Sourcepub fn flex_basis(self, basis: Option<Length>) -> LayoutStyle
pub fn flex_basis(self, basis: Option<Length>) -> LayoutStyle
Sets the flex basis.
Sourcepub fn no_basis(self) -> LayoutStyle
pub fn no_basis(self) -> LayoutStyle
Clears the flex basis.
Sourcepub fn expand(self) -> LayoutStyle
pub fn expand(self) -> LayoutStyle
Sets the flex grow weight to one.
Sourcepub fn flex_weight(self) -> f32
pub fn flex_weight(self) -> f32
Returns the sanitized flex grow weight.
Sourcepub fn flex_grow_weight(self) -> f32
pub fn flex_grow_weight(self) -> f32
Returns the sanitized flex grow weight.
Sourcepub fn flex_shrink_weight(self) -> f32
pub fn flex_shrink_weight(self) -> f32
Returns the sanitized flex shrink weight.
Sourcepub fn align_self(self, align: Option<Align>) -> LayoutStyle
pub fn align_self(self, align: Option<Align>) -> LayoutStyle
Sets the cross-axis alignment override.
Sourcepub fn align_self_value(self, align: Align) -> LayoutStyle
pub fn align_self_value(self, align: Align) -> LayoutStyle
Sets an explicit cross-axis alignment override.
Sourcepub fn auto_align(self) -> LayoutStyle
pub fn auto_align(self) -> LayoutStyle
Clears the alignment override so the container’s alignment is used.
Sourcepub fn effective_align(self, container: Align) -> Align
pub fn effective_align(self, container: Align) -> Align
Resolves the effective alignment against a container alignment.
Sourcepub fn aspect_ratio(self, ratio: Option<f32>) -> LayoutStyle
pub fn aspect_ratio(self, ratio: Option<f32>) -> LayoutStyle
Sets the aspect ratio, ignoring invalid values.
Sourcepub fn aspect(self, ratio: f32) -> LayoutStyle
pub fn aspect(self, ratio: f32) -> LayoutStyle
Sets the aspect ratio to ratio.
Sourcepub fn no_aspect(self) -> LayoutStyle
pub fn no_aspect(self) -> LayoutStyle
Clears the aspect ratio.
Sourcepub fn position(self, position: Position) -> LayoutStyle
pub fn position(self, position: Position) -> LayoutStyle
Sets the positioning mode.
Sourcepub fn absolute(self) -> LayoutStyle
pub fn absolute(self) -> LayoutStyle
Positions the view absolutely with auto insets.
Sourcepub fn absolute_at(self, left: f32, top: f32) -> LayoutStyle
pub fn absolute_at(self, left: f32, top: f32) -> LayoutStyle
Positions the view absolutely at the given left and top offsets.
Sourcepub fn absolute_inset(self, inset: Inset) -> LayoutStyle
pub fn absolute_inset(self, inset: Inset) -> LayoutStyle
Positions the view absolutely with the given insets.
Sourcepub fn is_absolute(self) -> bool
pub fn is_absolute(self) -> bool
Returns true if the view is positioned absolutely.
Sourcepub fn absolute_inset_of(self) -> Option<Inset>
pub fn absolute_inset_of(self) -> Option<Inset>
Returns the absolute insets, or None for flow positioning.
Sourcepub fn margin_main(self, axis: Axis) -> f32
pub fn margin_main(self, axis: Axis) -> f32
Returns the horizontal or vertical margin for the given axis.
Sourcepub fn margin_cross(self, axis: Axis) -> f32
pub fn margin_cross(self, axis: Axis) -> f32
Returns the cross-axis margin for the given main axis.
Sourcepub fn apply_aspect(
self,
w: f32,
h: f32,
w_auto: bool,
h_auto: bool,
) -> (f32, f32)
pub fn apply_aspect( self, w: f32, h: f32, w_auto: bool, h_auto: bool, ) -> (f32, f32)
Applies the aspect ratio to the size, deriving either auto axis.
Sourcepub fn outer_size(self, inner: Size) -> Size
pub fn outer_size(self, inner: Size) -> Size
Expands an inner size by this style’s margins.
Sourcepub fn clamp_main(self, value: f32, axis: Axis) -> f32
pub fn clamp_main(self, value: f32, axis: Axis) -> f32
Clamps a value to the minimum and maximum along the given axis.
Sourcepub fn overflow(self, overflow: Overflow) -> LayoutStyle
pub fn overflow(self, overflow: Overflow) -> LayoutStyle
Sets the overflow behavior.
Sourcepub fn indent_top(self, v: f32) -> LayoutStyle
pub fn indent_top(self, v: f32) -> LayoutStyle
Sets the top indent.
Sourcepub fn indent_bottom(self, v: f32) -> LayoutStyle
pub fn indent_bottom(self, v: f32) -> LayoutStyle
Sets the bottom indent.
Sourcepub fn indent_left(self, v: f32) -> LayoutStyle
pub fn indent_left(self, v: f32) -> LayoutStyle
Sets the left indent.
Sourcepub fn indent_right(self, v: f32) -> LayoutStyle
pub fn indent_right(self, v: f32) -> LayoutStyle
Sets the right indent.
Sourcepub fn clear_indent_top(self) -> LayoutStyle
pub fn clear_indent_top(self) -> LayoutStyle
Clears the top indent.
Sourcepub fn clear_indent_bottom(self) -> LayoutStyle
pub fn clear_indent_bottom(self) -> LayoutStyle
Clears the bottom indent.
Sourcepub fn clear_indent_left(self) -> LayoutStyle
pub fn clear_indent_left(self) -> LayoutStyle
Clears the left indent.
Sourcepub fn clear_indent_right(self) -> LayoutStyle
pub fn clear_indent_right(self) -> LayoutStyle
Clears the right indent.
Sourcepub fn clear_indents(self) -> LayoutStyle
pub fn clear_indents(self) -> LayoutStyle
Clears every indent.
Sourcepub fn indent(self, indents: Indents) -> LayoutStyle
pub fn indent(self, indents: Indents) -> LayoutStyle
Applies the set sides from indents.
Sourcepub fn indent_all(self, v: f32) -> LayoutStyle
pub fn indent_all(self, v: f32) -> LayoutStyle
Sets the same indent on every side.
Sourcepub fn indent_xy(self, x: f32, y: f32) -> LayoutStyle
pub fn indent_xy(self, x: f32, y: f32) -> LayoutStyle
Sets the horizontal and vertical indents.
Sourcepub fn indent_axes(self, horizontal: f32, vertical: f32) -> LayoutStyle
pub fn indent_axes(self, horizontal: f32, vertical: f32) -> LayoutStyle
Sets the horizontal and vertical indents.
Sourcepub fn indent_main_start(self, axis: Axis) -> Option<f32>
pub fn indent_main_start(self, axis: Axis) -> Option<f32>
Returns the indent at the main-axis start for the given axis.
Sourcepub fn indent_main_end(self, axis: Axis) -> Option<f32>
pub fn indent_main_end(self, axis: Axis) -> Option<f32>
Returns the indent at the main-axis end for the given axis.
Sourcepub fn indent_cross_start(self, axis: Axis) -> Option<f32>
pub fn indent_cross_start(self, axis: Axis) -> Option<f32>
Returns the indent at the cross-axis start for the given main axis.
Sourcepub fn indent_cross_end(self, axis: Axis) -> Option<f32>
pub fn indent_cross_end(self, axis: Axis) -> Option<f32>
Returns the indent at the cross-axis end for the given main axis.
Trait Implementations§
Source§impl Clone for LayoutStyle
impl Clone for LayoutStyle
Source§fn clone(&self) -> LayoutStyle
fn clone(&self) -> LayoutStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more