Create a UI example demonstrating the difference between node Visibility::is_visible
and Display::None
#5380
Labels
A-UI
Graphical user interfaces, styles, layouts, and widgets
C-Examples
An addition or correction to our examples
D-Trivial
Nice and easy! A great choice to get started with Bevy
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_visible
field of theVisibility
component 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 theStyle
component 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:
Visibility::is_visible == true
ANDDisplay::Flex
,Visibility::is_visible == true
ANDDisplay::None
,Visibility::is_visible == false
ANDDisplay::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:
The text was updated successfully, but these errors were encountered: