Skip to content

Commit 2c8f065

Browse files
Move aspect ratios with size constraints
1 parent 8824e3a commit 2c8f065

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

crates/bevy_ui/src/flex/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn from_flexbox_layout(
5959
size: from_val_size(scale_factor, value.size_constraints.suggested),
6060
min_size: from_val_size(scale_factor, value.size_constraints.min),
6161
max_size: from_val_size(scale_factor, value.size_constraints.max),
62-
aspect_ratio: match value.flexbox_layout.aspect_ratio {
62+
aspect_ratio: match value.size_constraints.aspect_ratio {
6363
Some(value) => taffy::number::Number::Defined(value),
6464
None => taffy::number::Number::Undefined,
6565
},

crates/bevy_ui/src/layout_components.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![warn(missing_docs)]
2-
31
//! Components used to control the layout of [`UiNode`] entities.
42
use crate::{Size, UiRect, Val};
53
use bevy_derive::{Deref, DerefMut};
@@ -71,6 +69,8 @@ pub struct SizeConstraints {
7169
pub suggested: Size<Val>,
7270
/// The maximum extent, which cannot be violated by the layouting algorithm
7371
pub max: Size<Val>,
72+
/// The expected aspect ratio, computed as width / height
73+
pub aspect_ratio: Option<f32>,
7474
}
7575

7676
/// The space around and inside of a UI node
@@ -205,8 +205,6 @@ pub mod flex {
205205
pub shrink: f32,
206206
/// The initial size of the item
207207
pub basis: Val,
208-
/// The aspect ratio of the flexbox
209-
pub aspect_ratio: Option<f32>,
210208
}
211209

212210
impl Default for FlexboxLayout {
@@ -220,7 +218,6 @@ pub mod flex {
220218
grow: 0.0,
221219
shrink: 1.0,
222220
basis: Val::Auto,
223-
aspect_ratio: Default::default(),
224221
}
225222
}
226223
}

0 commit comments

Comments
 (0)