Skip to content

Commit 30164e7

Browse files
Move Wrap back to a subcomponent
This reverts commit 8824e3a.
1 parent 6f9ed8a commit 30164e7

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

crates/bevy_ui/src/entity.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{
44
layout_components::{
55
flex::FlexLayout, LayoutStrategy, Offset, Overflow, PositionType, SizeConstraints, Spacing,
6-
TextDirection, Wrap,
6+
TextDirection,
77
},
88
widget::{Button, ImageMode},
99
CalculatedSize, FocusPolicy, Interaction, Node, UiColor, UiImage,
@@ -39,8 +39,6 @@ pub struct NodeBundle {
3939
pub flex_layout: FlexLayout,
4040
/// The direction of the text
4141
pub text_direction: TextDirection,
42-
/// Controls how the content wraps
43-
pub wrap: Wrap,
4442
/// The behavior in case the node overflows its allocated space
4543
pub overflow: Overflow,
4644
/// Describes the color of the node
@@ -78,8 +76,6 @@ pub struct ImageBundle {
7876
pub flex_layout: FlexLayout,
7977
/// The direction of the text
8078
pub text_direction: TextDirection,
81-
/// Controls how the content wraps
82-
pub wrap: Wrap,
8379
/// The behavior in case the node overflows its allocated space
8480
pub overflow: Overflow,
8581
/// Configures how the image should scale
@@ -121,8 +117,6 @@ pub struct TextBundle {
121117
pub flex_layout: FlexLayout,
122118
/// The direction of the text
123119
pub text_direction: TextDirection,
124-
/// Controls how the content wraps
125-
pub wrap: Wrap,
126120
/// The behavior in case the node overflows its allocated space
127121
pub overflow: Overflow,
128122
/// Contains the text of the node
@@ -187,7 +181,6 @@ impl Default for TextBundle {
187181
size_constraints: Default::default(),
188182
flex_layout: Default::default(),
189183
text_direction: Default::default(),
190-
wrap: Default::default(),
191184
overflow: Default::default(),
192185
transform: Default::default(),
193186
global_transform: Default::default(),
@@ -220,8 +213,6 @@ pub struct ButtonBundle {
220213
pub flex_layout: FlexLayout,
221214
/// The direction of the text
222215
pub text_direction: TextDirection,
223-
/// Controls how the content wraps
224-
pub wrap: Wrap,
225216
/// The behavior in case the node overflows its allocated space
226217
pub overflow: Overflow,
227218
/// Describes whether and how the button has been interacted with by the input

crates/bevy_ui/src/flex/convert.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::layout_components::{
22
flex::{
33
AlignContent, AlignItems, AlignSelf, FlexDirection, FlexLayoutQueryItem, JustifyContent,
4+
Wrap,
45
},
5-
LayoutStrategy, PositionType, Wrap,
6+
LayoutStrategy, PositionType,
67
};
78
use crate::{Size, UiRect, Val};
89

@@ -41,7 +42,7 @@ pub fn from_flex_layout(scale_factor: f64, value: FlexLayoutQueryItem<'_>) -> ta
4142
display: (*value.layout_strategy).into(),
4243
position_type: (*value.position_type).into(),
4344
flex_direction: value.flex_layout.flex_direction.into(),
44-
flex_wrap: (*value.wrap).into(),
45+
flex_wrap: value.flex_layout.wrap.into(),
4546
align_items: value.flex_layout.align_items.into(),
4647
align_self: value.flex_layout.align_self.into(),
4748
align_content: value.flex_layout.align_content.into(),

crates/bevy_ui/src/layout_components.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,12 @@ pub enum Overflow {
204204
Hidden,
205205
}
206206

207-
/// Defines if child UI items appear on a single line or on multiple lines
208-
#[derive(
209-
Component, Copy, Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Reflect,
210-
)]
211-
#[reflect_value(PartialEq, Serialize, Deserialize)]
212-
pub enum Wrap {
213-
/// Single line, will overflow if needed
214-
#[default]
215-
NoWrap,
216-
/// Multiple lines, if needed
217-
Wrap,
218-
/// Same as [`FlexWrap::Wrap`] but new lines will appear before the previous one
219-
WrapReverse,
220-
}
221-
222207
/// Flexbox-specific layout components
223208
pub mod flex {
224-
use super::{
225-
LayoutStrategy, Offset, Overflow, PositionType, SizeConstraints, Spacing, TextDirection,
226-
Wrap,
227-
};
228-
use crate::Val;
229-
use bevy_ecs::prelude::Component;
209+
230210
use bevy_ecs::query::{Changed, Or, WorldQuery};
231-
use bevy_reflect::prelude::*;
232-
use serde::{Deserialize, Serialize};
211+
212+
use super::*;
233213

234214
/// A query for all of the components need for flexbox layout.
235215
///
@@ -250,8 +230,6 @@ pub mod flex {
250230
pub flex_layout: &'static FlexLayout,
251231
/// The direction of the text
252232
pub text_direction: &'static TextDirection,
253-
/// Controls how the content wraps
254-
pub wrap: &'static Wrap,
255233
/// The behavior in case the node overflows its allocated space
256234
pub overflow: &'static Overflow,
257235
}
@@ -286,6 +264,8 @@ pub mod flex {
286264
pub align_content: AlignContent,
287265
/// Aligns this containers items along the main-axis
288266
pub justify_content: JustifyContent,
267+
/// Controls how the content wraps
268+
pub wrap: Wrap,
289269
/// Defines how much a flexbox item should grow if there's space available
290270
pub grow: f32,
291271
/// How to shrink if there's not enough space available
@@ -302,6 +282,7 @@ pub mod flex {
302282
align_self: Default::default(),
303283
align_content: Default::default(),
304284
justify_content: Default::default(),
285+
wrap: Default::default(),
305286
grow: 0.0,
306287
shrink: 1.0,
307288
basis: Val::Auto,
@@ -401,4 +382,17 @@ pub mod flex {
401382
/// Like [`JustifyContent::SpaceAround`] but with even spacing between items
402383
SpaceEvenly,
403384
}
385+
386+
/// Defines if flexbox items appear on a single line or on multiple lines
387+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Reflect)]
388+
#[reflect_value(PartialEq, Serialize, Deserialize)]
389+
pub enum Wrap {
390+
/// Single line, will overflow if needed
391+
#[default]
392+
NoWrap,
393+
/// Multiple lines, if needed
394+
Wrap,
395+
/// Same as [`FlexWrap::Wrap`] but new lines will appear before the previous one
396+
WrapReverse,
397+
}
404398
}

0 commit comments

Comments
 (0)