Skip to content

Commit 87f0f7b

Browse files
Flexbox -> Flex in type names
1 parent 2c8f065 commit 87f0f7b

File tree

7 files changed

+50
-55
lines changed

7 files changed

+50
-55
lines changed

crates/bevy_ui/src/entity.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use crate::{
44
layout_components::{
5-
flex::FlexboxLayout, LayoutStrategy, Offset, Overflow, PositionType, SizeConstraints,
6-
Spacing, TextDirection, Wrap,
5+
flex::FlexLayout, LayoutStrategy, Offset, Overflow, PositionType, SizeConstraints, Spacing,
6+
TextDirection, Wrap,
77
},
88
widget::{Button, ImageMode},
99
CalculatedSize, FocusPolicy, Interaction, Node, UiColor, UiImage,
@@ -36,7 +36,7 @@ pub struct NodeBundle {
3636
/// The margin, padding and border of the UI node
3737
pub spacing: Spacing,
3838
/// The flexbox layout parameters
39-
pub flexbox_layout: FlexboxLayout,
39+
pub flex_layout: FlexLayout,
4040
/// The direction of the text
4141
pub text_direction: TextDirection,
4242
/// Controls how the content wraps
@@ -75,7 +75,7 @@ pub struct ImageBundle {
7575
/// The margin, padding and border of the UI node
7676
pub spacing: Spacing,
7777
/// The flexbox layout parameters
78-
pub flexbox_layout: FlexboxLayout,
78+
pub flex_layout: FlexLayout,
7979
/// The direction of the text
8080
pub text_direction: TextDirection,
8181
/// Controls how the content wraps
@@ -118,7 +118,7 @@ pub struct TextBundle {
118118
/// The margin, padding and border of the UI node
119119
pub spacing: Spacing,
120120
/// The flexbox layout parameters
121-
pub flexbox_layout: FlexboxLayout,
121+
pub flex_layout: FlexLayout,
122122
/// The direction of the text
123123
pub text_direction: TextDirection,
124124
/// Controls how the content wraps
@@ -168,9 +168,9 @@ impl TextBundle {
168168
self
169169
}
170170

171-
/// Returns this [`TextBundle`] with a new [`FlexboxLayout`].
172-
pub const fn with_flex_layout(mut self, layout: FlexboxLayout) -> Self {
173-
self.flexbox_layout = layout;
171+
/// Returns this [`TextBundle`] with a new [`FlexLayout`].
172+
pub const fn with_flex_layout(mut self, layout: FlexLayout) -> Self {
173+
self.flex_layout = layout;
174174
self
175175
}
176176
}
@@ -185,7 +185,7 @@ impl Default for TextBundle {
185185
layout_strategy: Default::default(),
186186
position_type: Default::default(),
187187
size_constraints: Default::default(),
188-
flexbox_layout: Default::default(),
188+
flex_layout: Default::default(),
189189
text_direction: Default::default(),
190190
wrap: Default::default(),
191191
overflow: Default::default(),
@@ -217,7 +217,7 @@ pub struct ButtonBundle {
217217
/// The margin, padding and border of the UI node
218218
pub spacing: Spacing,
219219
/// The flexbox layout parameters
220-
pub flexbox_layout: FlexboxLayout,
220+
pub flex_layout: FlexLayout,
221221
/// The direction of the text
222222
pub text_direction: TextDirection,
223223
/// Controls how the content wraps

crates/bevy_ui/src/flex/convert.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::layout_components::{
22
flex::{
3-
AlignContent, AlignItems, AlignSelf, FlexDirection, FlexboxLayoutQueryItem, JustifyContent,
3+
AlignContent, AlignItems, AlignSelf, FlexDirection, FlexLayoutQueryItem, JustifyContent,
44
},
55
LayoutStrategy, PositionType, Wrap,
66
};
@@ -36,26 +36,23 @@ pub fn from_val_size(
3636
}
3737
}
3838

39-
pub fn from_flexbox_layout(
40-
scale_factor: f64,
41-
value: FlexboxLayoutQueryItem<'_>,
42-
) -> taffy::style::Style {
39+
pub fn from_flex_layout(scale_factor: f64, value: FlexLayoutQueryItem<'_>) -> taffy::style::Style {
4340
taffy::style::Style {
4441
display: (*value.layout_strategy).into(),
4542
position_type: (*value.position_type).into(),
46-
flex_direction: value.flexbox_layout.flex_direction.into(),
43+
flex_direction: value.flex_layout.flex_direction.into(),
4744
flex_wrap: (*value.wrap).into(),
48-
align_items: value.flexbox_layout.align_items.into(),
49-
align_self: value.flexbox_layout.align_self.into(),
50-
align_content: value.flexbox_layout.align_content.into(),
51-
justify_content: value.flexbox_layout.justify_content.into(),
45+
align_items: value.flex_layout.align_items.into(),
46+
align_self: value.flex_layout.align_self.into(),
47+
align_content: value.flex_layout.align_content.into(),
48+
justify_content: value.flex_layout.justify_content.into(),
5249
position: from_rect(scale_factor, value.offset.0),
5350
margin: from_rect(scale_factor, value.spacing.margin),
5451
padding: from_rect(scale_factor, value.spacing.padding),
5552
border: from_rect(scale_factor, value.spacing.border),
56-
flex_grow: value.flexbox_layout.grow,
57-
flex_shrink: value.flexbox_layout.shrink,
58-
flex_basis: from_val(scale_factor, value.flexbox_layout.basis),
53+
flex_grow: value.flex_layout.grow,
54+
flex_shrink: value.flex_layout.shrink,
55+
flex_basis: from_val(scale_factor, value.flex_layout.basis),
5956
size: from_val_size(scale_factor, value.size_constraints.suggested),
6057
min_size: from_val_size(scale_factor, value.size_constraints.min),
6158
max_size: from_val_size(scale_factor, value.size_constraints.max),
@@ -116,7 +113,7 @@ impl From<AlignContent> for taffy::style::AlignContent {
116113
impl From<LayoutStrategy> for taffy::style::Display {
117114
fn from(value: LayoutStrategy) -> Self {
118115
match value {
119-
LayoutStrategy::Flexbox => taffy::style::Display::Flex,
116+
LayoutStrategy::Flex => taffy::style::Display::Flex,
120117
LayoutStrategy::None => taffy::style::Display::None,
121118
}
122119
}

crates/bevy_ui/src/flex/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod convert;
22

33
use crate::{
4-
layout_components::flex::{FlexboxLayoutChanged, FlexboxLayoutQuery, FlexboxLayoutQueryItem},
4+
layout_components::flex::{FlexLayoutChanged, FlexLayoutQuery, FlexLayoutQueryItem},
55
CalculatedSize, Node,
66
};
77
use bevy_ecs::{
@@ -62,12 +62,12 @@ impl FlexSurface {
6262
pub fn upsert_node(
6363
&mut self,
6464
entity: Entity,
65-
layout: FlexboxLayoutQueryItem<'_>,
65+
layout: FlexLayoutQueryItem<'_>,
6666
scale_factor: f64,
6767
) {
6868
let mut added = false;
6969
let taffy = &mut self.taffy;
70-
let taffy_style = convert::from_flexbox_layout(scale_factor, layout);
70+
let taffy_style = convert::from_flex_layout(scale_factor, layout);
7171
let taffy_node = self.entity_to_taffy.entry(entity).or_insert_with(|| {
7272
added = true;
7373
taffy.new_node(taffy_style, &Vec::new()).unwrap()
@@ -81,12 +81,12 @@ impl FlexSurface {
8181
pub fn upsert_leaf(
8282
&mut self,
8383
entity: Entity,
84-
layout: FlexboxLayoutQueryItem<'_>,
84+
layout: FlexLayoutQueryItem<'_>,
8585
calculated_size: CalculatedSize,
8686
scale_factor: f64,
8787
) {
8888
let taffy = &mut self.taffy;
89-
let taffy_style = convert::from_flexbox_layout(scale_factor, layout);
89+
let taffy_style = convert::from_flex_layout(scale_factor, layout);
9090
let measure = taffy::node::MeasureFunc::Boxed(Box::new(
9191
move |constraints: taffy::geometry::Size<Number>| {
9292
let mut size = convert::from_f32_size(scale_factor, calculated_size.size);
@@ -207,12 +207,12 @@ pub fn flex_node_system(
207207
mut flex_surface: ResMut<FlexSurface>,
208208
root_node_query: Query<Entity, (With<Node>, Without<Parent>)>,
209209
node_query: Query<
210-
(Entity, FlexboxLayoutQuery, Option<&CalculatedSize>),
211-
(With<Node>, FlexboxLayoutChanged),
210+
(Entity, FlexLayoutQuery, Option<&CalculatedSize>),
211+
(With<Node>, FlexLayoutChanged),
212212
>,
213-
full_node_query: Query<(Entity, FlexboxLayoutQuery, Option<&CalculatedSize>), With<Node>>,
213+
full_node_query: Query<(Entity, FlexLayoutQuery, Option<&CalculatedSize>), With<Node>>,
214214
changed_size_query: Query<
215-
(Entity, FlexboxLayoutQuery, &CalculatedSize),
215+
(Entity, FlexLayoutQuery, &CalculatedSize),
216216
(With<Node>, Changed<CalculatedSize>),
217217
>,
218218
children_query: Query<(Entity, &Children), (With<Node>, Changed<Children>)>,
@@ -239,7 +239,7 @@ pub fn flex_node_system(
239239
fn update_changed<F: WorldQuery>(
240240
flex_surface: &mut FlexSurface,
241241
scaling_factor: f64,
242-
query: Query<(Entity, FlexboxLayoutQuery, Option<&CalculatedSize>), F>,
242+
query: Query<(Entity, FlexLayoutQuery, Option<&CalculatedSize>), F>,
243243
) {
244244
// update changed nodes
245245
for (entity, layout, calculated_size) in &query {

crates/bevy_ui/src/layout_components.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum LayoutStrategy {
1717
///
1818
/// As implemented by [`taffy`]: some bugs or limitations may exist; please file an issue!\
1919
#[default]
20-
Flexbox,
20+
Flex,
2121
}
2222

2323
/// The strategy used to position this node
@@ -142,11 +142,11 @@ pub mod flex {
142142
use bevy_reflect::prelude::*;
143143
use serde::{Deserialize, Serialize};
144144

145-
/// A query for all of the components in a [`FlexboxLayoutBundle`].
145+
/// A query for all of the components need for flexbox layout.
146146
///
147147
/// See [`FlexboxLayoutChanged`] when attempting to use this as a query filter.
148148
#[derive(WorldQuery)]
149-
pub struct FlexboxLayoutQuery {
149+
pub struct FlexLayoutQuery {
150150
/// The layout algorithm used
151151
pub layout_strategy: &'static LayoutStrategy,
152152
/// The position of this UI node
@@ -158,7 +158,7 @@ pub mod flex {
158158
/// The margin, padding and border of the UI node
159159
pub spacing: &'static Spacing,
160160
/// The flexbox layout parameters
161-
pub flexbox_layout: &'static FlexboxLayout,
161+
pub flex_layout: &'static FlexLayout,
162162
/// The direction of the text
163163
pub text_direction: &'static TextDirection,
164164
/// Controls how the content wraps
@@ -167,15 +167,13 @@ pub mod flex {
167167
pub overflow: &'static Overflow,
168168
}
169169

170-
/// A type alias for when any of the components in the [`FlexboxLayoutBundle`] has been changed
171-
///
172-
/// See [`FlexboxLayoutQuery`] for the data-fetching equivalent.
173-
pub type FlexboxLayoutChanged = Or<(
170+
/// A type alias for when any of the components in a [`FlexLayoutQuery`] have changed.
171+
pub type FlexLayoutChanged = Or<(
174172
Changed<LayoutStrategy>,
175173
Changed<PositionType>,
176174
Changed<SizeConstraints>,
177175
Changed<Spacing>,
178-
Changed<FlexboxLayout>,
176+
Changed<FlexLayout>,
179177
Changed<TextDirection>,
180178
Changed<Overflow>,
181179
)>;
@@ -186,7 +184,7 @@ pub mod flex {
186184
/// you can use [guides](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) for additional documentation.
187185
#[derive(Component, Serialize, Deserialize, Reflect, Debug, PartialEq, Clone, Copy)]
188186
#[reflect_value(PartialEq, Serialize, Deserialize)]
189-
pub struct FlexboxLayout {
187+
pub struct FlexLayout {
190188
/// How items are ordered inside a flexbox
191189
///
192190
/// Sets the main and cross-axis: if this is a "row" variant, the main axis will be rows.
@@ -207,9 +205,9 @@ pub mod flex {
207205
pub basis: Val,
208206
}
209207

210-
impl Default for FlexboxLayout {
211-
fn default() -> FlexboxLayout {
212-
FlexboxLayout {
208+
impl Default for FlexLayout {
209+
fn default() -> FlexLayout {
210+
FlexLayout {
213211
flex_direction: Default::default(),
214212
align_items: Default::default(),
215213
align_self: Default::default(),

crates/bevy_ui/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Plugin for UiPlugin {
7676
.register_type::<Size<f32>>()
7777
.register_type::<Size<Val>>()
7878
.register_type::<UiRect<Val>>()
79-
.register_type::<FlexboxLayout>()
79+
.register_type::<FlexLayout>()
8080
.register_type::<UiColor>()
8181
.register_type::<UiImage>()
8282
.register_type::<Val>()

crates/bevy_ui/src/update.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This module contains systems that update the UI when something changes
22
3-
use crate::{layout_components::Overflow, prelude::flex::FlexboxLayoutQuery, CalculatedClip};
3+
use crate::{layout_components::Overflow, prelude::flex::FlexLayoutQuery, CalculatedClip};
44

55
use super::Node;
66
use bevy_ecs::{
@@ -71,7 +71,7 @@ pub fn update_clipping_system(
7171
mut node_query: Query<(
7272
&Node,
7373
&GlobalTransform,
74-
FlexboxLayoutQuery,
74+
FlexLayoutQuery,
7575
Option<&mut CalculatedClip>,
7676
)>,
7777
children_query: Query<&Children>,
@@ -93,7 +93,7 @@ fn update_clipping(
9393
node_query: &mut Query<(
9494
&Node,
9595
&GlobalTransform,
96-
FlexboxLayoutQuery,
96+
FlexLayoutQuery,
9797
Option<&mut CalculatedClip>,
9898
)>,
9999
entity: Entity,

crates/bevy_ui/src/widget/text.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
layout_components::flex::{FlexboxLayout, FlexboxLayoutChanged, FlexboxLayoutQuery},
2+
layout_components::flex::{FlexLayout, FlexLayoutChanged, FlexLayoutQuery},
33
CalculatedSize, Size, Val,
44
};
55
use bevy_asset::Assets;
@@ -50,9 +50,9 @@ pub fn text_system(
5050
mut font_atlas_set_storage: ResMut<Assets<FontAtlasSet>>,
5151
mut text_pipeline: ResMut<DefaultTextPipeline>,
5252
mut text_queries: ParamSet<(
53-
Query<Entity, Or<(Changed<Text>, FlexboxLayoutChanged)>>,
54-
Query<Entity, (With<Text>, With<FlexboxLayout>)>,
55-
Query<(&Text, FlexboxLayoutQuery, &mut CalculatedSize)>,
53+
Query<Entity, Or<(Changed<Text>, FlexLayoutChanged)>>,
54+
Query<Entity, (With<Text>, With<FlexLayout>)>,
55+
Query<(&Text, FlexLayoutQuery, &mut CalculatedSize)>,
5656
)>,
5757
) {
5858
let scale_factor = windows.scale_factor(WindowId::primary());

0 commit comments

Comments
 (0)