Skip to content

Commit fc0e008

Browse files
committed
Use gap/padding instead of percent calculations
1 parent 721f73c commit fc0e008

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

examples/ui/text_wrap_debug.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() {
1515
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
1616
commands.spawn(Camera2dBundle::default());
1717

18+
let gap = Val::Px(8.0);
1819
let text_style = TextStyle {
1920
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
2021
font_size: 14.0,
@@ -26,6 +27,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
2627
style: Style {
2728
flex_direction: FlexDirection::Column,
2829
size: Size::new(Val::Percent(100.), Val::Percent(100.)),
30+
gap: Size::all(gap),
31+
padding: UiRect::all(gap),
2932
..Default::default()
3033
},
3134
background_color: Color::BLACK.into(),
@@ -37,10 +40,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
3740
let row_id = commands
3841
.spawn(NodeBundle {
3942
style: Style {
40-
flex_direction: FlexDirection::Row,
41-
justify_content: JustifyContent::SpaceAround,
42-
align_items: AlignItems::Center,
4343
size: Size::new(Val::Percent(100.), Val::Percent(50.)),
44+
gap: Size::all(Val::Px(8.0)),
4445
..Default::default()
4546
},
4647
..Default::default()
@@ -63,7 +64,9 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
6364
style: Style {
6465
justify_content: justification,
6566
flex_direction: FlexDirection::Column,
66-
size: Size::new(Val::Percent(16.), Val::Percent(95.)),
67+
size: Size::new(Val::Undefined, Val::Percent(100.)),
68+
flex_grow: 1.,
69+
flex_basis: Val::Px(0.),
6770
overflow: Overflow::Hidden,
6871
..Default::default()
6972
},
@@ -76,7 +79,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
7679
format!("JustifyContent::{justification:?}"),
7780
format!("LineBreakOn::{linebreak_behaviour:?}"),
7881
"Line 1\nLine 2\nLine 3".to_string(),
79-
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas auctor, nunc ac faucibus fringilla.".to_string(),
82+
// Uncomment for total breakage
83+
// "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas auctor, nunc ac faucibus fringilla.".to_string(),
8084
];
8185

8286
for (j, message) in messages.into_iter().enumerate() {

0 commit comments

Comments
 (0)