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

Outlines are drawn for nodes with Display::None set and their children #10940

Closed
ickshonpe opened this issue Dec 11, 2023 · 0 comments · Fixed by #10942
Closed

Outlines are drawn for nodes with Display::None set and their children #10940

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

Comments

@ickshonpe
Copy link
Contributor

ickshonpe commented Dec 11, 2023

Bevy version

main 4b1865f

What you did

use bevy::prelude::*;

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

pub fn setup(mut commands: Commands) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(NodeBundle {
        style: Style {
            display: Display::None,
            width: Val::Percent(100.),
            height: Val::Percent(100.),
            align_items: AlignItems::Center,
            justify_content: JustifyContent::Center,
            ..Default::default()
        },
        ..default()
    }).with_children(|builder| {
        builder.spawn((
            NodeBundle {
                style: Style {
                    width: Val::Px(100.),
                    height: Val::Px(100.),
                    border: UiRect::all(Val::Px(25.)),
                    ..Default::default()
                },
                background_color: Color::BLUE.into(),
                border_color: Color::RED.into(),
                ..Default::default()
            },
            Outline {
                width: Val::Px(25.),    
                color: Color::WHITE.into(),
                ..Default::default()
            }
        ));
    });
}

What went wrong

With Display::None set nothing should be rendered but a white square is drawn in the top left corner. The square is the outline of the child element which is a zero sized node at the origin.

@ickshonpe ickshonpe added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels Dec 11, 2023
github-merge-queue bot pushed a commit that referenced this issue Dec 23, 2023
# Objective
Outlines are drawn for UI nodes with `Display::None` set and their
descendants. They should not be visible.

## Solution

Make all Nodes with `Display::None` inherit an empty clipping rect,
ensuring that the outlines are not visible.

Fixes #10940

---

## Changelog
* In `update_clipping_system` if a node has `Display::None` set, clip
the entire node and all its descendants by replacing the inherited clip
with a default rect (which is empty)
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.

1 participant