bugfix: [#34663] Cannot rotate view while using Knife tool with Maya preset
authorDalai Felinto <dfelinto@gmail.com>
Tue, 17 Sep 2013 20:35:17 +0000 (20:35 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Tue, 17 Sep 2013 20:35:17 +0000 (20:35 +0000)
fix as suggested by Ton Roosendaal in tracker:
"the knife tool has a "MODE_PANNING" state, it could be nice to set this
in the modal map as well, to define the shortcut(s) that have to be passed on."

release/scripts/presets/keyconfig/maya.py
source/blender/editors/mesh/editmesh_knife.c

index cb9926cba8c068a5a456aeb2cc8af508c4ce7ae0..508c226ae5309750980b1a87528f1a8190b8d968 100644 (file)
@@ -688,6 +688,31 @@ kmi.properties.level = 4
 kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True)
 kmi.properties.level = 5
 
+# Knife Tool
+km = kc.keymaps.new('Knife Tool Modal Map', space_type='EMPTY', region_type='WINDOW', modal=True)
+
+kmi = km.keymap_items.new_modal('CANCEL', 'ESC', 'ANY', any=True)
+kmi = km.keymap_items.new_modal('PANNING', 'LEFTMOUSE', 'ANY', alt=True)
+kmi = km.keymap_items.new_modal('ADD_CUT', 'LEFTMOUSE', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('CANCEL', 'RIGHTMOUSE', 'ANY', any=True)
+kmi = km.keymap_items.new_modal('CONFIRM', 'RET', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('CONFIRM', 'NUMPAD_ENTER', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('CONFIRM', 'SPACE', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('NEW_CUT', 'E', 'PRESS')
+
+kmi = km.keymap_items.new_modal('SNAP_MIDPOINT_ON', 'LEFT_CTRL', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('SNAP_MIDPOINT_OFF', 'LEFT_CTRL', 'RELEASE', any=True)
+kmi = km.keymap_items.new_modal('SNAP_MIDPOINT_ON', 'RIGHT_CTRL', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('SNAP_MIDPOINT_OFF', 'RIGHT_CTRL', 'RELEASE', any=True)
+
+kmi = km.keymap_items.new_modal('IGNORE_SNAP_ON', 'LEFT_SHIFT', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('IGNORE_SNAP_OFF', 'LEFT_SHIFT', 'RELEASE', any=True)
+kmi = km.keymap_items.new_modal('IGNORE_SNAP_ON', 'RIGHT_SHIFT', 'PRESS', any=True)
+kmi = km.keymap_items.new_modal('IGNORE_SNAP_OFF', 'RIGHT_SHIFT', 'RELEASE', any=True)
+
+kmi = km.keymap_items.new_modal('ANGLE_SNAP_TOGGLE', 'C', 'PRESS')
+kmi = km.keymap_items.new_modal('CUT_THROUGH_TOGGLE', 'Z', 'PRESS')
+
 # Map Curve
 km = kc.keymaps.new('Curve', space_type='EMPTY', region_type='WINDOW', modal=False)
 
index c0640a4132f1e9161e50576ea2dfc09c14f671c8..7ea1432a7913cd2dda3eacc540730a570ead2b12 100644 (file)
@@ -3123,7 +3123,8 @@ enum {
        KNF_MODEL_IGNORE_SNAP_OFF,
        KNF_MODAL_ADD_CUT,
        KNF_MODAL_ANGLE_SNAP_TOGGLE,
-       KNF_MODAL_CUT_THROUGH_TOGGLE
+       KNF_MODAL_CUT_THROUGH_TOGGLE,
+       KNF_MODAL_PANNING
 };
 
 wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
@@ -3139,6 +3140,7 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
                {KNF_MODAL_CUT_THROUGH_TOGGLE, "CUT_THROUGH_TOGGLE", 0, "Toggle Cut Through", ""},
                {KNF_MODAL_NEW_CUT, "NEW_CUT", 0, "End Current Cut", ""},
                {KNF_MODAL_ADD_CUT, "ADD_CUT", 0, "Add Cut", ""},
+               {KNF_MODAL_PANNING, "PANNING", 0, "Panning", ""},
                {0, NULL, 0, NULL, NULL}
        };
 
@@ -3152,6 +3154,7 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
 
        /* items for modal map */
        WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KNF_MODAL_CANCEL);
+       WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_ANY, KM_ANY, 0, KNF_MODAL_PANNING);
        WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, KNF_MODAL_ADD_CUT);
        WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, KNF_MODAL_CANCEL);
        WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, KNF_MODAL_CONFIRM);
@@ -3277,6 +3280,20 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
                                ED_region_tag_redraw(kcd->ar);
                                break;
+                       case KNF_MODAL_PANNING:
+                               if (event->val != KM_RELEASE) {
+                                       if (kcd->mode != MODE_PANNING) {
+                                               kcd->prevmode = kcd->mode;
+                                               kcd->mode = MODE_PANNING;
+                                       }
+                               }
+                               else {
+                                       kcd->mode = kcd->prevmode;
+                               }
+
+                               ED_region_tag_redraw(kcd->ar);
+                               return OPERATOR_PASS_THROUGH;
+                               break;
                }
        }
        else { /* non-modal-mapped events */
@@ -3287,19 +3304,6 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
                        case WHEELUPMOUSE:
                        case WHEELDOWNMOUSE:
                                return OPERATOR_PASS_THROUGH;
-                       case MIDDLEMOUSE:
-                               if (event->val != KM_RELEASE) {
-                                       if (kcd->mode != MODE_PANNING)
-                                               kcd->prevmode = kcd->mode;
-                                       kcd->mode = MODE_PANNING;
-                               }
-                               else {
-                                       kcd->mode = kcd->prevmode;
-                               }
-
-                               ED_region_tag_redraw(kcd->ar);
-                               return OPERATOR_PASS_THROUGH;
-
                        case MOUSEMOVE: /* mouse moved somewhere to select another loop */
                                if (kcd->mode != MODE_PANNING) {
                                        knifetool_update_mval_i(kcd, event->mval);