mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
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
2 changed files with 9 additions and 2 deletions
|
@ -525,7 +525,7 @@ pub fn extract_uinode_borders(
|
|||
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).
|
||||
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 {
|
||||
extracted_uinodes.uinodes.insert(
|
||||
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`)
|
||||
if !view_visibility.get() || uinode.size().x == 0. || uinode.size().y == 0. {
|
||||
if !view_visibility.get() || uinode.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,13 @@ impl Node {
|
|||
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.
|
||||
/// 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 {
|
||||
|
|
Loading…
Reference in a new issue