Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Add AUTO and UNDEFINED const constructors for Size #5761

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/bevy_ui/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ impl Size {
pub fn new(width: Val, height: Val) -> Self {
Size { width, height }
}

/// Creates a Size where both values are [`Val::Auto`].
pub const AUTO: Size = Size {
width: Val::Auto,
height: Val::Auto,
};

/// Creates a Size where both values are [`Val::Undefined`].
pub const UNDEFINED: Size = Size {
width: Val::Undefined,
height: Val::Undefined,
};
}

impl Add<Vec2> for Size {
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ impl Default for Style {
flex_grow: 0.0,
flex_shrink: 1.0,
flex_basis: Val::Auto,
size: Size::new(Val::Auto, Val::Auto),
min_size: Size::new(Val::Auto, Val::Auto),
max_size: Size::new(Val::Auto, Val::Auto),
size: Size::AUTO,
min_size: Size::AUTO,
max_size: Size::AUTO,
aspect_ratio: Default::default(),
overflow: Default::default(),
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style {
flex_direction: FlexDirection::ColumnReverse,
flex_grow: 1.0,
max_size: Size::new(Val::Undefined, Val::Undefined),
max_size: Size::UNDEFINED,
..default()
},
color: Color::NONE.into(),
Expand Down