Bläddra i källkod

Toggle marker visibility with Ctrl+M

Johannes Hofmann 7 år sedan
förälder
incheckning
67b549d0c2
2 ändrade filer med 16 tillägg och 2 borttagningar
  1. 8
    0
      src/main.rs
  2. 8
    2
      src/map_view_gl.rs

+ 8
- 0
src/main.rs Visa fil

@@ -222,6 +222,14 @@ fn handle_event(
222 222
                             Action::Nothing
223 223
                         }
224 224
                     },
225
+                    VirtualKeyCode::M => {
226
+                        if modifiers.ctrl {
227
+                            map.toggle_marker();
228
+                            Action::Redraw
229
+                        } else {
230
+                            Action::Nothing
231
+                        }
232
+                    },
225 233
                     VirtualKeyCode::H => {
226 234
                         if modifiers.ctrl {
227 235
                             map.toggle_atmosphere();

+ 8
- 2
src/map_view_gl.rs Visa fil

@@ -28,6 +28,7 @@ pub struct MapViewGl {
28 28
     ortho_tile_layer: OrthoTileLayer,
29 29
     atmos_layer: AtmosLayer,
30 30
     projection: Projection,
31
+    show_marker: bool,
31 32
     show_atmos: bool,
32 33
     last_draw_type: DrawType,
33 34
 }
@@ -94,6 +95,7 @@ impl MapViewGl {
94 95
             ortho_tile_layer,
95 96
             atmos_layer,
96 97
             projection: Projection::Mercator,
98
+            show_marker: true,
97 99
             show_atmos: false,
98 100
             last_draw_type: DrawType::Null,
99 101
         }
@@ -131,6 +133,10 @@ impl MapViewGl {
131 133
         };
132 134
     }
133 135
 
136
+    pub fn toggle_marker(&mut self) {
137
+        self.show_marker = !self.show_marker;
138
+    }
139
+
134 140
     pub fn toggle_atmosphere(&mut self) {
135 141
         self.show_atmos = !self.show_atmos;
136 142
     }
@@ -217,14 +223,14 @@ impl MapViewGl {
217 223
         match self.projection {
218 224
             Projection::Mercator => {
219 225
                 let ret = self.draw_mercator_tiles(cx, source, snap_to_pixel);
220
-                if !self.marker_layer.is_empty() {
226
+                if self.show_marker && !self.marker_layer.is_empty() {
221 227
                     self.draw_mercator_marker(cx, snap_to_pixel);
222 228
                 }
223 229
                 ret
224 230
             },
225 231
             Projection::Orthografic => {
226 232
                 let ret = self.draw_ortho_tiles(cx, source);
227
-                if !self.marker_layer.is_empty() {
233
+                if self.show_marker && !self.marker_layer.is_empty() {
228 234
                     self.draw_ortho_marker(cx);
229 235
                 }
230 236
                 if self.show_atmos {