From 00e1c9bf4d91121abad491cd5927df98e831043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Wed, 24 Apr 2024 18:33:34 -0400 Subject: [PATCH] fix: fix brush undo being broken after upgrade to egui 0.26 --- crates/ui/src/tabs/map/mod.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/ui/src/tabs/map/mod.rs b/crates/ui/src/tabs/map/mod.rs index 2144c5d7..7d24040a 100644 --- a/crates/ui/src/tabs/map/mod.rs +++ b/crates/ui/src/tabs/map/mod.rs @@ -400,7 +400,9 @@ impl luminol_core::Tab for Tab { } } - if !response.dragged_by(egui::PointerButton::Primary) { + if !response.is_pointer_button_down_on() + || ui.input(|i| !i.pointer.button_down(egui::PointerButton::Primary)) + { if self.drawing_shape { self.drawing_shape = false; } @@ -429,17 +431,6 @@ impl luminol_core::Tab for Tab { if let luminol_components::SelectedLayer::Tiles(tile_layer) = self.view.selected_layer { - // Before drawing tiles, save the state of the current layer so we can undo it - // later if we need to - if response.drag_started_by(egui::PointerButton::Primary) - && !ui.input(|i| i.modifiers.command) - { - self.tilemap_undo_cache_layer = tile_layer; - for i in 0..self.layer_cache.len() { - self.tilemap_undo_cache[i] = self.layer_cache[i]; - } - } - // Tile drawing if response.is_pointer_button_down_on() && ui.input(|i| { @@ -447,6 +438,13 @@ impl luminol_core::Tab for Tab { && !i.modifiers.command }) { + if self.drawing_shape_pos.is_none() { + // Before drawing tiles, save the state of the current layer so we can + // undo it later if we need to + self.tilemap_undo_cache_layer = tile_layer; + self.tilemap_undo_cache.copy_from_slice(&self.layer_cache); + } + self.handle_brush( map_x as usize, map_y as usize,