11//! This module contains basic node bundles used to build UIs
22
33use crate :: {
4- layout_components:: { Inset , Overflow , Position , SizeConstraints , Spacing } ,
4+ layout_components:: { Inset , Position , SizeConstraints , Spacing } ,
55 prelude:: { FlexContainer , FlexItem } ,
66 widget:: Button ,
7- BackgroundColor , CalculatedSize , FocusPolicy , Interaction , Node , UiImage , ZIndex ,
7+ BackgroundColor , CalculatedSize , FocusPolicy , Interaction , LayoutControl , Node , UiImage ,
8+ ZIndex ,
89} ;
910use bevy_ecs:: bundle:: Bundle ;
1011use bevy_render:: {
@@ -21,20 +22,18 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
2122pub struct NodeBundle {
2223 /// Describes the size of the node
2324 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 ,
2429 /// Defines how this node's layout should be.
2530 pub layout : FlexContainer ,
2631 /// Defines how this node should behave as a child of a node.
2732 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 ,
3233 /// The constraints on the size of this node
3334 pub size_constraints : SizeConstraints ,
3435 /// The margin, padding and border of the UI node
3536 pub spacing : Spacing ,
36- /// The behavior in case the node overflows its allocated space
37- pub overflow : Overflow ,
3837 /// The background color, which serves as a "fill" for this node
3938 pub background_color : BackgroundColor ,
4039 /// Whether this node should block interaction with lower nodes
@@ -44,14 +43,14 @@ pub struct NodeBundle {
4443 /// This field is automatically managed by the UI layout system.
4544 /// To alter the position of this entity, use the properties of layouting components.
4645 ///
47- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
46+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
4847 pub transform : Transform ,
4948 /// The global transform of the node
5049 ///
5150 /// This field is automatically managed by the UI layout system.
5251 /// To alter the position of this entity, use the properties of layouting components.
5352 ///
54- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
53+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
5554 pub global_transform : GlobalTransform ,
5655 /// Describes the visibility properties of the node
5756 pub visibility : Visibility ,
@@ -64,15 +63,13 @@ pub struct NodeBundle {
6463impl Default for NodeBundle {
6564 fn default ( ) -> Self {
6665 NodeBundle {
67- // Transparent background
6866 node : Default :: default ( ) ,
67+ control : Default :: default ( ) ,
6968 layout : Default :: default ( ) ,
7069 child_layout : Default :: default ( ) ,
71- inset : Default :: default ( ) ,
72- position : Default :: default ( ) ,
7370 size_constraints : Default :: default ( ) ,
7471 spacing : Default :: default ( ) ,
75- overflow : Default :: default ( ) ,
72+ // Transparent background
7673 background_color : Color :: NONE . into ( ) ,
7774 focus_policy : Default :: default ( ) ,
7875 transform : Default :: default ( ) ,
@@ -89,20 +86,18 @@ impl Default for NodeBundle {
8986pub struct ImageBundle {
9087 /// Describes the size of the node
9188 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 ,
9293 /// Defines how this node's layout should be.
9394 pub layout : FlexContainer ,
9495 /// Defines how this node should behave as a child of a node.
9596 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 ,
10097 /// The constraints on the size of this node
10198 pub size_constraints : SizeConstraints ,
10299 /// The margin, padding and border of the UI node
103100 pub spacing : Spacing ,
104- /// The behavior in case the node overflows its allocated space
105- pub overflow : Overflow ,
106101 /// The calculated size based on the given image
107102 pub calculated_size : CalculatedSize ,
108103 /// The background color, which serves as a "fill" for this node
@@ -118,14 +113,14 @@ pub struct ImageBundle {
118113 /// This field is automatically managed by the UI layout system.
119114 /// To alter the position of this entity, use the properties of layouting components.
120115 ///
121- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
116+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
122117 pub transform : Transform ,
123118 /// The global transform of the node
124119 ///
125120 /// This field is automatically managed by the UI layout system.
126121 /// To alter the position of this entity, use the properties of layouting components.
127122 ///
128- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
123+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
129124 pub global_transform : GlobalTransform ,
130125 /// Describes the visibility properties of the node
131126 pub visibility : Visibility ,
@@ -140,20 +135,18 @@ pub struct ImageBundle {
140135pub struct TextBundle {
141136 /// Describes the size of the node
142137 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 ,
143142 /// Defines how this node's layout should be.
144143 pub layout : FlexContainer ,
145144 /// Defines how this node should behave as a child of a node.
146145 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 ,
151146 /// The constraints on the size of this node
152147 pub size_constraints : SizeConstraints ,
153148 /// The margin, padding and border of the UI node
154149 pub spacing : Spacing ,
155- /// The behavior in case the node overflows its allocated space
156- pub overflow : Overflow ,
157150 /// Contains the text of the node
158151 pub text : Text ,
159152 /// The calculated size based on the given image
@@ -165,14 +158,14 @@ pub struct TextBundle {
165158 /// This field is automatically managed by the UI layout system.
166159 /// To alter the position of this entity, use the properties of layouting components.
167160 ///
168- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
161+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
169162 pub transform : Transform ,
170163 /// The global transform of the node
171164 ///
172165 /// This field is automatically managed by the UI layout system.
173166 /// To alter the position of this entity, use the properties of layouting components.
174167 ///
175- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
168+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
176169 pub global_transform : GlobalTransform ,
177170 /// Describes the visibility properties of the node
178171 pub visibility : Visibility ,
@@ -235,13 +228,13 @@ impl TextBundle {
235228
236229 /// Returns this [`TextBundle`] with a new [`Position`].
237230 pub const fn with_position ( mut self , position : Position ) -> Self {
238- self . position = position;
231+ self . control . position = position;
239232 self
240233 }
241234
242235 /// Returns this [`TextBundle`] with a new [`Inset`].
243236 pub const fn with_inset ( mut self , inset : Inset ) -> Self {
244- self . inset = inset;
237+ self . control . inset = inset;
245238 self
246239 }
247240}
@@ -254,16 +247,14 @@ impl Default for TextBundle {
254247 node : Default :: default ( ) ,
255248 calculated_size : Default :: default ( ) ,
256249 layout : Default :: default ( ) ,
250+ control : Default :: default ( ) ,
257251 child_layout : Default :: default ( ) ,
258- position : Default :: default ( ) ,
259252 size_constraints : Default :: default ( ) ,
260- overflow : Default :: default ( ) ,
261253 transform : Default :: default ( ) ,
262254 global_transform : Default :: default ( ) ,
263255 visibility : Default :: default ( ) ,
264256 computed_visibility : Default :: default ( ) ,
265257 z_index : Default :: default ( ) ,
266- inset : Default :: default ( ) ,
267258 spacing : Default :: default ( ) ,
268259 }
269260 }
@@ -276,20 +267,18 @@ pub struct ButtonBundle {
276267 pub node : Node ,
277268 /// Marker component that signals this node is a button
278269 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 ,
279274 /// Defines how this node's layout should be.
280275 pub layout : FlexContainer ,
281276 /// Defines how this node should behave as a child of a node.
282277 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 ,
287278 /// The constraints on the size of this node
288279 pub size_constraints : SizeConstraints ,
289280 /// The margin, padding and border of the UI node
290281 pub spacing : Spacing ,
291- /// The behavior in case the node overflows its allocated space
292- pub overflow : Overflow ,
293282 /// Describes whether and how the button has been interacted with by the input
294283 pub interaction : Interaction ,
295284 /// Whether this node should block interaction with lower nodes
@@ -305,14 +294,14 @@ pub struct ButtonBundle {
305294 /// This field is automatically managed by the UI layout system.
306295 /// To alter the position of this entity, use the properties of layouting components.
307296 ///
308- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
297+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
309298 pub transform : Transform ,
310299 /// The global transform of the node
311300 ///
312301 /// This field is automatically managed by the UI layout system.
313302 /// To alter the position of this entity, use the properties of layouting components.
314303 ///
315- /// See: [`FlexContainer `], [`FlexItem `], [`Inset `], [`Position`], [` SizeConstraints`], [`Spacing`], [`Overflow `].
304+ /// See: [`LayoutControl `], [`FlexContainer `], [`FlexItem `], [`SizeConstraints`], [`Spacing`].
316305 pub global_transform : GlobalTransform ,
317306 /// Describes the visibility properties of the node
318307 pub visibility : Visibility ,
0 commit comments