Clip outlines by the node's own clipping rect, not the parent's. (#10922)
# Objective A nodes outline should be clipped using its own clipping rect, not its parents. fixes #10921 ## Solution Clip outlines by the node's own clipping rect, not the parent's. If you compare the `overflow` ui example in main with this PR, you'll see that the outlines that appear when you hover above the images are now clipped along with the images. --- ## Changelog * Outlines are now clipped using the node's own clipping rect, not the parent's.
This commit is contained in:
parent
1523e8c409
commit
4a46f273a1
@ -390,13 +390,12 @@ pub fn extract_uinode_outlines(
|
|||||||
&GlobalTransform,
|
&GlobalTransform,
|
||||||
&Outline,
|
&Outline,
|
||||||
&ViewVisibility,
|
&ViewVisibility,
|
||||||
Option<&Parent>,
|
Option<&CalculatedClip>,
|
||||||
)>,
|
)>,
|
||||||
>,
|
>,
|
||||||
clip_query: Query<&CalculatedClip>,
|
|
||||||
) {
|
) {
|
||||||
let image = AssetId::<Image>::default();
|
let image = AssetId::<Image>::default();
|
||||||
for (node, global_transform, outline, view_visibility, maybe_parent) in uinode_query.iter() {
|
for (node, global_transform, outline, view_visibility, maybe_clip) in uinode_query.iter() {
|
||||||
// Skip invisible outlines
|
// Skip invisible outlines
|
||||||
if !view_visibility.get()
|
if !view_visibility.get()
|
||||||
|| outline.color.is_fully_transparent()
|
|| outline.color.is_fully_transparent()
|
||||||
@ -405,10 +404,6 @@ pub fn extract_uinode_outlines(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outline's are drawn outside of a node's borders, so they are clipped using the clipping Rect of their UI node entity's parent.
|
|
||||||
let clip =
|
|
||||||
maybe_parent.and_then(|parent| clip_query.get(parent.get()).ok().map(|clip| clip.clip));
|
|
||||||
|
|
||||||
// Calculate the outline rects.
|
// Calculate the outline rects.
|
||||||
let inner_rect = Rect::from_center_size(Vec2::ZERO, node.size() + 2. * node.outline_offset);
|
let inner_rect = Rect::from_center_size(Vec2::ZERO, node.size() + 2. * node.outline_offset);
|
||||||
let outer_rect = inner_rect.inset(node.outline_width());
|
let outer_rect = inner_rect.inset(node.outline_width());
|
||||||
@ -460,7 +455,7 @@ pub fn extract_uinode_outlines(
|
|||||||
},
|
},
|
||||||
image,
|
image,
|
||||||
atlas_size: None,
|
atlas_size: None,
|
||||||
clip,
|
clip: maybe_clip.map(|clip| clip.clip),
|
||||||
flip_x: false,
|
flip_x: false,
|
||||||
flip_y: false,
|
flip_y: false,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user