changeset 13:40c5d2879627

Add functionality for moving around the map via "dragging" while pressing 3rd / middle mouse button.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 24 Sep 2011 11:58:37 +0300
parents cc5de2dcf008
children 3af73bbaec8e
files src/editloop.cc
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/editloop.cc	Sat Sep 24 08:43:19 2011 +0300
+++ b/src/editloop.cc	Sat Sep 24 11:58:37 2011 +0300
@@ -211,8 +211,8 @@
 edit_t e;
 /* FIXME : all these variables should be moved to edit_t : */
 int    RedrawMap;
-bool   DragObject = false;
-int    oldbuttons;
+bool   DragObject = false, DragMapMove = false;
+int    oldbuttons, DragMapMoveX, DragMapMoveY;
 
 bool   StretchSelBox = false;  // FIXME apparently not used anymore...
 
@@ -874,7 +874,31 @@
    /*
     *	Step 3.2.2 -- Mouse events
     */
+   if (DragMapMove && is.key == YE_MOTION) {
+        int deltaX = DragMapMoveX - is.x,
+            deltaY = DragMapMoveY - is.y;
+        
+        if (deltaX != 0 || deltaY != 0) {
+            OrigX += (ScrMaxX * deltaX) / (250 * Scale);
+            OrigY -= (ScrMaxY * deltaY) / (250 * Scale);
+            RedrawMap = 1;
+            DragMapMoveX = is.x;
+            DragMapMoveY = is.y;
+            goto done2;
+        }
+   }
 
+   else if (is.key == YE_BUTM_PRESS) {
+        DragMapMove = true;
+        DragMapMoveX = is.x;
+        DragMapMoveY = is.y;
+        goto done;
+   }
+
+   else if (is.key == YE_BUTM_RELEASE) {
+        DragMapMove = false;
+        goto done;
+   }
 
    // Clicking on an item of the menu bar
    // pulls down the corresponding menu.