Skip to content

Commit

Permalink
In update_clipping_system if a node with Display::None is found, …
Browse files Browse the repository at this point in the history
…clip that entire node and all its descendants by replacing the inherited clipping rect with the default rect (which is empty).
  • Loading branch information
ickshonpe committed Dec 11, 2023
1 parent 4b1865f commit 51d7bf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module contains systems that update the UI when something changes
use crate::{CalculatedClip, OverflowAxis, Style};
use crate::{CalculatedClip, OverflowAxis, Style, Display};

use super::Node;
use bevy_ecs::{
Expand Down Expand Up @@ -35,13 +35,18 @@ fn update_clipping(
children_query: &Query<&Children>,
node_query: &mut Query<(&Node, &GlobalTransform, &Style, Option<&mut CalculatedClip>)>,
entity: Entity,
maybe_inherited_clip: Option<Rect>,
mut maybe_inherited_clip: Option<Rect>,
) {
let Ok((node, global_transform, style, maybe_calculated_clip)) = node_query.get_mut(entity)
else {
return;
};

// If `display` is None, clip the entire node and all its descendants by replacing the inherited clip with a default rect (which is empty)
if style.display == Display::None {
maybe_inherited_clip = Some(Rect::default());
}

// Update this node's CalculatedClip component
if let Some(mut calculated_clip) = maybe_calculated_clip {
if let Some(inherited_clip) = maybe_inherited_clip {
Expand Down

0 comments on commit 51d7bf1

Please sign in to comment.