2 small view navigation features stolen from other apps :)
authorMatt Ebb <matt@mke3.net>
Wed, 6 Jan 2010 12:22:59 +0000 (12:22 +0000)
committerMatt Ebb <matt@mke3.net>
Wed, 6 Jan 2010 12:22:59 +0000 (12:22 +0000)
* Now, while rotating a 3D view with MMB held down, you can hold shift to switch to Pan or ctrl to switch to Zoom, without having to let go of MMB. While it sounds simple it makes things really smooth to use and eases repeated presses of MMB. One thing I liked from Max. It's also in the modal key maps, so you can change it to whatever you like.

* A similar thing, when panning a 2D View, you can hold LMB to switch to zoom, effectively making MMB+LMB zoom. This is not very useful on a mouse, but it's very nice for tablet use, being able to navigate with one hand (side switch+stylus press) very easily. This one's from Fusion.

source/blender/editors/interface/view2d_ops.c
source/blender/editors/space_view3d/view3d_edit.c

index 7d1dc00e2717b4fecbe60be80b3155c8f92571a8..57882b7dd0dbf21c551352eb87b25c4a914b78e2 100644 (file)
@@ -236,6 +236,18 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
                        break;
                        
                case LEFTMOUSE:
+                       /* switch to zoom */
+                       if (event->val==KM_PRESS) {
+                               /* calculate overall delta mouse-movement for redo */
+                               RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
+                               RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
+                               
+                               view_pan_exit(C, op);
+                               WM_cursor_restore(CTX_wm_window(C));
+                               
+                               WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL);
+                               return OPERATOR_FINISHED;
+                       }
                case MIDDLEMOUSE:
                case ESCKEY:
                        if (event->val==KM_RELEASE) {
index c0d9d49d1883cc5a4cb128c2282bb40b6525ffba..680cc53c8028de3493e3130c928f63b598b1643a 100644 (file)
@@ -445,7 +445,9 @@ enum {
 #define VIEW_MODAL_CONFIRM                             1 /* used for all view operations */
 #define VIEWROT_MODAL_AXIS_SNAP_ENABLE 2
 #define VIEWROT_MODAL_AXIS_SNAP_DISABLE        3
-
+#define VIEWROT_MODAL_SWITCH_ZOOM              4
+#define VIEWROT_MODAL_SWITCH_MOVE              5
+#define VIEWROT_MODAL_SWITCH_ROTATE            6
 
 /* called in transform_ops.c, on each regeneration of keymaps  */
 void viewrotate_modal_keymap(wmKeyConfig *keyconf)
@@ -455,6 +457,9 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
 
        {VIEWROT_MODAL_AXIS_SNAP_ENABLE,        "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""},
        {VIEWROT_MODAL_AXIS_SNAP_DISABLE,       "AXIS_SNAP_DISABLE", 0, "Enable Axis Snap", ""},
+               
+       {VIEWROT_MODAL_SWITCH_ZOOM, "SWITCH_TO_ZOOM", 0, "Switch to Zoom"},
+       {VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
 
        {0, NULL, 0, NULL, NULL}};
 
@@ -469,9 +474,13 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf)
        WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
        WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
 
-       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_ENABLE);
-       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_DISABLE);
+       WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_ENABLE);
+       WM_modalkeymap_add_item(keymap, LEFTALTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_DISABLE);
 
+       WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
+       WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE);
+       
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_rotate");
 
@@ -633,6 +642,14 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
                                vod->axis_snap= FALSE;
                                event_code= VIEW_APPLY;
                                break;
+                       case VIEWROT_MODAL_SWITCH_ZOOM:
+                               WM_operator_name_call(C, "VIEW3D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
+                       case VIEWROT_MODAL_SWITCH_MOVE:
+                               WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
                }
        }
        else if(event->type==vod->origkey && event->val==KM_RELEASE) {
@@ -736,6 +753,10 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
        WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
        WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
 
+       WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ZOOM);
+       WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
+       
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_move");
 }
@@ -784,6 +805,14 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
                        case VIEW_MODAL_CONFIRM:
                                event_code= VIEW_CONFIRM;
                                break;
+                       case VIEWROT_MODAL_SWITCH_ZOOM:
+                               WM_operator_name_call(C, "VIEW3D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
+                       case VIEWROT_MODAL_SWITCH_ROTATE:
+                               WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
                }
        }
        else if(event->type==vod->origkey && event->val==KM_RELEASE) {
@@ -854,6 +883,10 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf)
        WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
        WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
 
+       WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
+       WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
+       WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE);
+       
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom");
 }
@@ -995,6 +1028,14 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
                        case VIEW_MODAL_CONFIRM:
                                event_code= VIEW_CONFIRM;
                                break;
+                       case VIEWROT_MODAL_SWITCH_MOVE:
+                               WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
+                       case VIEWROT_MODAL_SWITCH_ROTATE:
+                               WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL);
+                               event_code= VIEW_CONFIRM;
+                               break;
                }
        }
        else if(event->type==vod->origkey && event->val==KM_RELEASE) {