Skip to content

Commit 0b8cc1b

Browse files
committed
Fix issues from rebase
1 parent 2a48ceb commit 0b8cc1b

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

crates/bevy_ui/src/geometry.rs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ pub struct UiRect {
134134
pub bottom: Val,
135135
}
136136

137-
impl UiRect<Val> {
138-
/// ```rust
139-
/// assert_eq!(UiRect<Val>::DEFAULT, UiRect<Val>::default());
140-
/// ```
141-
pub const DEFAULT: UiRect<Val> = UiRect {
142-
left: Val::Undefined,
143-
right: Val::Undefined,
144-
top: Val::Undefined,
145-
bottom: Val::Undefined,
146-
};
147-
}
148-
149137
impl UiRect {
150138
/// Creates a new [`UiRect`] from the values specified.
151139
///
@@ -166,7 +154,7 @@ impl UiRect {
166154
/// assert_eq!(ui_rect.top, Val::Px(30.0));
167155
/// assert_eq!(ui_rect.bottom, Val::Px(40.0));
168156
/// ```
169-
pub fn new(left: Val, right: Val, top: Val, bottom: Val) -> Self {
157+
pub const fn new(left: Val, right: Val, top: Val, bottom: Val) -> Self {
170158
UiRect {
171159
left,
172160
right,
@@ -189,14 +177,35 @@ impl UiRect {
189177
/// assert_eq!(ui_rect.top, Val::Px(10.0));
190178
/// assert_eq!(ui_rect.bottom, Val::Px(10.0));
191179
/// ```
192-
pub fn all(value: Val) -> Self {
180+
pub const fn all(value: Val) -> Self {
193181
UiRect {
194182
left: value,
195183
right: value,
196184
top: value,
197185
bottom: value,
198186
}
199187
}
188+
189+
/// ```rust
190+
/// assert_eq!(UiRect::DEFAULT, UiRect::default());
191+
/// ```
192+
pub const DEFAULT: UiRect = UiRect::UNDEFINED;
193+
194+
/// Creates a [`UiRect`] where all sides are [`Val::Undefined`]
195+
pub const UNDEFINED: UiRect = UiRect {
196+
left: Val::Undefined,
197+
right: Val::Undefined,
198+
top: Val::Undefined,
199+
bottom: Val::Undefined,
200+
};
201+
202+
/// Creates a [`UiRect`] where all sides are [`Val::Auto`]
203+
pub const AUTO: UiRect = UiRect {
204+
left: Val::Auto,
205+
right: Val::Auto,
206+
top: Val::Auto,
207+
bottom: Val::Auto,
208+
};
200209
}
201210

202211
/// A 2-dimensional area defined by a width and height.
@@ -228,6 +237,8 @@ impl Size {
228237
Size { width, height }
229238
}
230239

240+
pub const DEFAULT: Size = Size::UNDEFINED;
241+
231242
/// Creates a Size where both values are [`Val::Auto`].
232243
pub const AUTO: Size = Size {
233244
width: Val::Auto,
@@ -240,7 +251,8 @@ impl Size {
240251
height: Val::Undefined,
241252
};
242253

243-
pub const FULL: Size<Val> = Size {
254+
/// Creates a Size where both values are 100 percent.
255+
pub const FULL: Size = Size {
244256
width: Val::Percent(100.),
245257
height: Val::Percent(100.),
246258
};

crates/bevy_ui/src/layout_components.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub enum PositionType {
5454
Reflect,
5555
)]
5656
#[reflect_value(PartialEq, Serialize, Deserialize)]
57-
pub struct Offset(pub UiRect<Val>);
57+
pub struct Offset(pub UiRect);
5858

5959
/// Controls the size of UI nodes
6060
///
@@ -64,11 +64,11 @@ pub struct Offset(pub UiRect<Val>);
6464
#[reflect_value(PartialEq, Serialize, Deserialize)]
6565
pub struct SizeConstraints {
6666
/// The minimum extent, which cannot be violated by the layouting algorithm
67-
pub min: Size<Val>,
67+
pub min: Size,
6868
/// The suggested extent, which will be used if other constraints can be comfortably satisfied
69-
pub suggested: Size<Val>,
69+
pub suggested: Size,
7070
/// The maximum extent, which cannot be violated by the layouting algorithm
71-
pub max: Size<Val>,
71+
pub max: Size,
7272
/// The expected aspect ratio, computed as width / height
7373
pub aspect_ratio: Option<f32>,
7474
}
@@ -121,11 +121,11 @@ impl SizeConstraints {
121121
#[reflect_value(PartialEq, Serialize, Deserialize)]
122122
pub struct Spacing {
123123
/// The space around the outside of the UI element
124-
pub margin: UiRect<Val>,
124+
pub margin: UiRect,
125125
/// The space around the inside of the UI element
126-
pub padding: UiRect<Val>,
126+
pub padding: UiRect,
127127
/// The space around the outside of the UI element that can be colored to create a visible border
128-
pub border: UiRect<Val>,
128+
pub border: UiRect,
129129
}
130130

131131
impl Spacing {
@@ -150,7 +150,7 @@ impl Spacing {
150150
});
151151

152152
/// Sets only the margin
153-
pub const fn margin(rect: UiRect<Val>) -> Spacing {
153+
pub const fn margin(rect: UiRect) -> Spacing {
154154
Spacing {
155155
margin: rect,
156156
..Self::DEFAULT
@@ -171,7 +171,7 @@ impl Spacing {
171171
}
172172

173173
/// Sets only the padding
174-
pub const fn padding(rect: UiRect<Val>) -> Spacing {
174+
pub const fn padding(rect: UiRect) -> Spacing {
175175
Spacing {
176176
padding: rect,
177177
..Self::DEFAULT
@@ -192,7 +192,7 @@ impl Spacing {
192192
}
193193

194194
/// Sets only the padding
195-
pub const fn border(rect: UiRect<Val>) -> Spacing {
195+
pub const fn border(rect: UiRect) -> Spacing {
196196
Spacing {
197197
border: rect,
198198
..Self::DEFAULT

crates/bevy_ui/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ impl Plugin for UiPlugin {
9595
.register_type::<Overflow>()
9696
.register_type::<PositionType>()
9797
.register_type::<Size>()
98-
.register_type::<Size<f32>>()
99-
.register_type::<Size<Val>>()
10098
.register_type::<UiRect>()
101-
.register_type::<UiRect<Val>>()
10299
.register_type::<FlexLayout>()
103100
.register_type::<UiColor>()
104101
.register_type::<UiImage>()

0 commit comments

Comments
 (0)