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

Pan Zoom demo widgets are layered incorrectly #4128

Closed
YgorSouza opened this issue Mar 3, 2024 · 4 comments · Fixed by #4690
Closed

Pan Zoom demo widgets are layered incorrectly #4128

YgorSouza opened this issue Mar 3, 2024 · 4 comments · Fixed by #4690
Labels
bug Something is broken

Comments

@YgorSouza
Copy link
Contributor

Describe the bug

image

Desktop (please complete the following information):

  • OS: Windows 11, Fedora 39
  • Browser: Firefox
@YgorSouza YgorSouza added the bug Something is broken label Mar 3, 2024
@ToppDev
Copy link

ToppDev commented Mar 16, 2024

maybe related. The pan zoom items can be interacted with, even outside of their window. (tested on https://egui.rs)

PanZoom.mp4

@markusdd
Copy link

markusdd commented May 3, 2024

closing #4448 in favor of this, thank @YgorSouza

@Creative0708
Copy link
Contributor

This bug seems to be a side effect of a workaround to get the pan zoom widgets to display above the window itself.

let id = egui::Area::new(id.with(("subarea", i)))
.default_pos(pos)
// Need to cover up the pan_zoom demo window,
// but may also cover over other windows.
.order(egui::Order::Foreground)
.show(ui.ctx(), |ui| {
ui.set_clip_rect(transform.inverse() * rect);
egui::Frame::default()
.rounding(egui::Rounding::same(4.0))
.inner_margin(egui::Margin::same(8.0))
.stroke(ui.ctx().style().visuals.window_stroke)
.fill(ui.style().visuals.panel_fill)
.show(ui, |ui| {
ui.style_mut().wrap_mode = Some(TextWrapMode::Extend);
callback(ui, self)
});
})
.response
.layer_id;
ui.ctx().set_transform_layer(id, transform);

The areas that hold the widgets are given a layer order of Order::Foreground, which displays above everything that is Order::Middle, Order::Background, etc. The demo windows are Order::Middle, so they render behind the widgets. The comments in the code snippet mention this.

If the widgets were given Order::Middle instead, moving the pan zoom window to the front (such as by clicking) would bring the widgets behind the pan zoom window:

2024-06-21.15-48-58.mp4

I'm not sure how this would be fixed without support for, say, parent/child layers. Possible feature request maybe?

@YgorSouza
Copy link
Contributor Author

Actually, I just noticed this was already discussed in the PR that implemented the demo: #3906 (comment).

emilk added a commit that referenced this issue Jun 23, 2024
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.

* Closes <#4128>

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
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.

* Closes <emilk#4128>

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants