From dd58d5175faa9a21eebb45c4a9615c314be51f56 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Fri, 8 Apr 2022 09:06:04 +0200 Subject: [PATCH] Replace `top_most_layer` with more flexible `layer_ids` (#1266) --- CHANGELOG.md | 1 + egui/src/context.rs | 9 ++------- egui/src/memory.rs | 7 +++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a4a83a..e21d30fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w * Renamed `AlphaImage` to `FontImage` to discourage any other use for it ([#1412](https://github.com/emilk/egui/pull/1412)). * Warnings will pe painted on screen when there is an `Id` clash for `Grid`, `Plot` or `ScrollArea` ([#1452](https://github.com/emilk/egui/pull/1452)). * `Checkbox` and `RadioButton` with an empty label (`""`) will now take up much less space ([#1456](https://github.com/emilk/egui/pull/1456)). +* Replaced `Memory::top_most_layer` with more flexible `Memory::layer_ids`. ### Fixed 🐛 * Fixed ComboBoxes always being rendered left-aligned ([#1304](https://github.com/emilk/egui/pull/1304)). diff --git a/egui/src/context.rs b/egui/src/context.rs index e0212496..0c55b713 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -943,13 +943,8 @@ impl Context { self.memory().layer_id_at(pos, resize_grab_radius_side) } - /// The overall top-most layer. When an area is clicked on or interacted - /// with, it is moved above all other areas. - pub fn top_most_layer(&self) -> Option { - self.memory().top_most_layer() - } - - /// Moves the given area to the top. + /// Moves the given area to the top in its [`Order`]. + /// [`Area`]:s and [`Window`]:s also do this automatically when being clicked on or interacted with. pub fn move_to_top(&self, layer_id: LayerId) { self.memory().areas.move_to_top(layer_id); } diff --git a/egui/src/memory.rs b/egui/src/memory.rs index d9913a41..ed91043f 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -329,10 +329,9 @@ impl Memory { self.areas.layer_id_at(pos, resize_interact_radius_side) } - /// The overall top-most layer. When an area is clicked on or interacted - /// with, it is moved above all other areas. - pub fn top_most_layer(&self) -> Option { - self.areas.order().last().copied() + /// An iterator over all layers. Back-to-front. Top is last. + pub fn layer_ids(&self) -> impl ExactSizeIterator + '_ { + self.areas.order().iter().copied() } pub(crate) fn had_focus_last_frame(&self, id: Id) -> bool {