Skip to content

Commit

Permalink
Merge pull request #19 from podusowski/minor-refactor
Browse files Browse the repository at this point in the history
Minor refactor
  • Loading branch information
podusowski authored Jul 18, 2023
2 parents b2a9b0a + 6b1ce69 commit fe2c530
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -148,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;
};

Expand Down

0 comments on commit fe2c530

Please sign in to comment.