UI examples clean up (#9479)
# Objective Fix a few issues with some of the examples: * Root UI nodes have an implicit parent with `FlexDirection::Row` and `AlignItems::Stretch` set. Only a width constraint is needed to fill the viewport. Specifying ```height: Val::Percent(100.)``` is unnecessary and can cause confusing overflow behaviour. * The default for position and size constraint properties is `Val::Auto`. Setting `left: Val::Auto`, `max_height: Val::Auto`, etc does nothing. ## Solution Delete those lines. There should be no observable differences in the behaviours of any of the examples. Also changed a padding setting in the `flex_layout` example to use the `axes` helper function.
This commit is contained in:
parent
20c85b5fc3
commit
373f1eeb1e
@ -151,7 +151,6 @@ mod game {
|
|||||||
NodeBundle {
|
NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Percent(100.0),
|
width: Val::Percent(100.0),
|
||||||
height: Val::Percent(100.0),
|
|
||||||
// center children
|
// center children
|
||||||
align_items: AlignItems::Center,
|
align_items: AlignItems::Center,
|
||||||
justify_content: JustifyContent::Center,
|
justify_content: JustifyContent::Center,
|
||||||
|
|||||||
@ -110,7 +110,6 @@ fn setup_scene(
|
|||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
left: Val::Px(50.0),
|
left: Val::Px(50.0),
|
||||||
right: Val::Px(50.0),
|
right: Val::Px(50.0),
|
||||||
top: Val::Auto,
|
|
||||||
bottom: Val::Px(50.0),
|
bottom: Val::Px(50.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
|||||||
@ -412,7 +412,6 @@ where
|
|||||||
.spawn((
|
.spawn((
|
||||||
ButtonBundle {
|
ButtonBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
//height: Val::Px(24.),
|
|
||||||
align_self: AlignSelf::FlexStart,
|
align_self: AlignSelf::FlexStart,
|
||||||
padding: UiRect::axes(Val::Px(5.), Val::Px(1.)),
|
padding: UiRect::axes(Val::Px(5.), Val::Px(1.)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@ -162,12 +162,7 @@ fn spawn_nested_text_bundle(
|
|||||||
.spawn(NodeBundle {
|
.spawn(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
margin,
|
margin,
|
||||||
padding: UiRect {
|
padding: UiRect::axes(Val::Px(5.), Val::Px(1.)),
|
||||||
top: Val::Px(1.),
|
|
||||||
left: Val::Px(5.),
|
|
||||||
right: Val::Px(5.),
|
|
||||||
bottom: Val::Px(1.),
|
|
||||||
},
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
background_color: BackgroundColor(background_color),
|
background_color: BackgroundColor(background_color),
|
||||||
|
|||||||
@ -183,7 +183,6 @@ fn spawn_layout(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
width: Val::Percent(60.),
|
width: Val::Percent(60.),
|
||||||
height: Val::Px(300.),
|
height: Val::Px(300.),
|
||||||
max_width: Val::Px(600.),
|
max_width: Val::Px(600.),
|
||||||
max_height: Val::Auto,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
background_color: BackgroundColor(Color::Rgba {
|
background_color: BackgroundColor(Color::Rgba {
|
||||||
|
|||||||
@ -82,7 +82,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
.spawn(NodeBundle {
|
.spawn(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Percent(100.),
|
width: Val::Percent(100.),
|
||||||
height: Val::Percent(100.),
|
|
||||||
flex_direction: FlexDirection::Column,
|
flex_direction: FlexDirection::Column,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
|||||||
@ -19,7 +19,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
.spawn(NodeBundle {
|
.spawn(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Percent(100.),
|
width: Val::Percent(100.),
|
||||||
height: Val::Percent(100.),
|
|
||||||
align_items: AlignItems::Center,
|
align_items: AlignItems::Center,
|
||||||
justify_content: JustifyContent::Center,
|
justify_content: JustifyContent::Center,
|
||||||
flex_direction: FlexDirection::Column,
|
flex_direction: FlexDirection::Column,
|
||||||
|
|||||||
@ -29,7 +29,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
.spawn(NodeBundle {
|
.spawn(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::Percent(100.0),
|
width: Val::Percent(100.0),
|
||||||
height: Val::Percent(100.0),
|
|
||||||
justify_content: JustifyContent::SpaceBetween,
|
justify_content: JustifyContent::SpaceBetween,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user