Move Rect to bevy_ui and rename it to UiRect (#4276)

# Objective

- Closes #335.
- Related #4285.
- Part of the splitting process of #3503.

## Solution

- Move `Rect` to `bevy_ui` and rename it to `UiRect`.

## Reasons

- `Rect` is only used in `bevy_ui` and therefore calling it `UiRect` makes the intent clearer.
- We have two types that are called `Rect` currently and it's missleading (see `bevy_sprite::Rect` and #335).
- Discussion in #3503.

## Changelog

### Changed

- The `Rect` type got moved from `bevy_math` to `bevy_ui` and renamed to `UiRect`.

## Migration Guide

- The `Rect` type got renamed to `UiRect`. To migrate you just have to change every occurrence of `Rect` to `UiRect`.

Co-authored-by: KDecay <KDecayMusic@protonmail.com>
This commit is contained in:
KDecay 2022-04-25 19:20:38 +00:00
parent 91f2b51083
commit 989fb8a78d
19 changed files with 84 additions and 91 deletions

View File

@ -10,4 +10,3 @@ keywords = ["bevy"]
[dependencies] [dependencies]
glam = { version = "0.20.0", features = ["serde", "bytemuck"] } glam = { version = "0.20.0", features = ["serde", "bytemuck"] }
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] }

View File

@ -1,36 +0,0 @@
use bevy_reflect::Reflect;
/// A rect, as defined by its "side" locations
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
pub struct Rect<T: Reflect + PartialEq> {
pub left: T,
pub right: T,
pub top: T,
pub bottom: T,
}
impl<T: Reflect + PartialEq> Rect<T> {
pub fn all(value: T) -> Self
where
T: Clone,
{
Rect {
left: value.clone(),
right: value.clone(),
top: value.clone(),
bottom: value,
}
}
}
impl<T: Default + Reflect + PartialEq> Default for Rect<T> {
fn default() -> Self {
Self {
left: Default::default(),
right: Default::default(),
top: Default::default(),
bottom: Default::default(),
}
}
}

View File

@ -1,12 +1,9 @@
mod geometry;
pub use geometry::*;
pub use glam::*; pub use glam::*;
pub mod prelude { pub mod prelude {
#[doc(hidden)] #[doc(hidden)]
pub use crate::{ pub use crate::{
BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, Rect, UVec2, UVec3, BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, UVec2, UVec3, UVec4,
UVec4, Vec2, Vec3, Vec4, Vec2, Vec3, Vec4,
}; };
} }

View File

