aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/app.rs b/src/app.rs
index fc7f736..70d68b8 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -68,6 +68,7 @@ pub struct AppState<'ctx> {
68 pub ttf_context: &'ctx Sdl2TtfContext, 68 pub ttf_context: &'ctx Sdl2TtfContext,
69 pub undo_stack: UndoStack<ModifyRecord>, 69 pub undo_stack: UndoStack<ModifyRecord>,
70 pub zoom: u8, 70 pub zoom: u8,
71 pub pan_start: Point,
71} 72}
72 73
73// private actions on appstate 74// private actions on appstate
@@ -678,6 +679,7 @@ impl<'ctx> AppState<'ctx> {
678 mouse: (0, 0), 679 mouse: (0, 0),
679 pixmap, 680 pixmap,
680 start: Point::new(60, 60), 681 start: Point::new(60, 60),
682 pan_start: Point::new(0, 0),
681 symmetry: Default::default(), 683 symmetry: Default::default(),
682 ttf_context, 684 ttf_context,
683 undo_stack: UndoStack::new(), 685 undo_stack: UndoStack::new(),
@@ -821,6 +823,12 @@ impl<'ctx> AppState<'ctx> {
821 .unwrap_or(0), 823 .unwrap_or(0),
822 ); 824 );
823 } 825 }
826 Event::MouseButtonDown {
827 x,
828 y,
829 mouse_btn: MouseButton::Middle,
830 ..
831 } => self.pan_start = Point::from((x, y)),
824 // start of operation 832 // start of operation
825 Event::MouseButtonDown { 833 Event::MouseButtonDown {
826 x, y, mouse_btn, .. 834 x, y, mouse_btn, ..
@@ -962,6 +970,11 @@ impl<'ctx> AppState<'ctx> {
962 } 970 }
963 _ => (), 971 _ => (),
964 } 972 }
973 } else if mousestate.is_mouse_button_pressed(MouseButton::Middle) {
974 let pan_end = Point::from((x, y));
975 let shift = pan_end - self.pan_start;
976 self.start += shift;
977 self.pan_start = pan_end;
965 } 978 }
966 } 979 }
967 // end of operation 980 // end of operation