diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -283,6 +283,7 @@ impl<'ctx> AppState<'ctx> { | |||
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | // recenters the viewport | ||
286 | pub fn center_grid(&mut self) { | 287 | pub fn center_grid(&mut self) { |
287 | let (winsize_x, winsize_y) = self.canvas.window().size(); | 288 | let (winsize_x, winsize_y) = self.canvas.window().size(); |
288 | let grid_width = self.width() * self.zoom as u32; | 289 | let grid_width = self.width() * self.zoom as u32; |
@@ -293,6 +294,17 @@ impl<'ctx> AppState<'ctx> { | |||
293 | ); | 294 | ); |
294 | } | 295 | } |
295 | 296 | ||
297 | // brings the pixel under the mouse to win center | ||
298 | pub fn center_mouse(&mut self) { | ||
299 | let win_size = self.canvas.window().size(); | ||
300 | let win_center = ((win_size.0 / 2) as i32, (win_size.1 / 2) as i32); | ||
301 | self.context | ||
302 | .mouse() | ||
303 | .warp_mouse_in_window(self.canvas.window(), win_center.0, win_center.1); | ||
304 | let delta = Point::from(self.mouse) - Point::from(win_center); | ||
305 | self.start -= delta; | ||
306 | } | ||
307 | |||
296 | pub fn reduce_intensity(&mut self) { | 308 | pub fn reduce_intensity(&mut self) { |
297 | if self.dither_level > 0 { | 309 | if self.dither_level > 0 { |
298 | self.dither_level -= 1; | 310 | self.dither_level -= 1; |
@@ -804,16 +816,6 @@ impl<'ctx> AppState<'ctx> { | |||
804 | } | 816 | } |
805 | continue; | 817 | continue; |
806 | } | 818 | } |
807 | Keycode::LCtrl | Keycode::RCtrl => { | ||
808 | self.brush = Brush::line( | ||
809 | self.cache | ||
810 | .borrow() | ||
811 | .as_ref() | ||
812 | .map(|c| c.last_brush.size().unwrap_or(0)) | ||
813 | .unwrap_or(0), | ||
814 | true, | ||
815 | ); | ||
816 | } | ||
817 | _ => (), | 819 | _ => (), |
818 | } | 820 | } |
819 | } | 821 | } |
@@ -822,8 +824,9 @@ impl<'ctx> AppState<'ctx> { | |||
822 | keymod, | 824 | keymod, |
823 | .. | 825 | .. |
824 | } if self.keybinds.contains_key(&Keybind::new(k, keymod)) => { | 826 | } if self.keybinds.contains_key(&Keybind::new(k, keymod)) => { |
825 | let body = self.keybinds.get(&Keybind::new(k, keymod)).unwrap(); | 827 | let body = |
826 | self.eval_expr(&body.clone()); | 828 | self.keybinds.get(&Keybind::new(k, keymod)).unwrap().clone(); |
829 | self.eval_expr(&body); | ||
827 | } | 830 | } |
828 | Event::KeyDown { | 831 | Event::KeyDown { |
829 | keycode: Some(k), .. | 832 | keycode: Some(k), .. |
@@ -1071,7 +1074,6 @@ impl<'ctx> AppState<'ctx> { | |||
1071 | } | 1074 | } |
1072 | } | 1075 | } |
1073 | } | 1076 | } |
1074 | self.cache(); | ||
1075 | self.redraw(); | 1077 | self.redraw(); |
1076 | } | 1078 | } |
1077 | } | 1079 | } |