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 hit_testable(self, on: bool) -> Self
pub fn hit_testable(self, on: bool) -> Self
Enables or disables hit testing for this view.
Sourcepub fn pad(self, padding: impl Into<Edges>) -> Self
pub fn pad(self, padding: impl Into<Edges>) -> Self
Alias for LayoutStyle::padding.
Sourcepub fn padding_xy(self, x: f32, y: f32) -> Self
pub fn padding_xy(self, x: f32, y: f32) -> Self
Sets the horizontal and vertical padding.
Sourcepub fn padding_left(self, v: f32) -> Self
pub fn padding_left(self, v: f32) -> Self
Sets the left padding.
Sourcepub fn padding_right(self, v: f32) -> Self
pub fn padding_right(self, v: f32) -> Self
Sets the right padding.
Sourcepub fn padding_top(self, v: f32) -> Self
pub fn padding_top(self, v: f32) -> Self
Sets the top padding.
Sourcepub fn padding_bottom(self, v: f32) -> Self
pub fn padding_bottom(self, v: f32) -> Self
Sets the bottom padding.
Sourcepub fn min_height(self, v: f32) -> Self
pub fn min_height(self, v: f32) -> Self
Sets the minimum height.
Sourcepub fn max_height(self, v: f32) -> Self
pub fn max_height(self, v: f32) -> Self
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_left(self, v: f32) -> Self
pub fn margin_left(self, v: f32) -> Self
Sets the left margin.
Sourcepub fn margin_right(self, v: f32) -> Self
pub fn margin_right(self, v: f32) -> Self
Sets the right margin.
Sourcepub fn margin_top(self, v: f32) -> Self
pub fn margin_top(self, v: f32) -> Self
Sets the top margin.
Sourcepub fn margin_bottom(self, v: f32) -> Self
pub fn margin_bottom(self, v: f32) -> Self
Sets the bottom margin.
Sourcepub fn flex_shrink(self, shrink: f32) -> Self
pub fn flex_shrink(self, shrink: f32) -> Self
Sets the flex shrink weight.
Sourcepub fn flex_full(self, grow: f32, shrink: f32, basis: Option<Length>) -> Self
pub fn flex_full(self, grow: f32, shrink: f32, basis: Option<Length>) -> Self
Sets the grow weight, shrink weight, and basis together.
Sourcepub fn flex_basis(self, basis: Option<Length>) -> Self
pub fn flex_basis(self, basis: Option<Length>) -> Self
Sets the flex basis.
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>) -> Self
pub fn align_self(self, align: Option<Align>) -> Self
Sets the cross-axis alignment override.
Sourcepub fn align_self_value(self, align: Align) -> Self
pub fn align_self_value(self, align: Align) -> Self
Sets an explicit cross-axis alignment override.
Sourcepub fn auto_align(self) -> Self
pub fn auto_align(self) -> Self
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>) -> Self
pub fn aspect_ratio(self, ratio: Option<f32>) -> Self
Sets the aspect ratio, ignoring invalid values.
Sourcepub fn absolute_at(self, left: f32, top: f32) -> Self
pub fn absolute_at(self, left: f32, top: f32) -> Self
Positions the view absolutely at the given left and top offsets.
Sourcepub fn absolute_inset(self, inset: Inset) -> Self
pub fn absolute_inset(self, inset: Inset) -> Self
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 indent_top(self, v: f32) -> Self
pub fn indent_top(self, v: f32) -> Self
Sets the top indent.
Sourcepub fn indent_bottom(self, v: f32) -> Self
pub fn indent_bottom(self, v: f32) -> Self
Sets the bottom indent.
Sourcepub fn indent_left(self, v: f32) -> Self
pub fn indent_left(self, v: f32) -> Self
Sets the left indent.
Sourcepub fn indent_right(self, v: f32) -> Self
pub fn indent_right(self, v: f32) -> Self
Sets the right indent.
Sourcepub fn clear_indent_top(self) -> Self
pub fn clear_indent_top(self) -> Self
Clears the top indent.
Sourcepub fn clear_indent_bottom(self) -> Self
pub fn clear_indent_bottom(self) -> Self
Clears the bottom indent.
Sourcepub fn clear_indent_left(self) -> Self
pub fn clear_indent_left(self) -> Self
Clears the left indent.
Sourcepub fn clear_indent_right(self) -> Self
pub fn clear_indent_right(self) -> Self
Clears the right indent.
Sourcepub fn clear_indents(self) -> Self
pub fn clear_indents(self) -> Self
Clears every indent.
Sourcepub fn indent_all(self, v: f32) -> Self
pub fn indent_all(self, v: f32) -> Self
Sets the same indent on every side.
Sourcepub fn indent_axes(self, horizontal: f32, vertical: f32) -> Self
pub fn indent_axes(self, horizontal: f32, vertical: f32) -> Self
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.