Skip to content

UI vertical layout inaccurate for TextNode #7488

Closed
DioxusLabs/taffy
#348
@dvogel

Description

@dvogel

Bevy version

Bevy v0.9.1
Rustc 1.66.1
Linux, debian/bookworm

AdapterInfo { name: "AMD Radeon RX 560 Series (RADV POLARIS11)", vendor: 4098, device: 26623, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 22.3.3", backend: Vulkan }

What you did

The following code (also available with assets in this repro) is meant to render a text box from the top of the screen to the bottom of the screen. However it renders part of the text box underneath the window titlebar and leaves a gap between the bottom of the text box and the window border (screenshots below).

use bevy::{
    prelude::*,
    ui::{BackgroundColor, Val},
};

pub fn inject_ui_entities(asset_server: Res<AssetServer>, mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn((
        TextBundle {
            text: Text::from_section(
                "Hello world!",
                TextStyle {
                    font: asset_server.load("fonts/FiraSans-Regular.ttf"),
                    font_size: 30.0,
                    color: Color::WHITE,
                },
            ),
            style: Style {
                position: UiRect {
                    left: Val::Auto,
                    right: Val::Auto,
                    top: Val::Px(0.0),
                    bottom: Val::Percent(1.0),
                },
                ..default()
            },
            transform: Transform::from_xyz(0.0, 0.0, 0.0),
            ..default()
        },
        BackgroundColor(Color::rgba(164.0 / 256.0, 116.0 / 256.0, 73.0 / 256.0, 0.5)),
    ));
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            window: WindowDescriptor {
                title: String::from("UI Gap Repro"),
                width: 1200.0,
                height: 600.0,
                ..Default::default()
            },
            exit_on_all_closed: true,
            ..default()
        }))
        .add_system(bevy::window::close_on_esc)
        .add_startup_system(inject_ui_entities)
        .run();
}

What went wrong

With two different window dimensions, you can see that the error is proportional to the height of the window:

Screenshot from 2023-02-03 08-27-14

Screenshot from 2023-02-03 08-26-58

Additional information

Other information that can be used to further reproduce or isolate the problem.
This commonly includes:

  • I tried to reproduce this with just a NodeBundle but it didn't render at all (likely an error or misunderstanding on my part).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsA-WindowingPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions