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

Simplify the display_and_visibility example #9738

Conversation

cBournhonesque
Copy link
Contributor

@cBournhonesque cBournhonesque commented Sep 9, 2023

Objective

Address #9735 by removing the level of nesting and simplifying the example.
Also added some comments

fixes #9735

Solution

Use commands.entity(entity).add_child() instead of with_children in order to remove the level of nesting and to be able to work with loops.

TODO

I have two remaining problems with this PR that I wasn't able to fix (and i need help on them):

  • the alignment of the squares on the left is wrong for some reason, I don't really get why
  • the alignment of the last "visibility" button is wrong on the right unless I add an invisible NodeBundle (which was present in the original example)

@rparrett
Copy link
Contributor

One thing I noticed while playing around this earlier was that the "panel container" nodes are seemingly redundant and could be replaced with a 10px white border on the "frame nodes"

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change labels Sep 10, 2023
@ickshonpe
Copy link
Contributor

The invisible node is because I used JustifyContent::SpaceBetween to evenly distribute vertical space around the Visibility button. It could be done in other ways, maybe by nesting the two buttons together in another node.

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-Code-Quality A section of code that is hard to understand or change C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor the display_and_visibility UI example
5 participants