Improve UI layouting
This commit is contained in:
parent
1d673203db
commit
74db5c4be4
1 changed files with 17 additions and 7 deletions
24
src/main.rs
24
src/main.rs
|
@ -60,8 +60,8 @@ use bevy::{
|
||||||
ui::{
|
ui::{
|
||||||
entity::{ButtonBundle, ImageBundle, NodeBundle, TextBundle},
|
entity::{ButtonBundle, ImageBundle, NodeBundle, TextBundle},
|
||||||
widget::Button,
|
widget::Button,
|
||||||
AlignItems, FocusPolicy, Interaction, JustifyContent, Size, Style, UiColor, UiImage,
|
AlignItems, FocusPolicy, Interaction, JustifyContent, PositionType, Size, Style, UiColor,
|
||||||
UiRect, Val,
|
UiImage, UiRect, Val,
|
||||||
},
|
},
|
||||||
utils::default,
|
utils::default,
|
||||||
window::{CursorIcon, WindowDescriptor, Windows},
|
window::{CursorIcon, WindowDescriptor, Windows},
|
||||||
|
@ -221,21 +221,31 @@ fn generate_graphics(
|
||||||
|
|
||||||
_ = commands.spawn_bundle(Camera2dBundle::default());
|
_ = commands.spawn_bundle(Camera2dBundle::default());
|
||||||
_ = commands
|
_ = commands
|
||||||
.spawn_bundle(ImageBundle {
|
.spawn_bundle(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
size: Size::new(Val::Percent(100.0), Val::Auto),
|
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
image: UiImage(image_handle),
|
color: Color::NONE.into(),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.with_children(|world_map| {
|
.with_children(|root_node| {
|
||||||
_ = world_map
|
_ = root_node.spawn_bundle(ImageBundle {
|
||||||
|
style: Style {
|
||||||
|
size: Size::new(Val::Percent(100.0), Val::Auto),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
image: UiImage(image_handle),
|
||||||
|
..default()
|
||||||
|
});
|
||||||
|
|
||||||
|
_ = root_node
|
||||||
.spawn_bundle(NodeBundle {
|
.spawn_bundle(NodeBundle {
|
||||||
style: Style {
|
style: Style {
|
||||||
size: Size::new(Val::Percent(100.0), Val::Undefined),
|
size: Size::new(Val::Percent(100.0), Val::Undefined),
|
||||||
padding: UiRect::all(Val::Px(3.0)),
|
padding: UiRect::all(Val::Px(3.0)),
|
||||||
justify_content: JustifyContent::SpaceAround,
|
justify_content: JustifyContent::SpaceAround,
|
||||||
|
position_type: PositionType::Absolute,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
color: Color::NONE.into(),
|
color: Color::NONE.into(),
|
||||||
|
|
Loading…
Reference in a new issue