-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Setting the visibility of UI nodes is confusing and redundant #5368
Comments
Just for some context. In CSS changing the display property removes the node from layouting, while visibility just makes it not visible, but doesn't affect the layout. Not sure if this is similar in bevy. |
Oh... then that's how Bevy currently work... do you know if events are still triggered by a not visible element? |
they don't get interaction events. |
@mockersf what do you think the right path forward is then?
|
In general, you can't trigger interaction on them because you can't see them, but you can still trigger them mechanically (through javascript). Also, because of the inspector, you can just... unhide them. This was actually the source of a few bugs that I've encountered in the wild. |
WRT triggering them mechanically, users will be able to achieve the same effect by manually setting the That inspector stuff seems like a nasty security issue... |
If we merge #5361 we would work completely like CSS... I think that would be what I prefer, but it would need documentation to explain. But it should be feasible. Mentioning on the visibility component that it hides and stop events, but don't remove from layout, and mention the display field. Keeping the two separated (visibility / computed in layout) can be useful to allow for invisible nodes in layout, so that everything stays in the same place when something else becomes visible / invisible. |
#5361 has been merged. What's the status of this? |
To close this, we either need a) consensus that we want both + #5380 fixed |
I would like the (a) scenario, just like in CSS. Also, the visibility vs display has been well documented. Implementing #5380 will also consolidate the pattern. |
I would also like the (a) scenario. In fact, I have deliberately made use of that distinction in my own UIs before. The ability to choose between "don't render, but keep it in the layout" and "remove it from the layout", is a useful feature to have. |
I also like Should #7629 mention that it closes this issue? |
Agreed, I think that #7629 will resolve this. |
# Objective An example demonstrating how Display and Visibility work in Bevy UI. fixes #5380 related #5368 ![Bevy App 15_02_2023 20_40_46](https://user-images.githubusercontent.com/27962798/219150865-419ade53-250b-4030-8197-907cac7aa5da.png) ## Changelog * Added the example `flex_display.rs`.
What problem does this solve or what need does it fill?
The visibility of UI entities can be controlled in two distinct ways: via the
Style
component's field, and by settingVisibility
(you could also muck withComputedVisibility
but please don't).This is both confusing, and results in inconsistent behavior (see #5360 and the resulting #5361).
What solution would you like?
Remove the
Display
field ofStyle
, and let users set this via theVisiblity
component instead. In the interface withtaffy
, construct thetaffy::Style
struct information based on the combination of these components.This is simple, allows for direct querying and is much more consistent with the rest of the engine.
What alternative(s) have you considered?
Display
as the canonical representation. This is confusing, and ties us tightly to CSS's model rather than being modular. It's also very inconsistent with the way visibility is handled elsewhere.Additional context
Prompted by @mockersf complaining about this in #5361 (comment) <3
The text was updated successfully, but these errors were encountered: