1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Allow setting a layer as a sublayer of another (#4690)

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 <https://github.com/emilk/egui/issues/4128>

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
YgorSouza
2024-06-23 12:43:46 +02:00
committed by GitHub
parent 8cef6fc872
commit b1dc059ef3
3 changed files with 56 additions and 5 deletions

View File

@@ -110,11 +110,10 @@ impl crate::View for PanZoom {
.into_iter()
.enumerate()
{
let window_layer = ui.layer_id();
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)
.order(egui::Order::Middle)
.show(ui.ctx(), |ui| {
ui.set_clip_rect(transform.inverse() * rect);
egui::Frame::default()
@@ -130,6 +129,7 @@ impl crate::View for PanZoom {
.response
.layer_id;
ui.ctx().set_transform_layer(id, transform);
ui.ctx().set_sublayer(window_layer, id);
}
}
}