diff --git a/crates/bevy_ui/src/layout/convert.rs b/crates/bevy_ui/src/layout/convert.rs index 42aaa77f73..079e73bb49 100644 --- a/crates/bevy_ui/src/layout/convert.rs +++ b/crates/bevy_ui/src/layout/convert.rs @@ -20,12 +20,12 @@ impl Val { Val::Px(value) => { taffy::style::LengthPercentageAuto::Length(context.scale_factor * value) } - Val::VMin(value) => { - taffy::style::LengthPercentageAuto::Length(context.min_size * value / 100.) - } - Val::VMax(value) => { - taffy::style::LengthPercentageAuto::Length(context.max_size * value / 100.) - } + Val::VMin(value) => taffy::style::LengthPercentageAuto::Length( + context.physical_size.min_element() * value / 100., + ), + Val::VMax(value) => taffy::style::LengthPercentageAuto::Length( + context.physical_size.max_element() * value / 100., + ), Val::Vw(value) => { taffy::style::LengthPercentageAuto::Length(context.physical_size.x * value / 100.) } diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index ca077a9e56..99d1f37693 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -33,24 +33,18 @@ pub(crate) mod ui_surface; pub struct LayoutContext { pub scale_factor: f32, pub physical_size: Vec2, - pub min_size: f32, - pub max_size: f32, } impl LayoutContext { pub const DEFAULT: Self = Self { scale_factor: 1.0, physical_size: Vec2::ZERO, - min_size: 0.0, - max_size: 0.0, }; /// create new a [`LayoutContext`] from the window's physical size and scale factor fn new(scale_factor: f32, physical_size: Vec2) -> Self { Self { scale_factor, physical_size, - min_size: physical_size.x.min(physical_size.y), - max_size: physical_size.x.max(physical_size.y), } } } @@ -60,8 +54,6 @@ impl LayoutContext { pub const TEST_CONTEXT: Self = Self { scale_factor: 1.0, physical_size: Vec2::new(1000.0, 1000.0), - min_size: 0.0, - max_size: 1000.0, }; }