[Merged by Bors] - change the default width and height of Size to Val::Auto#7475
Closed
ickshonpe wants to merge 1 commit intobevyengine:mainfrom
Closed
[Merged by Bors] - change the default width and height of Size to Val::Auto#7475ickshonpe wants to merge 1 commit intobevyengine:mainfrom
width and height of Size to Val::Auto#7475ickshonpe wants to merge 1 commit intobevyengine:mainfrom
Conversation
Size default width and height to Val::AutoSize default width and height to Val::Auto
alice-i-cecile
approved these changes
Feb 2, 2023
Size default width and height to Val::Autowidth and height of Size to Val::Auto
nicoburns
reviewed
Feb 2, 2023
Contributor
nicoburns
left a comment
There was a problem hiding this comment.
This change seems unproblematic to me. However, I believe it will have no effect as IIRC Taffy versions that have both Undefined and Auto treat them both as Auto anyway.
Contributor
Author
|
Undefined and Auto definitely aren't the same. Ultra minimal example, red window: use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(|mut commands: Commands| {
commands.spawn(Camera2dBundle::default());
commands.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.), Val::Auto),
..Default::default()
},
background_color: BackgroundColor(Color::RED),
..Default::default()
});
})
.run();
}Grey window: use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(|mut commands: Commands| {
commands.spawn(Camera2dBundle::default());
commands.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.), Val::Undefined),
..Default::default()
},
background_color: BackgroundColor(Color::RED),
..Default::default()
});
})
.run();The Taffy 2.x compute source is full of predicates like |
Weibye
approved these changes
Feb 2, 2023
Member
|
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Feb 3, 2023
# Objective In CSS Flexbox width and height are auto by default, whereas in Bevy their default is `Size::Undefined`. This means that, unlike in CSS, if you elide a height or width value for a node it will be given zero length (unless it has an explicitly sized child node). This has misled users into falsely assuming that they have to explicitly set a value for both height and width all the time. relevant issue: #7120 ## Solution Change the `Size` `width` and `height` default values to `Val::Auto` ## Changelog * Changed the `Size` `width` and `height` default values to `Val::Auto` ## Migration Guide The default values for `Size` `width` and `height` have been changed from `Val::Undefined` to `Val::Auto`. It's unlikely to cause any issues with existing code.
Contributor
|
Build failed (retrying...): |
bors bot
pushed a commit
that referenced
this pull request
Feb 3, 2023
# Objective In CSS Flexbox width and height are auto by default, whereas in Bevy their default is `Size::Undefined`. This means that, unlike in CSS, if you elide a height or width value for a node it will be given zero length (unless it has an explicitly sized child node). This has misled users into falsely assuming that they have to explicitly set a value for both height and width all the time. relevant issue: #7120 ## Solution Change the `Size` `width` and `height` default values to `Val::Auto` ## Changelog * Changed the `Size` `width` and `height` default values to `Val::Auto` ## Migration Guide The default values for `Size` `width` and `height` have been changed from `Val::Undefined` to `Val::Auto`. It's unlikely to cause any issues with existing code.
Contributor
|
Pull request successfully merged into main. Build succeeded:
|
width and height of Size to Val::Autowidth and height of Size to Val::Auto
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
In CSS Flexbox width and height are auto by default, whereas in Bevy their default is
Size::Undefined.This means that, unlike in CSS, if you elide a height or width value for a node it will be given zero length (unless it has an explicitly sized child node). This has misled users into falsely assuming that they have to explicitly set a value for both height and width all the time.
relevant issue: #7120
Solution
Change the
Sizewidthandheightdefault values toVal::AutoChangelog
Sizewidthandheightdefault values toVal::AutoMigration Guide
The default values for
Sizewidthandheighthave been changed fromVal::UndefinedtoVal::Auto.It's unlikely to cause any issues with existing code.