Skip to content

Commit

Permalink
Use gap/padding instead of percent calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
doup committed Mar 9, 2023
1 parent 721f73c commit fc0e008
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/ui/text_wrap_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn main() {
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());

let gap = Val::Px(8.0);
let text_style = TextStyle {
font: asset_server.load("fonts/FiraSans-Bold.ttf"),
font_size: 14.0,
Expand All @@ -26,6 +27,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style {
flex_direction: FlexDirection::Column,
size: Size::new(Val::Percent(100.), Val::Percent(100.)),
gap: Size::all(gap),
padding: UiRect::all(gap),
..Default::default()
},
background_color: Color::BLACK.into(),
Expand All @@ -37,10 +40,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
let row_id = commands
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Row,
justify_content: JustifyContent::SpaceAround,
align_items: AlignItems::Center,
size: Size::new(Val::Percent(100.), Val::Percent(50.)),
gap: Size::all(Val::Px(8.0)),

This comment has been minimized.

Copy link
@doup

doup Mar 9, 2023

Author Owner

This should be:

gap: Size::all(gap),
..Default::default()
},
..Default::default()
Expand All @@ -63,7 +64,9 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style {
justify_content: justification,
flex_direction: FlexDirection::Column,
size: Size::new(Val::Percent(16.), Val::Percent(95.)),
size: Size::new(Val::Undefined, Val::Percent(100.)),
flex_grow: 1.,
flex_basis: Val::Px(0.),
overflow: Overflow::Hidden,
..Default::default()
},
Expand All @@ -76,7 +79,8 @@ fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
format!("JustifyContent::{justification:?}"),
format!("LineBreakOn::{linebreak_behaviour:?}"),
"Line 1\nLine 2\nLine 3".to_string(),
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas auctor, nunc ac faucibus fringilla.".to_string(),
// Uncomment for total breakage
// "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas auctor, nunc ac faucibus fringilla.".to_string(),

This comment has been minimized.

Copy link
@doup

doup Mar 9, 2023

Author Owner

Uncommented so by default it works, but on resize fails (on smaller widths).

];

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

0 comments on commit fc0e008

Please sign in to comment.