aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-05-04 05:07:07 +0100
committerAkshay <[email protected]>2021-05-04 05:07:07 +0100
commit225351e7c98e91451e0b02fd2b9c3060ebd153a7 (patch)
tree34dc6f42b9835a35ddd03c519fd7ebd2ca0086eb /src/app.rs
parent7c311d2449cc81a20a9a3f5e26b71f36be263a0d (diff)
add middle mouse pan
Diffstat (limited to 'src/app.rs')
-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