Fixup ui-wtf for bevy 0.11

main
Elijah Voigt 2 years ago
parent b9dc61dad1
commit 563e8c07d2

@ -10,10 +10,8 @@ fn main() {
}), }),
..default() ..default()
})) }))
// Only run when window is active to reduce cpu cycles .add_systems(Startup, (init,))
// .insert_resource(WinitSettings::desktop_app()) .add_systems(Update, (scroll,))
.add_startup_system(init)
.add_system(scroll)
.run(); .run();
} }
@ -30,8 +28,9 @@ fn init(mut commands: Commands) {
background_color: BackgroundColor(Color::WHITE), background_color: BackgroundColor(Color::WHITE),
style: Style { style: Style {
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
size: Size::all(Val::Percent(90.0)), width: Val::Percent(90.0),
overflow: Overflow::Hidden, height: Val::Percent(90.0),
overflow: Overflow::clip(),
..default() ..default()
}, },
..default() ..default()
@ -45,8 +44,10 @@ fn init(mut commands: Commands) {
flex_wrap: FlexWrap::Wrap, flex_wrap: FlexWrap::Wrap,
flex_direction: FlexDirection::Row, flex_direction: FlexDirection::Row,
justify_content: JustifyContent::SpaceAround, justify_content: JustifyContent::SpaceAround,
size: Size::AUTO, width: Val::Auto,
max_size: Size::UNDEFINED, height: Val::Auto,
max_width: Val::Auto,
max_height: Val::Auto,
..default() ..default()
}, },
..default() ..default()
@ -73,7 +74,8 @@ fn init(mut commands: Commands) {
parent.spawn(NodeBundle { parent.spawn(NodeBundle {
background_color: BackgroundColor(colors[i]), background_color: BackgroundColor(colors[i]),
style: Style { style: Style {
size: Size::all(Val::Px(256.0)), width: Val::Px(256.0),
height: Val::Px(256.0),
padding: UiRect::all(Val::Px(5.0)), padding: UiRect::all(Val::Px(5.0)),
..default() ..default()
}, },
@ -90,7 +92,7 @@ fn scroll(
) { ) {
for ev in scroll_evr.iter() { for ev in scroll_evr.iter() {
for mut s in query.iter_mut() { for mut s in query.iter_mut() {
s.position.top = match s.position.top { s.top = match s.top {
Val::Px(current) => Val::Px(current + (ev.y * 5.0)), Val::Px(current) => Val::Px(current + (ev.y * 5.0)),
_ => Val::Px(0.0), _ => Val::Px(0.0),
}; };

Loading…
Cancel
Save