1
1
//! This module contains basic node bundles used to build UIs
2
2
3
3
use crate :: {
4
- layout_components:: { Inset , Overflow , Position , SizeConstraints , Spacing } ,
4
+ layout_components:: { Inset , Position , SizeConstraints , Spacing } ,
5
5
prelude:: { FlexContainer , FlexItem } ,
6
6
widget:: Button ,
7
- BackgroundColor , CalculatedSize , FocusPolicy , Interaction , Node , UiImage , ZIndex ,
7
+ BackgroundColor , CalculatedSize , FocusPolicy , Interaction , LayoutControl , Node , UiImage ,
8
+ ZIndex ,
8
9
} ;
9
10
use bevy_ecs:: bundle:: Bundle ;
10
11
use bevy_render:: {
@@ -21,20 +22,18 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
21
22
pub struct NodeBundle {
22
23
/// Describes the size of the node
23
24
pub node : Node ,
25
+ /// Core controls for layouting of this node.
26
+ ///
27
+ /// See: [`Display`](crate::Display), [`Position`](crate::Position), [`Inset`](crate::Inset), [`Overflow`](crate::Overflow).
28
+ pub control : LayoutControl ,
24
29
/// Defines how this node's layout should be.
25
30
pub layout : FlexContainer ,
26
31
/// Defines how this node should behave as a child of a node.
27
32
pub child_layout : FlexItem ,
28
- /// The inset of this UI node, relative to its default position
29
- pub inset : Inset ,
30
- /// Whether the node should be absolute or relatively positioned
31
- pub position : Position ,
32
33
/// The constraints on the size of this node
33
34
pub size_constraints : SizeConstraints ,
34
35
/// The margin, padding and border of the UI node
35
36
pub spacing : Spacing ,
36
- /// The behavior in case the node overflows its allocated space
37
- pub overflow : Overflow ,
38
37
/// The background color, which serves as a "fill" for this node
39
38
pub background_color : BackgroundColor ,
40
39
/// Whether this node should block interaction with lower nodes
@@ -44,14 +43,14 @@ pub struct NodeBundle {
44
43
/// This field is automatically managed by the UI layout system.
45
44
/// To alter the position of this entity, use the properties of layouting components.
46
45
///
47
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
46
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
48
47
pub transform : Transform ,
49
48
/// The global transform of the node
50
49
///
51
50
/// This field is automatically managed by the UI layout system.
52
51
/// To alter the position of this entity, use the properties of layouting components.
53
52
///
54
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
53
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
55
54
pub global_transform : GlobalTransform ,
56
55
/// Describes the visibility properties of the node
57
56
pub visibility : Visibility ,
@@ -64,15 +63,13 @@ pub struct NodeBundle {
64
63
impl Default for NodeBundle {
65
64
fn default ( ) -> Self {
66
65
NodeBundle {
67
- // Transparent background
68
66
node : Default :: default ( ) ,
67
+ control : Default :: default ( ) ,
69
68
layout : Default :: default ( ) ,
70
69
child_layout : Default :: default ( ) ,
71
- inset : Default :: default ( ) ,
72
- position : Default :: default ( ) ,
73
70
size_constraints : Default :: default ( ) ,
74
71
spacing : Default :: default ( ) ,
75
- overflow : Default :: default ( ) ,
72
+ // Transparent background
76
73
background_color : Color :: NONE . into ( ) ,
77
74
focus_policy : Default :: default ( ) ,
78
75
transform : Default :: default ( ) ,
@@ -89,20 +86,18 @@ impl Default for NodeBundle {
89
86
pub struct ImageBundle {
90
87
/// Describes the size of the node
91
88
pub node : Node ,
89
+ /// Core controls for layouting of this node.
90
+ ///
91
+ /// See: [`Display`](crate::Display), [`Position`](crate::Position), [`Inset`](crate::Inset), [`Overflow`](crate::Overflow).
92
+ pub control : LayoutControl ,
92
93
/// Defines how this node's layout should be.
93
94
pub layout : FlexContainer ,
94
95
/// Defines how this node should behave as a child of a node.
95
96
pub child_layout : FlexItem ,
96
- /// The inset of this UI node, relative to its default position
97
- pub inset : Inset ,
98
- /// Whether the node should be absolute or relatively positioned
99
- pub position : Position ,
100
97
/// The constraints on the size of this node
101
98
pub size_constraints : SizeConstraints ,
102
99
/// The margin, padding and border of the UI node
103
100
pub spacing : Spacing ,
104
- /// The behavior in case the node overflows its allocated space
105
- pub overflow : Overflow ,
106
101
/// The calculated size based on the given image
107
102
pub calculated_size : CalculatedSize ,
108
103
/// The background color, which serves as a "fill" for this node
@@ -118,14 +113,14 @@ pub struct ImageBundle {
118
113
/// This field is automatically managed by the UI layout system.
119
114
/// To alter the position of this entity, use the properties of layouting components.
120
115
///
121
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
116
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
122
117
pub transform : Transform ,
123
118
/// The global transform of the node
124
119
///
125
120
/// This field is automatically managed by the UI layout system.
126
121
/// To alter the position of this entity, use the properties of layouting components.
127
122
///
128
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
123
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
129
124
pub global_transform : GlobalTransform ,
130
125
/// Describes the visibility properties of the node
131
126
pub visibility : Visibility ,
@@ -140,20 +135,18 @@ pub struct ImageBundle {
140
135
pub struct TextBundle {
141
136
/// Describes the size of the node
142
137
pub node : Node ,
138
+ /// Core controls for layouting of this node.
139
+ ///
140
+ /// See: [`Display`](crate::Display), [`Position`](crate::Position), [`Inset`](crate::Inset), [`Overflow`](crate::Overflow).
141
+ pub control : LayoutControl ,
143
142
/// Defines how this node's layout should be.
144
143
pub layout : FlexContainer ,
145
144
/// Defines how this node should behave as a child of a node.
146
145
pub child_layout : FlexItem ,
147
- /// The inset of this UI node, relative to its default position
148
- pub inset : Inset ,
149
- /// Whether the node should be absolute or relatively positioned
150
- pub position : Position ,
151
146
/// The constraints on the size of this node
152
147
pub size_constraints : SizeConstraints ,
153
148
/// The margin, padding and border of the UI node
154
149
pub spacing : Spacing ,
155
- /// The behavior in case the node overflows its allocated space
156
- pub overflow : Overflow ,
157
150
/// Contains the text of the node
158
151
pub text : Text ,
159
152
/// The calculated size based on the given image
@@ -165,14 +158,14 @@ pub struct TextBundle {
165
158
/// This field is automatically managed by the UI layout system.
166
159
/// To alter the position of this entity, use the properties of layouting components.
167
160
///
168
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
161
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
169
162
pub transform : Transform ,
170
163
/// The global transform of the node
171
164
///
172
165
/// This field is automatically managed by the UI layout system.
173
166
/// To alter the position of this entity, use the properties of layouting components.
174
167
///
175
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
168
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
176
169
pub global_transform : GlobalTransform ,
177
170
/// Describes the visibility properties of the node
178
171
pub visibility : Visibility ,
@@ -235,13 +228,13 @@ impl TextBundle {
235
228
236
229
/// Returns this [`TextBundle`] with a new [`Position`].
237
230
pub const fn with_position ( mut self , position : Position ) -> Self {
238
- self . position = position;
231
+ self . control . position = position;
239
232
self
240
233
}
241
234
242
235
/// Returns this [`TextBundle`] with a new [`Inset`].
243
236
pub const fn with_inset ( mut self , inset : Inset ) -> Self {
244
- self . inset = inset;
237
+ self . control . inset = inset;
245
238
self
246
239
}
247
240
}
@@ -254,16 +247,14 @@ impl Default for TextBundle {
254
247
node : Default :: default ( ) ,
255
248
calculated_size : Default :: default ( ) ,
256
249
layout : Default :: default ( ) ,
250
+ control : Default :: default ( ) ,
257
251
child_layout : Default :: default ( ) ,
258
- position : Default :: default ( ) ,
259
252
size_constraints : Default :: default ( ) ,
260
- overflow : Default :: default ( ) ,
261
253
transform : Default :: default ( ) ,
262
254
global_transform : Default :: default ( ) ,
263
255
visibility : Default :: default ( ) ,
264
256
computed_visibility : Default :: default ( ) ,
265
257
z_index : Default :: default ( ) ,
266
- inset : Default :: default ( ) ,
267
258
spacing : Default :: default ( ) ,
268
259
}
269
260
}
@@ -276,20 +267,18 @@ pub struct ButtonBundle {
276
267
pub node : Node ,
277
268
/// Marker component that signals this node is a button
278
269
pub button : Button ,
270
+ /// Core controls for layouting of this node.
271
+ ///
272
+ /// See: [`Display`](crate::Display), [`Position`](crate::Position), [`Inset`](crate::Inset), [`Overflow`](crate::Overflow).
273
+ pub control : LayoutControl ,
279
274
/// Defines how this node's layout should be.
280
275
pub layout : FlexContainer ,
281
276
/// Defines how this node should behave as a child of a node.
282
277
pub child_layout : FlexItem ,
283
- /// The inset of this UI node, relative to its default position
284
- pub inset : Inset ,
285
- /// Whether the node should be absolute or relatively positioned
286
- pub position : Position ,
287
278
/// The constraints on the size of this node
288
279
pub size_constraints : SizeConstraints ,
289
280
/// The margin, padding and border of the UI node
290
281
pub spacing : Spacing ,
291
- /// The behavior in case the node overflows its allocated space
292
- pub overflow : Overflow ,
293
282
/// Describes whether and how the button has been interacted with by the input
294
283
pub interaction : Interaction ,
295
284
/// Whether this node should block interaction with lower nodes
@@ -305,14 +294,14 @@ pub struct ButtonBundle {
305
294
/// This field is automatically managed by the UI layout system.
306
295
/// To alter the position of this entity, use the properties of layouting components.
307
296
///
308
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
297
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
309
298
pub transform : Transform ,
310
299
/// The global transform of the node
311
300
///
312
301
/// This field is automatically managed by the UI layout system.
313
302
/// To alter the position of this entity, use the properties of layouting components.
314
303
///
315
- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
304
+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
316
305
pub global_transform : GlobalTransform ,
317
306
/// Describes the visibility properties of the node
318
307
pub visibility : Visibility ,
0 commit comments