diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index 64c6e1e7879fb..7282150298258 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -10,4 +10,3 @@ keywords = ["bevy"] [dependencies] glam = { version = "0.20.0", features = ["serde", "bytemuck"] } -bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", features = ["bevy"] } diff --git a/crates/bevy_math/src/geometry.rs b/crates/bevy_math/src/geometry.rs deleted file mode 100644 index ed93591485e36..0000000000000 --- a/crates/bevy_math/src/geometry.rs +++ /dev/null @@ -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 { - pub left: T, - pub right: T, - pub top: T, - pub bottom: T, -} - -impl Rect { - pub fn all(value: T) -> Self - where - T: Clone, - { - Rect { - left: value.clone(), - right: value.clone(), - top: value.clone(), - bottom: value, - } - } -} - -impl Default for Rect { - fn default() -> Self { - Self { - left: Default::default(), - right: Default::default(), - top: Default::default(), - bottom: Default::default(), - } - } -} diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 866e4ec4d0c70..f854004559a25 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -1,12 +1,9 @@ -mod geometry; - -pub use geometry::*; pub use glam::*; pub mod prelude { #[doc(hidden)] pub use crate::{ - BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, Rect, UVec2, UVec3, - UVec4, Vec2, Vec3, Vec4, + BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, UVec2, UVec3, UVec4, + Vec2, Vec3, Vec4, }; } diff --git a/crates/bevy_ui/src/flex/convert.rs b/crates/bevy_ui/src/flex/convert.rs index fab4e8b8d4dd0..3c73b1f566714 100644 --- a/crates/bevy_ui/src/flex/convert.rs +++ b/crates/bevy_ui/src/flex/convert.rs @@ -1,12 +1,11 @@ use crate::{ 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( scale_factor: f64, - rect: Rect, + rect: UiRect, ) -> stretch::geometry::Rect { stretch::geometry::Rect { start: from_val(scale_factor, rect.left), diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index f06d1d7ad3cfa..2ce50140a4eaa 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -2,6 +2,41 @@ use bevy_math::Vec2; use bevy_reflect::Reflect; 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 { + pub left: T, + pub right: T, + pub top: T, + pub bottom: T, +} + +impl UiRect { + pub fn all(value: T) -> Self + where + T: Clone, + { + UiRect { + left: value.clone(), + right: value.clone(), + top: value.clone(), + bottom: value, + } + } +} + +impl Default for UiRect { + 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 #[derive(Copy, Clone, PartialEq, Debug, Reflect)] #[reflect(PartialEq)] diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index 2d4f1e2b6f1d8..4155bf11729cc 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -29,7 +29,6 @@ use crate::Size; use bevy_app::prelude::*; use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel}; use bevy_input::InputSystem; -use bevy_math::Rect; use bevy_transform::TransformSystem; use bevy_window::ModifiesWindows; use update::{ui_z_system, update_clipping_system}; @@ -71,7 +70,7 @@ impl Plugin for UiPlugin { .register_type::() .register_type::>() .register_type::>() - .register_type::>() + .register_type::>() .register_type::