Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disappearing space in the layout with intrinsically sized UI nodes #8516

Closed
ickshonpe opened this issue Apr 30, 2023 · 0 comments · Fixed by #8402
Closed

Disappearing space in the layout with intrinsically sized UI nodes #8516

ickshonpe opened this issue Apr 30, 2023 · 0 comments · Fixed by #8402
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior

Comments

@ickshonpe
Copy link
Contributor

Bevy version

Main ee697f8

What you did

use bevy::prelude::*;
use bevy::ui::AvailableSpace;
use bevy::ui::CalculatedSize;
use bevy::ui::Measure;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

#[derive(Clone)]
pub struct TestMeasure;

impl Measure for TestMeasure {
    fn measure(
        &self,
        _: Option<f32>,
        _: Option<f32>,
        _: AvailableSpace,
        _: AvailableSpace,
    ) -> Vec2 {
        Vec2::new(500., 0.)
    }

    fn dyn_clone(&self) -> Box<dyn Measure> {
        Box::new(self.clone())
    }
}


fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
        commands.spawn((NodeBundle {
            style: Style {
                max_size: Size::width(Val::Px(0.)),
                ..Default::default()
            },
            background_color: Color::GREEN.into(),
            ..default()
        },
        CalculatedSize { measure: Box::new(TestMeasure) }
    ));
    commands.spawn(NodeBundle {
        style: Style {
            size: Size::width(Val::Percent(100.)),
            ..Default::default()
        },
        background_color: Color::RED.into(),
        ..Default::default()
    });
}

What went wrong

Capture-size

The green NodeBundle with the calculated size has a max-width constraint of 0., so it takes up no space in the layout as expected. But the red NodeBundle doesn't grow to fill 100% of the width of the window and leaves an empty space.

Additional Information

Looked obviously like it must be a bug in Taffy, but couldn't reproduce it. Instead, it was definitely introduced by #7779 but I'm not sure how as #7779 doesn't modify any of the layout calculations except for changing how scale factor is applied, but this doesn't seem like a scale factor related bug.

@ickshonpe ickshonpe added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 30, 2023
@ickshonpe ickshonpe changed the title Intrinsically sized UI nodes Disappearing space in the layout with intrinsically sized UI nodes Apr 30, 2023
@nicopap nicopap added A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants