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

Handle window paint order (click to bring to front etc)

This commit is contained in:
Emil Ernerfeldt
2020-04-17 23:22:28 +02:00
parent f709423809
commit 481af55ce5
6 changed files with 31 additions and 10 deletions

View File

@@ -13,7 +13,7 @@ pub struct Memory {
windows: HashMap<Id, WindowState>,
/// Top is last
window_order: Vec<Id>,
pub window_order: Vec<Id>,
}
impl Memory {
@@ -44,7 +44,13 @@ impl Memory {
Layer::Background
}
pub fn move_window_to_top(&mut self, _id: Id) {
// TODO
pub fn move_window_to_top(&mut self, id: Id) {
if self.window_order.last() == Some(&id) {
return; // common case early-out
}
if let Some(index) = self.window_order.iter().position(|x| *x == id) {
self.window_order.remove(index);
}
self.window_order.push(id);
}
}