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

[Merged by Bors] - Disable UI node Interaction when ComputedVisibility is false #5361

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/bevy_ui/src/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ use smallvec::SmallVec;
/// when [`ComputedVisibility::is_visible()`] is false.
/// This ensures that hidden UI nodes are not interactable,
/// and do not end up stuck in an active state if hidden at the wrong time.
///
/// Note that you can also control the visibility of a node using the [`Display`](crate::ui_node::Display) property,
/// which fully collapses the layout.
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved
#[derive(
Component, Copy, Clone, Default, Eq, PartialEq, Debug, Reflect, Serialize, Deserialize,
)]
Expand Down
11 changes: 9 additions & 2 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ impl AddAssign<f32> for Val {
#[reflect(Component, Default, PartialEq)]
pub struct Style {
/// Whether to arrange this node and its children with flexbox layout
///
/// If this is set to [`Display::None`], this node will be collapsed.
pub display: Display,
/// Whether to arrange this node relative to other nodes, or positioned absolutely
pub position_type: PositionType,
Expand Down Expand Up @@ -212,14 +214,19 @@ pub enum Direction {
RightToLeft,
}

/// Whether to use Flexbox layout
/// Whether to use a flexbox layout strategy
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved
///
/// Part of the [`Style`] component.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Reflect)]
#[reflect_value(PartialEq, Serialize, Deserialize)]
pub enum Display {
/// Use flexbox
/// Use flexbox layout to determine the position of this [`Node`]
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved
#[default]
Flex,
/// Use no layout, don't render this node and its children
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved
///
/// If you want to hide a node and its children,
/// but keep its layout in place, set its [`Visibility`](bevy_render::view::Visibility) component instead.
None,
}

Expand Down