bevy icon indicating copy to clipboard operation
bevy copied to clipboard

max_size not working on NodeBundle

Open tecbeast42 opened this issue 2 years ago • 2 comments
trafficstars

Bevy version

v0.10

What you did

I added 2 NodeBundles. The parent is blue, the child is red. The child should have a max size of 600 px.

use bevy::prelude::*;

fn main() {
    let mut app = App::new();
    app.add_plugins(
        DefaultPlugins
    );
    app.add_startup_system(setup);
    app.run();
}

fn setup(
    mut commands: Commands,
) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(NodeBundle {
        style: Style {
            size: Size::new(Val::Auto, Val::Percent(100.0)),
            ..default()
        },
        background_color: Color::BLUE.into(),
        ..default()
    }).with_children(|damage_report| {
            damage_report.spawn((
                NodeBundle {
                    style: Style {
                        margin: UiRect::all(Val::Px(5.0)),
                        padding: UiRect::all(Val::Px(5.0)),
                        size: Size::new(Val::Px(450.0), Val::Undefined),
                        max_size: Size::new(Val::Undefined, Val::Px(600.0)),
                        flex_direction: FlexDirection::Column,
                        justify_content: JustifyContent::SpaceEvenly,
                        align_items: AlignItems::FlexStart,
                        ..default()
                    },
                    background_color: Color::RED.into(),
                    ..default()
                },
            ));
        });
}

What went wrong

The red child node fills the full parent node, even though the max_size is limited to 600 px.

Additional information

image

image

tecbeast42 avatar Mar 13 '23 10:03 tecbeast42

I forgot, it was working fine with bevy 0.9.

tecbeast42 avatar Mar 13 '23 10:03 tecbeast42

I believe this would be fixed by https://github.com/bevyengine/bevy/pull/7948. Would you mind checking?

rparrett avatar Mar 13 '23 14:03 rparrett

I can confirm that #7948 fixes the example above.

rparrett avatar Mar 13 '23 22:03 rparrett