-
Notifications
You must be signed in to change notification settings - Fork 2k
Add atom_ignore_spacing
#8026
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
Draft
lucasmerlin
wants to merge
1
commit into
main
Choose a base branch
from
lucas/atom-ignore-spacing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add atom_ignore_spacing
#8026
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/egui_tests/tests/snapshots/layout/button_image_shortcut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/egui_tests/tests/snapshots/layout/text_edit_prefix_suffix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/egui_tests/tests/snapshots/visuals/button_image_shortcut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/egui_tests/tests/snapshots/visuals/button_image_shortcut_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
tests/egui_tests/tests/snapshots/visuals/text_edit_prefix_suffix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial reaction is that this is getting a bit complicated.
We now have five things controlling size (
size,max_size,grow,shrink,ignore_spacing). The test space grows with the cartesian product of these.I suspect there is a simpler solution to be found. Let's discuss tomorrow morning.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with the inner workings of atoms so perhaps this doesn't make much sense but what about ignoring spacing for
AtomKind::Emptyatoms by default? My understanding is they are mostly (only?) used as separators so they themselves should be the spacing... This reasoning could be potentially extended to grow atoms for which available size is larger than the content because at that point the external padding would already be acting as spacing .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty atoms can also be used to add custom content. You can assign it an id and then read the rect from the AtomLayoutResponse and use ui.place to add e.g. a button or do custom painting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see,
AtomKind::Customwas removed andEmptyis also used for custom content now... Since Atoms use a flex-like layout perhaps it could be sensible to have a dedicated spacer atom with its own rules that only helps with the layout (like the absence of inter-atom margin in this instance).Alternatively, and specifically addressing @emilk's concern about the complexity of the current system, I think atoms could be reworked to be expressed by the combination of:
content_size: predictably, this is simply the actual size of the content.size: a range that fully encapsulates the dynamic behavior of the atom.margin: this is sort of the lower bound of the inner margin in dynamic scenariosTogether they allow for a quite a bit of functionality without much clutter, including:
atom0.size() + atom1.size() ... + atomN.size().The way this would work is we take the outer size as the absolute space taken up by the atom and then we compute how much space the content will actually use based on this simple formula:
outer_size - (outer_size - content_size).max(margin). For instance, here's a few cases:Basically the way this works is that as the atom grows in outer size, the inner size grows up to the size of the content with a fixed inner margin, but beyond that it's just the margin that grows to pad the content.
During the layouting phase we check what the atom is supposed to do (grow, shrink...) based on its size range, and then we decide what size (within its range) we want to use based on the other atoms, available space and so on, which shouldn't be too big a change compared to the current system.
Obviously this is just an idea and there's surely a number of edge cases (like what if margin is more than the minimum outer size?) or possible refinements (split min and max instead of using a range) but hopefully this can be useful in some form.