changeset 167:bb297f3f99f4

Allow using right mouse button to drag level display
author Neil Muller <drnlmuller@gmail.com>
date Tue, 03 Sep 2013 11:21:43 +0200
parents f73aba2e46bd
children ce8d4fc3baf4
files tools/area_editor.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/area_editor.py	Tue Sep 03 11:21:11 2013 +0200
+++ b/tools/area_editor.py	Tue Sep 03 11:21:43 2013 +0200
@@ -153,6 +153,7 @@
         self.filled_mode = False
         self.mouse_pos = None
         self.cur_poly = None
+        self._mouse_drag = False
 
     def _level_coordinates(self, pos):
         # Move positions to level values
@@ -221,6 +222,15 @@
         if self.cur_poly and old_pos != self.mouse_pos:
             self.invalidate()
 
+    def mouse_drag(self, ev):
+        if self._mouse_drag:
+            old_pos = self.mouse_pos
+            self.mouse_pos = ev.pos
+            diff = (-self.mouse_pos[0] + old_pos[0],
+                    -self.mouse_pos[1] + old_pos[1])
+            self._move_view(diff)
+            self.invalidate()
+
     def mouse_down(self, ev):
         if ev.button == 4:  # Scroll up
             self._move_view((0, -10))
@@ -230,10 +240,16 @@
             self._move_view((-10, 0))
         elif ev.button == 7:  # Scroll right
             self._move_view((10, 0))
-        elif self.cur_poly:
+        elif self.cur_poly and ev.button == 1:
             # Add a point
             self.level.add_point(self.cur_poly,
                                  self._level_coordinates(ev.pos))
+        elif ev.button == 3:
+            self._mouse_drag = True
+
+    def mouse_up(self, ev):
+        if ev.button == 3:
+            self._mouse_drag = False
 
     def close_poly(self):
         if self.cur_poly is None: