]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikwindow.c
Enable zooming in/out in jumps of 3 levels by pressing shift key at the same time...
[andy/viking.git] / src / vikwindow.c
index a1f49abe8cd888c104ac0b059c15915820468074..122f966f513a5f572503328d11439ad1a35a471d 100644 (file)
@@ -1817,6 +1817,9 @@ static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event
       draw_buf_done = FALSE;
     }
   }
+  else
+    zts->bounds_active = FALSE;
+
   return VIK_LAYER_TOOL_ACK;
 }
 
@@ -1824,11 +1827,11 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev
 {
   guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
 
-  zts->bounds_active = FALSE;
-
   // Ensure haven't just released on the exact same position
   //  i.e. probably haven't moved the mouse at all
-  if ( modifiers == GDK_SHIFT_MASK && !( ( event->x == zts->start_x ) && ( event->y == zts->start_y )) ) {
+  if ( zts->bounds_active && modifiers == GDK_SHIFT_MASK &&
+     ( event->x < zts->start_x-5 || event->x > zts->start_x+5 ) &&
+     ( event->y < zts->start_y-5 || event->y > zts->start_y+5 ) ) {
 
     VikCoord coord1, coord2;
     vik_viewport_screen_to_coord ( zts->vw->viking_vvp, zts->start_x, zts->start_y, &coord1);
@@ -1883,9 +1886,30 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev
       zoom = zoom * 2;
       vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom );
     }
-
-    draw_update ( zts->vw );
   }
+  else {
+     // When pressing shift and clicking for zoom, then jump three levels
+     if ( modifiers == GDK_SHIFT_MASK ) {
+       // Zoom in/out by three if possible
+       vik_viewport_set_center_screen ( zts->vw->viking_vvp, event->x, event->y );
+       if ( event->button == 1 ) {
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+          vik_viewport_zoom_in ( zts->vw->viking_vvp );
+       }
+       else if ( event->button == 3 ) {
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+          vik_viewport_zoom_out ( zts->vw->viking_vvp );
+       }
+     }
+  }
+
+  draw_update ( zts->vw );
+
+  // Reset
+  zts->bounds_active = FALSE;
+
   return VIK_LAYER_TOOL_ACK;
 }