bevy icon indicating copy to clipboard operation
bevy copied to clipboard

UI Display and Visibility Example

Open ickshonpe opened this issue 2 years ago • 9 comments

Objective

An example demonstrating how Display and Visibility work in Bevy UI.

fixes #5380 related #5368

Bevy App 15_02_2023 20_40_46

Changelog

  • Added the example flex_display.rs.

ickshonpe avatar Feb 11 '23 20:02 ickshonpe

You added a new example but didn't add metadata for it. Please update the root Cargo.toml file.

github-actions[bot] avatar Feb 14 '23 12:02 github-actions[bot]

With all of the nodes arranged in a hierarchy as they are, aren't Display::None and Visibility::Hidden behaving pretty identically here?

Would it be more interesting to show the clickable nodes in a single parent flex container?

rparrett avatar Feb 15 '23 14:02 rparrett

With all of the nodes arranged in a hierarchy as they are, aren't Display::None and Visibility::Hidden behaving pretty identically here?

Would it be more interesting to show the clickable nodes in a single parent flex container?

I'm not quite sure what you mean, the behaviour is quite different isn't it? Display::None hides the node and all its descendants, while Visibility::Hidden hides itself and only its children that are Visibility::Inherited.

ickshonpe avatar Feb 15 '23 17:02 ickshonpe

I'm not quite sure what you mean, the behaviour is quite different isn't it? Display::None hides the node and all its descendants, while Visibility::Hidden hides itself and only its children that are Visibility::Inherited.

That's fair.

When I think of the difference between Display::None and Visibility::Hidden though, the first thing that comes to mind is that Visibility::Hidden doesn't affect layout, but Display::None does.

Although I'm not sure how to demonstrate both properties simultaneously.

"2" is Visibility::Hidden
+-----------+          
|+-+     +-+|          
||1|     |3||          
|+-+     +-+|          
+-----------+
          
"2" is Display::None
+-----------+          
|+-+ +-+    |          
||1| |3|    |          
|+-+ +-+    |          
+-----------+  

rparrett avatar Feb 15 '23 17:02 rparrett

Oh I get it, you are right. It needs to demonstrate how Display::None collapses the layout too, yes.

ickshonpe avatar Feb 15 '23 18:02 ickshonpe

display_collapse

Should be able to do something like that with the inner nodes too somehow.

ickshonpe avatar Feb 15 '23 18:02 ickshonpe

Oh I know I can stuff each node with a second invisible panel.

display_collapse_2 collapse_last

That's much better.

ickshonpe avatar Feb 15 '23 18:02 ickshonpe

It seems like a bit of a problem that the buttons move out from under the cursor while you're cycling through Display options. Maybe move the controls to the left, or otherwise add a fixed size container node on the left side?

But I wonder if three panels

  • controls
  • nested hierarchy display
  • flat hierarchy display (vertical)

Would more clearly show what's going on (and would also solve that problem)

rparrett avatar Feb 15 '23 20:02 rparrett

Yes fixed it just now so the panels no longer move.

ickshonpe avatar Feb 15 '23 20:02 ickshonpe

@ickshonpe can you fix the conflicts and make a call on the nits? I think they're an improvement, but I won't block on them.

alice-i-cecile avatar Jun 19 '23 16:06 alice-i-cecile

@ickshonpe can you fix the conflicts and make a call on the nits? I think they're an improvement, but I won't block on them.

Yep I'll take a look

ickshonpe avatar Jun 19 '23 20:06 ickshonpe

You added a new example but didn't update the readme. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Jun 19 '23 20:06 github-actions[bot]

You added a new example but didn't update the readme. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Jun 19 '23 20:06 github-actions[bot]

You added a new example but didn't update the readme. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Jun 19 '23 21:06 github-actions[bot]

You added a new example but didn't update the readme. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Jun 19 '23 21:06 github-actions[bot]

You added a new example but didn't update the readme. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

github-actions[bot] avatar Jun 19 '23 21:06 github-actions[bot]

Everything resolved, should be ready as long as its passes CI checks.

ickshonpe avatar Jun 19 '23 23:06 ickshonpe