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

Create a UI example demonstrating the difference between node Visibility::is_visible and Display::None #5380

Closed
Nilirad opened this issue Jul 19, 2022 · 3 comments · Fixed by #7629
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

Comments

@Nilirad
Copy link
Contributor

Nilirad commented Jul 19, 2022

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 the is_visible field of the Visibility component of a node entity to false, 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 the Style component of a node entity. If the variant is set to Display::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:

  1. Element is visible. Visibility::is_visible == true AND Display::Flex,
  2. Element is collapsed. Visibility::is_visible == true AND Display::None,
  3. Element is invisible but occupies space. Visibility::is_visible == false AND Display::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]
@Nilirad Nilirad added D-Trivial Nice and easy! A great choice to get started with Bevy C-Examples An addition or correction to our examples A-UI Graphical user interfaces, styles, layouts, and widgets labels Jul 19, 2022
@Nilirad Nilirad changed the title Create a UI example demonstrating the difference between node !ComputedVisibility::is_visible() and Display::None # Create a UI example demonstrating the difference between node Visibility::is_visible and Display::None Jul 19, 2022
@Nilirad Nilirad changed the title # Create a UI example demonstrating the difference between node Visibility::is_visible and Display::None Create a UI example demonstrating the difference between node Visibility::is_visible and Display::None Jul 19, 2022
@Nilirad
Copy link
Contributor Author

Nilirad commented Jul 21, 2022

#5361 Has been merged, this issue is now implementable.

@arnavc52
Copy link
Contributor

#5368 might make this irrelevant, by the way.

@Nilirad
Copy link
Contributor Author

Nilirad commented Jul 22, 2022

#5368 might make this irrelevant, by the way.

I've asked a status update on that issue, thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants