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

Allow setting a layer as a sublayer of another #4690

Merged
merged 4 commits into from
Jun 23, 2024
Merged

Conversation

YgorSouza
Copy link
Contributor

When the layers are reordered at the end of the frame, the sublayers are
placed directly above their respective parents. This allows having Areas
inside Windows, e.g., for the pan-zoom container.

When the layers are reordered at the end of the frame, the sublayers are
placed directly above their respective parents. This allows having Areas
inside Windows, e.g., for the pan-zoom container.
This prevents the inner areas from being layered on top of other Windows
that are above the Pan Zoom demo window.
@YgorSouza
Copy link
Contributor Author

I don't know if this is the best API, but it is relatively simple and seems to solve the problem of the pan zoom demo being layered above everything.

Screencast.from.2024-06-23.09-41-36.mp4

It does not solve the other problem mentioned in #4128 (comment).

///
/// This currently only supports one level of nesting. If `parent` is a sublayer of another
/// layer, the behavior is unspecified.
pub fn set_sublayer(&self, parent: LayerId, child: LayerId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be called something like set_parent_window to be clearer? Technically the parent doesn't have to be a Window, but that is the intended use case, and a more complicated hierarchy would not work well with the current reordering algorithm. I'm not really sure what to call it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the current name, but we should document that this is a sticky setting, and therefor there should also be some way to clear it. Or we make it an immediate-mode function instead and clear it at the end of each frame

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually meant for it to be immediate, like the wants_to_be_on_top set. I'm going to fix that.

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this direction!

YgorSouza and others added 2 commits June 23, 2024 11:53
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
@emilk emilk added the egui label Jun 23, 2024
@emilk
Copy link
Owner

emilk commented Jun 23, 2024

Thanks!

@emilk emilk added the bug Something is broken label Jun 23, 2024
@emilk emilk changed the title Allow setting an Area as a sublayer of another Area Allow setting a layer as a sublayer of another Jun 23, 2024
@emilk emilk merged commit b1dc059 into emilk:master Jun 23, 2024
20 of 21 checks passed
@emilk emilk removed the bug Something is broken label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pan Zoom demo widgets are layered incorrectly
2 participants