浏览代码

Toggle marker visibility with Ctrl+M

Johannes Hofmann 7 年前
父节点
当前提交
67b549d0c2
共有 2 个文件被更改,包括 16 次插入2 次删除
  1. 8
    0
      src/main.rs
  2. 8
    2
      src/map_view_gl.rs

+ 8
- 0
src/main.rs 查看文件

222
                             Action::Nothing
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
                     VirtualKeyCode::H => {
233
                     VirtualKeyCode::H => {
226
                         if modifiers.ctrl {
234
                         if modifiers.ctrl {
227
                             map.toggle_atmosphere();
235
                             map.toggle_atmosphere();

+ 8
- 2
src/map_view_gl.rs 查看文件

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