@ -1,12 +1,11 @@
use crate::{ use crate::{
AlignContent, AlignItems, AlignSelf, Direction, Display, FlexDirection, FlexWrap, AlignContent, AlignItems, AlignSelf, Direction, Display, FlexDirection, FlexWrap,
JustifyContent, PositionType, Size, Style, Val, JustifyContent, PositionType, Size, Style, UiRect, Val,
}; };
use bevy_math::Rect;
pub fn from_rect( pub fn from_rect(
scale_factor: f64, scale_factor: f64,
rect: Rect<Val>, rect: UiRect<Val>,
) -> stretch::geometry::Rect<stretch::style::Dimension> { ) -> stretch::geometry::Rect<stretch::style::Dimension> {
stretch::geometry::Rect { stretch::geometry::Rect {
start: from_val(scale_factor, rect.left), start: from_val(scale_factor, rect.left),

View File

@ -2,6 +2,41 @@ use bevy_math::Vec2;
use bevy_reflect::Reflect; use bevy_reflect::Reflect;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
/// A rect, as defined by its "side" locations
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
pub struct UiRect<T: Reflect + PartialEq> {
pub left: T,
pub right: T,
pub top: T,
pub bottom: T,
}
impl<T: Reflect + PartialEq> UiRect<T> {
pub fn all(value: T) -> Self
where
T: Clone,
{
UiRect {
left: value.clone(),
right: value.clone(),
top: value.clone(),
bottom: value,
}
}
}
impl<T: Default + Reflect + PartialEq> Default for UiRect<T> {
fn default() -> Self {
Self {
left: Default::default(),
right: Default::default(),
top: Default::default(),
bottom: Default::default(),
}
}
}
/// A two dimensional "size" as defined by a width and height /// A two dimensional "size" as defined by a width and height
#[derive(Copy, Clone, PartialEq, Debug, Reflect)] #[derive(Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)] #[reflect(PartialEq)]

View File

@ -29,7 +29,6 @@ use crate::Size;
use bevy_app::prelude::*; use bevy_app::prelude::*;
use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel}; use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel};
use bevy_input::InputSystem; use bevy_input::InputSystem;
use bevy_math::Rect;
use bevy_transform::TransformSystem; use bevy_transform::TransformSystem;
use bevy_window::ModifiesWindows; use bevy_window::ModifiesWindows;
use update::{ui_z_system, update_clipping_system}; use update::{ui_z_system, update_clipping_system};
@ -71,7 +70,7 @@ impl Plugin for UiPlugin {
.register_type::<PositionType>() .register_type::<PositionType>()
.register_type::<Size<f32>>() .register_type::<Size<f32>>()
.register_type::<Size<Val>>() .register_type::<Size<Val>>()
.register_type::<Rect<Val>>() .register_type::<UiRect<Val>>()
.register_type::<Style>() .register_type::<Style>()
.register_type::<UiColor>() .register_type::<UiColor>()
.register_type::<UiImage>() .register_type::<UiImage>()

View File

@ -1,7 +1,7 @@
use crate::Size; use crate::{Size, UiRect};
use bevy_asset::Handle; use bevy_asset::Handle;
use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_math::{Rect, Vec2}; use bevy_math::Vec2;
use bevy_reflect::{Reflect, ReflectDeserialize}; use bevy_reflect::{Reflect, ReflectDeserialize};
use bevy_render::{ use bevy_render::{
color::Color, color::Color,
@ -90,13 +90,13 @@ pub struct Style {
/// How items align according to the main axis /// How items align according to the main axis
pub justify_content: JustifyContent, pub justify_content: JustifyContent,
/// The position of the node as descrided by its Rect /// The position of the node as descrided by its Rect
pub position: Rect<Val>, pub position: UiRect<Val>,
/// The margin of the node /// The margin of the node
pub margin: Rect<Val>, pub margin: UiRect<Val>,
/// The padding of the node /// The padding of the node
pub padding: Rect<Val>, pub padding: UiRect<Val>,
/// The border of the node /// The border of the node
pub border: Rect<Val>, pub border: UiRect<Val>,
/// Defines how much a flexbox item should grow if there's space available /// Defines how much a flexbox item should grow if there's space available
pub flex_grow: f32, pub flex_grow: f32,
/// How to shrink if there's not enough space available /// How to shrink if there's not enough space available

View File

@ -40,7 +40,7 @@ fn setup_menu(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(150.0), Val::Px(65.0)), size: Size::new(Val::Px(150.0), Val::Px(65.0)),
// center button // center button
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
// horizontally center child text // horizontally center child text
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
// vertically center child text // vertically center child text

View File

@ -165,7 +165,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut game: ResMu
), ),
style: Style { style: Style {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(5.0), top: Val::Px(5.0),
left: Val::Px(5.0), left: Val::Px(5.0),
..default() ..default()
@ -374,7 +374,7 @@ fn display_score(mut commands: Commands, asset_server: Res<AssetServer>, game: R
commands commands
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()

View File

@ -241,7 +241,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}, },
style: Style { style: Style {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: SCOREBOARD_TEXT_PADDING, top: SCOREBOARD_TEXT_PADDING,
left: SCOREBOARD_TEXT_PADDING, left: SCOREBOARD_TEXT_PADDING,
..default() ..default()

View File

@ -86,7 +86,7 @@ mod splash {
.spawn_bundle(ImageBundle { .spawn_bundle(ImageBundle {
style: Style { style: Style {
// This will center the logo // This will center the logo
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
// This will set the logo to be 200px wide, and auto adjust its height // This will set the logo to be 200px wide, and auto adjust its height
size: Size::new(Val::Px(200.0), Val::Auto), size: Size::new(Val::Px(200.0), Val::Auto),
..default() ..default()
@ -150,7 +150,7 @@ mod game {
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
// This will center the current node // This will center the current node
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
// This will display its children in a column, from top to bottom. Unlike // This will display its children in a column, from top to bottom. Unlike
// in Flexbox, Bevy origin is on bottom left, so the vertical axis is reversed // in Flexbox, Bevy origin is on bottom left, so the vertical axis is reversed
flex_direction: FlexDirection::ColumnReverse, flex_direction: FlexDirection::ColumnReverse,
@ -168,7 +168,7 @@ mod game {
// Display two lines of text, the second one with the current settings // Display two lines of text, the second one with the current settings
parent.spawn_bundle(TextBundle { parent.spawn_bundle(TextBundle {
style: Style { style: Style {
margin: Rect::all(Val::Px(50.0)), margin: UiRect::all(Val::Px(50.0)),
..default() ..default()
}, },
text: Text::with_section( text: Text::with_section(
@ -184,7 +184,7 @@ mod game {
}); });
parent.spawn_bundle(TextBundle { parent.spawn_bundle(TextBundle {
style: Style { style: Style {
margin: Rect::all(Val::Px(50.0)), margin: UiRect::all(Val::Px(50.0)),
..default() ..default()
}, },
text: Text { text: Text {
@ -396,7 +396,7 @@ mod menu {
// Common style for all buttons on the screen // Common style for all buttons on the screen
let button_style = Style { let button_style = Style {
size: Size::new(Val::Px(250.0), Val::Px(65.0)), size: Size::new(Val::Px(250.0), Val::Px(65.0)),
margin: Rect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -406,7 +406,7 @@ mod menu {
// This takes the icons out of the flexbox flow, to be positionned exactly // This takes the icons out of the flexbox flow, to be positionned exactly
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
// The icon will be close to the left border of the button // The icon will be close to the left border of the button
position: Rect { position: UiRect {
left: Val::Px(10.0), left: Val::Px(10.0),
right: Val::Auto, right: Val::Auto,
top: Val::Auto, top: Val::Auto,
@ -423,7 +423,7 @@ mod menu {
commands commands
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
flex_direction: FlexDirection::ColumnReverse, flex_direction: FlexDirection::ColumnReverse,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -436,7 +436,7 @@ mod menu {
// Display the game name // Display the game name
parent.spawn_bundle(TextBundle { parent.spawn_bundle(TextBundle {
style: Style { style: Style {
margin: Rect::all(Val::Px(50.0)), margin: UiRect::all(Val::Px(50.0)),
..default() ..default()
}, },
text: Text::with_section( text: Text::with_section(
@ -526,7 +526,7 @@ mod menu {
fn settings_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) { fn settings_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let button_style = Style { let button_style = Style {
size: Size::new(Val::Px(200.0), Val::Px(65.0)), size: Size::new(Val::Px(200.0), Val::Px(65.0)),
margin: Rect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -540,7 +540,7 @@ mod menu {
commands commands
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
flex_direction: FlexDirection::ColumnReverse, flex_direction: FlexDirection::ColumnReverse,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -609,7 +609,7 @@ mod menu {
) { ) {
let button_style = Style { let button_style = Style {
size: Size::new(Val::Px(200.0), Val::Px(65.0)), size: Size::new(Val::Px(200.0), Val::Px(65.0)),
margin: Rect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -623,7 +623,7 @@ mod menu {
commands commands
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
flex_direction: FlexDirection::ColumnReverse, flex_direction: FlexDirection::ColumnReverse,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -707,7 +707,7 @@ mod menu {
) { ) {
let button_style = Style { let button_style = Style {
size: Size::new(Val::Px(200.0), Val::Px(65.0)), size: Size::new(Val::Px(200.0), Val::Px(65.0)),
margin: Rect::all(Val::Px(20.0)), margin: UiRect::all(Val::Px(20.0)),
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()
@ -721,7 +721,7 @@ mod menu {
commands commands
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
flex_direction: FlexDirection::ColumnReverse, flex_direction: FlexDirection::ColumnReverse,
align_items: AlignItems::Center, align_items: AlignItems::Center,
..default() ..default()

View File

@ -134,7 +134,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}, },
style: Style { style: Style {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(5.0), top: Val::Px(5.0),
left: Val::Px(5.0), left: Val::Px(5.0),
..default() ..default()

View File

@ -50,7 +50,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(150.0), Val::Px(65.0)), size: Size::new(Val::Px(150.0), Val::Px(65.0)),
// center button // center button
margin: Rect::all(Val::Auto), margin: UiRect::all(Val::Auto),
// horizontally center child text // horizontally center child text
justify_content: JustifyContent::Center, justify_content: JustifyContent::Center,
// vertically center child text // vertically center child text

View File

@ -50,7 +50,7 @@ fn atlas_render_system(
image: texture_atlas.texture.clone().into(), image: texture_atlas.texture.clone().into(),
style: Style { style: Style {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(0.0), top: Val::Px(0.0),
left: Val::Px(512.0 * x_offset), left: Val::Px(512.0 * x_offset),
..default() ..default()

View File

@ -33,7 +33,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
align_self: AlignSelf::FlexEnd, align_self: AlignSelf::FlexEnd,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
bottom: Val::Px(5.0), bottom: Val::Px(5.0),
right: Val::Px(15.0), right: Val::Px(15.0),
..default() ..default()

View File

@ -28,7 +28,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
align_self: AlignSelf::FlexEnd, align_self: AlignSelf::FlexEnd,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(5.0), top: Val::Px(5.0),
left: Val::Px(15.0), left: Val::Px(15.0),
..default() ..default()
@ -50,7 +50,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
align_self: AlignSelf::FlexEnd, align_self: AlignSelf::FlexEnd,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(5.0), top: Val::Px(5.0),
right: Val::Px(15.0), right: Val::Px(15.0),
..default() ..default()
@ -80,7 +80,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
align_self: AlignSelf::FlexEnd, align_self: AlignSelf::FlexEnd,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
bottom: Val::Px(5.0), bottom: Val::Px(5.0),
right: Val::Px(15.0), right: Val::Px(15.0),
..default() ..default()
@ -147,7 +147,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
align_self: AlignSelf::FlexEnd, align_self: AlignSelf::FlexEnd,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
bottom: Val::Px(5.0), bottom: Val::Px(5.0),
left: Val::Px(15.0), left: Val::Px(15.0),
..default() ..default()

View File

@ -36,7 +36,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
size: Size::new(Val::Px(200.0), Val::Percent(100.0)), size: Size::new(Val::Px(200.0), Val::Percent(100.0)),
border: Rect::all(Val::Px(2.0)), border: UiRect::all(Val::Px(2.0)),
..default() ..default()
}, },
color: Color::rgb(0.65, 0.65, 0.65).into(), color: Color::rgb(0.65, 0.65, 0.65).into(),
@ -58,7 +58,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// text // text
parent.spawn_bundle(TextBundle { parent.spawn_bundle(TextBundle {
style: Style { style: Style {
margin: Rect::all(Val::Px(5.0)), margin: UiRect::all(Val::Px(5.0)),
..default() ..default()
}, },
text: Text::with_section( text: Text::with_section(
@ -91,7 +91,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
parent.spawn_bundle(TextBundle { parent.spawn_bundle(TextBundle {
style: Style { style: Style {
size: Size::new(Val::Undefined, Val::Px(25.)), size: Size::new(Val::Undefined, Val::Px(25.)),
margin: Rect { margin: UiRect {
left: Val::Auto, left: Val::Auto,
right: Val::Auto, right: Val::Auto,
..default() ..default()
@ -143,7 +143,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
flex_shrink: 0., flex_shrink: 0.,
size: Size::new(Val::Undefined, Val::Px(20.)), size: Size::new(Val::Undefined, Val::Px(20.)),
margin: Rect { margin: UiRect {
left: Val::Auto, left: Val::Auto,
right: Val::Auto, right: Val::Auto,
..default() ..default()
@ -172,12 +172,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(200.0), Val::Px(200.0)), size: Size::new(Val::Px(200.0), Val::Px(200.0)),
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
left: Val::Px(210.0), left: Val::Px(210.0),
bottom: Val::Px(10.0), bottom: Val::Px(10.0),
..default() ..default()
}, },
border: Rect::all(Val::Px(20.0)), border: UiRect::all(Val::Px(20.0)),
..default() ..default()
}, },
color: Color::rgb(0.4, 0.4, 1.0).into(), color: Color::rgb(0.4, 0.4, 1.0).into(),
@ -221,7 +221,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)), size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
left: Val::Px(20.0), left: Val::Px(20.0),
bottom: Val::Px(20.0), bottom: Val::Px(20.0),
..default() ..default()
@ -235,7 +235,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)), size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
left: Val::Px(40.0), left: Val::Px(40.0),
bottom: Val::Px(40.0), bottom: Val::Px(40.0),
..default() ..default()
@ -249,7 +249,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)), size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
left: Val::Px(60.0), left: Val::Px(60.0),
bottom: Val::Px(60.0), bottom: Val::Px(60.0),
..default() ..default()
@ -264,7 +264,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
style: Style { style: Style {
size: Size::new(Val::Px(100.0), Val::Px(100.0)), size: Size::new(Val::Px(100.0), Val::Px(100.0)),
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
left: Val::Px(80.0), left: Val::Px(80.0),
bottom: Val::Px(80.0), bottom: Val::Px(80.0),
..default() ..default()

View File

@ -169,7 +169,7 @@ pub(crate) mod test_setup {
style: Style { style: Style {
align_self: AlignSelf::FlexStart, align_self: AlignSelf::FlexStart,
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
position: Rect { position: UiRect {
top: Val::Px(5.0), top: Val::Px(5.0),
left: Val::Px(5.0), left: Val::Px(5.0),
..Default::default() ..Default::default()

View File

@ -35,7 +35,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.spawn_bundle(NodeBundle { .spawn_bundle(NodeBundle {
style: Style { style: Style {
size: Size::new(Val::Px(200.0), Val::Percent(100.0)), size: Size::new(Val::Px(200.0), Val::Percent(100.0)),
border: Rect::all(Val::Px(2.0)), border: UiRect::all(Val::Px(2.0)),
..default() ..default()
}, },
color: Color::rgb(0.65, 0.65, 0.65).into(), color: Color::rgb(0.65, 0.65, 0.65).into(),