Node::is_empty
(#15050)
# Objective Add a `Node::is_empty` method to replace the `uinode.size().x() <= 0. || uinode.size.y() <= 0.` checks.
This commit is contained in:
parent
5589f0da40
commit
cb221d8852
@ -525,7 +525,7 @@ pub fn extract_uinode_borders(
|
|||||||
let border_radius = clamp_radius(border_radius, uinode.size(), border.into());
|
let border_radius = clamp_radius(border_radius, uinode.size(), border.into());
|
||||||
|
|
||||||
// don't extract border if no border or the node is zero-sized (a zero sized node can still have an outline).
|
// don't extract border if no border or the node is zero-sized (a zero sized node can still have an outline).
|
||||||
if uinode.size().x > 0. && uinode.size().y > 0. && border != [0.; 4] {
|
if !uinode.is_empty() && border != [0.; 4] {
|
||||||
if let Some(border_color) = maybe_border_color {
|
if let Some(border_color) = maybe_border_color {
|
||||||
extracted_uinodes.uinodes.insert(
|
extracted_uinodes.uinodes.insert(
|
||||||
commands.spawn_empty().id(),
|
commands.spawn_empty().id(),
|
||||||
@ -698,7 +698,7 @@ pub fn extract_uinode_text(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Skip if not visible or if size is set to zero (e.g. when a parent is set to `Display::None`)
|
// Skip if not visible or if size is set to zero (e.g. when a parent is set to `Display::None`)
|
||||||
if !view_visibility.get() || uinode.size().x == 0. || uinode.size().y == 0. {
|
if !view_visibility.get() || uinode.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,13 @@ impl Node {
|
|||||||
self.calculated_size
|
self.calculated_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if the node is empty.
|
||||||
|
/// A node is considered empty if it has a zero or negative extent along either of its axes.
|
||||||
|
#[inline]
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.size().cmple(Vec2::ZERO).any()
|
||||||
|
}
|
||||||
|
|
||||||
/// The order of the node in the UI layout.
|
/// The order of the node in the UI layout.
|
||||||
/// Nodes with a higher stack index are drawn on top of and receive interactions before nodes with lower stack indices.
|
/// Nodes with a higher stack index are drawn on top of and receive interactions before nodes with lower stack indices.
|
||||||
pub const fn stack_index(&self) -> u32 {
|
pub const fn stack_index(&self) -> u32 {
|
||||||
|
Loading…
Reference in New Issue
Block a user