From 0f07622020e58b785cc8e25374d6708e781bfde5 Mon Sep 17 00:00:00 2001 From: Piotr Podusowski Date: Tue, 18 Jul 2023 21:26:47 +0200 Subject: [PATCH 1/2] rename internal function --- src/map.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/map.rs b/src/map.rs index ac155fb2..41bae48e 100644 --- a/src/map.rs +++ b/src/map.rs @@ -57,11 +57,9 @@ impl Widget for Map<'_, '_> { // then it felt right with both mouse wheel, and an Android phone. self.memory.zoom.zoom_by((zoom_delta - 1.) * 2.); } else { - self.memory.center_mode.screen_drag( - &response, - self.my_position, - self.memory.zoom.round(), - ); + self.memory + .center_mode + .drag(&response, self.my_position, self.memory.zoom.round()); } } @@ -102,7 +100,7 @@ pub enum Center { } impl Center { - fn screen_drag(&mut self, response: &Response, my_position: Position, zoom: u8) { + fn drag(&mut self, response: &Response, my_position: Position, zoom: u8) { if response.dragged_by(egui::PointerButton::Primary) { // We always end up in some exact, "detached" position, regardless of the current mode. *self = Center::Exact(screen_to_position( From 6b1ce69954520b0797d82089d84ca6e8b9139f9c Mon Sep 17 00:00:00 2001 From: Piotr Podusowski Date: Tue, 18 Jul 2023 21:29:20 +0200 Subject: [PATCH 2/2] code compacted --- src/map.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/map.rs b/src/map.rs index 41bae48e..169d846d 100644 --- a/src/map.rs +++ b/src/map.rs @@ -146,9 +146,7 @@ fn draw_tiles( let tile_screen_position = painter.clip_rect().center().to_vec2() + tile_projected.to_vec2() - map_center_projected_position.to_vec2(); - let image = if let Some(image) = tiles.at(tile_id) { - image - } else { + let Some(image) = tiles.at(tile_id) else { return; };