-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Create a UI example demonstrating the difference between node Visibility::is_visible and Display::None #5380
Description
Context
In Bevy UI, hierarchies of nodes can be hidden by tweaking two different properties, with slightly different effects, exactly like in CSS:
Visibility. Setting theis_visiblefield of theVisibilitycomponent of a node entity tofalse, will make the node and its descendants invisible. The layout engine will still include those UI elements to determine their and other elements' position.Display. It is an enum that is part of theStylecomponent of a node entity. If the variant is set toDisplay::None, the element and its descendants will not be included in the UI layout, therefore they won't occupy any space.
Assignment
You should create a new interactive example where the user can manually edit both properties at runtime for a single node (called target below).
Other, always visible nodes should surround the target (ideally at least one before and one after) to enhance and demonstrate the difference between the two different properties.
To prevent non meaningful states that can confuse the user, only three states should be valid:
- Element is visible.
Visibility::is_visible == trueANDDisplay::Flex, - Element is collapsed.
Visibility::is_visible == trueANDDisplay::None, - Element is invisible but occupies space.
Visibility::is_visible == falseANDDisplay::Flex.
The user experience for toggling between these states should be straightforward and chosen with care.
Optional: If you are able to demonstrate that an invisible element won't respond to any interaction, you'll get a cookie! 🍪 Be wary that this is not the focus of the example, so don't make its code stand out too much!
Example
I propose a mockup that you can copy if you struggle with finding a good UI design:
[button (set visible)] [button (set invisible)] [button (set collapsed)]
[target] <-- maybe a button that can give some interaction feedback! 🍪
[some text]