Key map related things:
authorMatt Ebb <matt@mke3.net>
Thu, 24 Dec 2009 09:26:06 +0000 (09:26 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 24 Dec 2009 09:26:06 +0000 (09:26 +0000)
* Moved 'change shortcut' (previously directly RMB on menu items) to a context-menu item, and added Remove Shortcut and Add Shortcut. This is all available now in a RMB context menu for operator buttons and menu entries.
* Renamed a bunch of key maps to be consistent with UI names, and human-readable. Since these key map names are now being directly used in the UI for people to find things, they should be understandable and in plain language.

This renaming may break some older saved key map setups - though previously saved .b25.blends should convert over ok. Exported .py files may need some find/replacing - in this commit check the changes in resources.c to see what's changed.

28 files changed:
release/scripts/ui/space_userpref.py
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/nla_ops.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_time/time_ops.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_keymap.c

index e33ac91435deb53bf8104e7e93c60b6ae0d856b4..81f61b3c78c49c5e3d1b306e2962e51dcca3f3a6 100644 (file)
@@ -21,71 +21,79 @@ import bpy
 
 KM_HIERARCHY = [
                     ('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
-                    ('Screen Editing', 'EMPTY', 'WINDOW', []),    # resizing, action corners
-                    ('Screen', 'EMPTY', 'WINDOW', []),    # full screen, undo, screenshot
+                    ('Screen', 'EMPTY', 'WINDOW', [    # full screen, undo, screenshot
+                        ('Screen Editing', 'EMPTY', 'WINDOW', []),    # resizing, action corners
+                        ]),    
 
                     ('View2D', 'EMPTY', 'WINDOW', []),    # view 2d navigation (per region)
-                    ('Frames', 'EMPTY', 'WINDOW', []),    # frame navigation (per region)
+                    ('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
                     ('Header', 'EMPTY', 'WINDOW', []),    # header stuff (per region)
-                    ('Markers', 'EMPTY', 'WINDOW', []),    # markers (per region)
-                    ('Animation', 'EMPTY', 'WINDOW', []),    # frame change on click, preview range (per region)
                     ('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region)
-
-                    ('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
-                    ('Animation_Channels', 'EMPTY', 'WINDOW', []),
-
-                    ('Buttons Generic', 'PROPERTIES', 'WINDOW', []), # align context menu
-                    ('TimeLine', 'TIMELINE', 'WINDOW', []),
-                    ('Outliner', 'OUTLINER', 'WINDOW', []),
-
-                    ('View3D', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
-                        ('Pose', 'EMPTY', 'WINDOW', []),
+                    
+                    ('3D View', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
                         ('Object Mode', 'EMPTY', 'WINDOW', []),
-                        ('Vertex Paint', 'EMPTY', 'WINDOW', []),
-                        ('Weight Paint', 'EMPTY', 'WINDOW', []),
-                        ('Face Mask', 'EMPTY', 'WINDOW', []),
-                        ('Sculpt', 'EMPTY', 'WINDOW', []),
-                        ('EditMesh', 'EMPTY', 'WINDOW', []),
+                        ('Mesh', 'EMPTY', 'WINDOW', []),
                         ('Curve', 'EMPTY', 'WINDOW', []),
                         ('Armature', 'EMPTY', 'WINDOW', []),
                         ('Metaball', 'EMPTY', 'WINDOW', []),
                         ('Lattice', 'EMPTY', 'WINDOW', []),
-                        ('Armature_Sketch', 'EMPTY', 'WINDOW', []),
-                        ('Particle', 'EMPTY', 'WINDOW', []),
                         ('Font', 'EMPTY', 'WINDOW', []),
-                        ('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
+                        
+                        ('Pose', 'EMPTY', 'WINDOW', []),
+                        
+                        ('Vertex Paint', 'EMPTY', 'WINDOW', []),
+                        ('Weight Paint', 'EMPTY', 'WINDOW', []),
+                        ('Face Mask', 'EMPTY', 'WINDOW', []),
                         ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
-                        ('View3D Generic', 'VIEW_3D', 'WINDOW', [])    # toolbar and properties
+                        ('Sculpt', 'EMPTY', 'WINDOW', []),
+                        
+                        ('Armature Sketch', 'EMPTY', 'WINDOW', []),
+                        ('Particle', 'EMPTY', 'WINDOW', []),
+                        
+                        ('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
+                        
+                        ('3D View Generic', 'VIEW_3D', 'WINDOW', [])    # toolbar and properties
+                        ]),
+                    
+                    ('Frames', 'EMPTY', 'WINDOW', []),    # frame navigation (per region)
+                    ('Markers', 'EMPTY', 'WINDOW', []),    # markers (per region)
+                    ('Animation', 'EMPTY', 'WINDOW', []),    # frame change on click, preview range (per region)
+                    ('Animation Channels', 'EMPTY', 'WINDOW', []),
+                    ('Graph Editor', 'GRAPH_EDITOR', 'WINDOW', [
+                        ('Graph Editor Generic', 'GRAPH_EDITOR', 'WINDOW', [])
                         ]),
-                    ('GraphEdit Keys', 'GRAPH_EDITOR', 'WINDOW', [
-                        ('GraphEdit Generic', 'GRAPH_EDITOR', 'WINDOW', [])
+                    ('Dopesheet', 'DOPESHEET_EDITOR', 'WINDOW', []),
+                    ('NLA Editor', 'NLA_EDITOR', 'WINDOW', [
+                        ('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
+                        ('NLA Generic', 'NLA_EDITOR', 'WINDOW', [])
                         ]),
 
                     ('Image', 'IMAGE_EDITOR', 'WINDOW', [
-                        ('UVEdit', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
+                        ('UV Editor', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
                         ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
                         ('Image Generic', 'IMAGE_EDITOR', 'WINDOW', [])
                         ]),
-
-                    ('Node Generic', 'NODE_EDITOR', 'WINDOW', [
-                        ('Node', 'NODE_EDITOR', 'WINDOW', [])
-                        ]),
-                    ('File', 'FILE_BROWSER', 'WINDOW', [
-                        ('FileMain', 'FILE_BROWSER', 'WINDOW', []),
-                        ('FileButtons', 'FILE_BROWSER', 'WINDOW', [])
+                        
+                    ('Timeline', 'TIMELINE', 'WINDOW', []),
+                    ('Outliner', 'OUTLINER', 'WINDOW', []),
+                        
+                    ('Node Editor', 'NODE_EDITOR', 'WINDOW', [
+                        ('Node Generic', 'NODE_EDITOR', 'WINDOW', [])
                         ]),
-                    ('Action_Keys', 'DOPESHEET_EDITOR', 'WINDOW', []),
-                    ('NLA Generic', 'NLA_EDITOR', 'WINDOW', [
-                        ('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
-                        ('NLA Data', 'NLA_EDITOR', 'WINDOW', [])
+                    ('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
+                    ('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
+                    
+                    ('File Browser', 'FILE_BROWSER', 'WINDOW', [
+                        ('File Browser Main', 'FILE_BROWSER', 'WINDOW', []),
+                        ('File Browser Buttons', 'FILE_BROWSER', 'WINDOW', [])
                         ]),
+
+                    ('Property Editor', 'PROPERTIES', 'WINDOW', []), # align context menu
+
                     ('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
                     ('Text', 'TEXT_EDITOR', 'WINDOW', []),
-                    ('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
-                    ('Logic Generic', 'LOGIC_EDITOR', 'WINDOW', []),
                     ('Console', 'CONSOLE', 'WINDOW', []),
-
-
+                    
                     ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
                     ('Gesture Border', 'EMPTY', 'WINDOW', []),
                     ('Standard Modal Map', 'EMPTY', 'WINDOW', []),
index c919b164a0558cae9e5d604fd9bc2fedcc4f3c5b..0c77c2b001013e1cd339fb2447ad3bbb51eec405 100644 (file)
@@ -1901,7 +1901,7 @@ void ED_operatortypes_animchannels(void)
 
 void ED_keymap_animchannels(wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation_Channels", 0, 0);
+       wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0);
        
        /* selection */
                /* click-select */
index 313791e28cbccda23b75ed3945b943952435ac5c..2af7fe09509a0661be906112e2636c83fb2e4bda 100644 (file)
@@ -592,6 +592,7 @@ void UI_exit(void);
 #define UI_ITEM_R_EVENT                        32
 #define UI_ITEM_R_FULL_EVENT   64
 #define UI_ITEM_R_NO_BG                        128
+#define UI_ITEM_R_IMMEDIATE            256
 
 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
index f0d09c505ac674009bc97b1f202791925aabff44..88b9c7819fd17507c5da2201db03166226d8a5d2 100644 (file)
@@ -1995,23 +1995,18 @@ void ui_check_but(uiBut *but)
                
        case HOTKEYEVT:
                if (but->flag & UI_SELECT) {
-                       short *sp= (short *)but->func_arg3;
+                       strncpy(but->drawstr, "", UI_MAX_DRAW_STR);
                        
-                       if(but->flag & UI_BUT_IMMEDIATE)
-                               strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
-                       else
-                               strncpy(but->drawstr, "", UI_MAX_DRAW_STR);
-                       
-                       if(*sp) {
+                       if(but->modifier_key) {
                                char *str= but->drawstr;
                                
-                               if(*sp & KM_SHIFT)
+                               if(but->modifier_key & KM_SHIFT)
                                        str= strcat(str, "Shift ");
-                               if(*sp & KM_CTRL)
+                               if(but->modifier_key & KM_CTRL)
                                        str= strcat(str, "Ctrl ");
-                               if(*sp & KM_ALT)
+                               if(but->modifier_key & KM_ALT)
                                        str= strcat(str, "Alt ");
-                               if(*sp & KM_OSKEY)
+                               if(but->modifier_key & KM_OSKEY)
                                        str= strcat(str, "Cmd ");
                        }
                        else
@@ -3169,7 +3164,7 @@ uiBut *uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1
 uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *keypoin, short *modkeypoin, char *tip)
 {
        uiBut *but= ui_def_but(block, HOTKEYEVT|SHO, retval, str, x1, y1, x2, y2, keypoin, 0.0, 0.0, 0.0, 0.0, tip);
-       but->func_arg3= modkeypoin; /* XXX hrmf, abuse! */
+       but->modifier_key= *modkeypoin;
        ui_check_but(but);
        return but;
 }
index 88868a61592f9ccde75ec1485137f6d4ecace7c7..b41f47db2710b5e2f20057f759e7dc07677d4f5f 100644 (file)
@@ -1862,13 +1862,12 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
        if(data->state == BUTTON_STATE_HIGHLIGHT) {
                if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
                        but->drawstr[0]= 0;
-                       *(short *)but->func_arg3= 0;
+                       but->modifier_key= 0;
                        button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
                        return WM_UI_HANDLER_BREAK;
                }
        }
        else if(data->state == BUTTON_STATE_WAIT_KEY_EVENT) {
-               short *sp= (short *)but->func_arg3;
                
                if(event->type == MOUSEMOVE)
                        return WM_UI_HANDLER_CONTINUE;
@@ -1884,15 +1883,15 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
                }
                
                /* always set */
-               *sp= 0; 
+               but->modifier_key = 0;
                if(event->shift)
-                       *sp |= KM_SHIFT;
+                       but->modifier_key |= KM_SHIFT;
                if(event->alt)
-                       *sp |= KM_ALT;
+                       but->modifier_key |= KM_ALT;
                if(event->ctrl)
-                       *sp |= KM_CTRL;
+                       but->modifier_key |= KM_CTRL;
                if(event->oskey)
-                       *sp |= KM_OSKEY;
+                       but->modifier_key |= KM_OSKEY;
                
                ui_check_but(but);
                ED_region_tag_redraw(data->region);
@@ -3333,69 +3332,134 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
        return WM_UI_HANDLER_CONTINUE;
 }
 
-/* callback for hotkey change button/menu */
-static void do_menu_change_hotkey(bContext *C, void *but_v, void *key_v)
+static void but_shortcut_name_func(bContext *C, void *arg1, int event)
 {
-       uiBut *but= but_v;
-       IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
-       short *key= key_v;
-       char buf[512], *butstr, *cpoin;
+       uiBut *but = (uiBut *)arg1;
        
-       /* signal for escape */
-       if(key[0]==0) return;
+       char buf[512], *butstr, *cpoin;
        
-       WM_key_event_operator_change(C, but->optype->idname, but->opcontext, prop, key[0], key[1]);
-
-       /* complex code to change name of button */
-       if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
-               
-               butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
+       if (but->optype) {
+               IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
                
-               /* XXX but->str changed... should not, remove the hotkey from it */
-               cpoin= strchr(but->str, '|');
-               if(cpoin) *cpoin= 0;            
-
-               strcpy(butstr, but->str);
-               strcat(butstr, "|");
-               strcat(butstr, buf);
-               
-               but->str= but->strdata;
-               BLI_strncpy(but->str, butstr, sizeof(but->strdata));
-               MEM_freeN(butstr);
-               
-               ui_check_but(but);
+               /* complex code to change name of button */
+               if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
+                       
+                       butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
+                       
+                       // XXX but->str changed... should not, remove the hotkey from it
+                       cpoin= strchr(but->str, '|');
+                       if(cpoin) *cpoin= 0;            
+                       
+                       strcpy(butstr, but->str);
+                       strcat(butstr, "|");
+                       strcat(butstr, buf);
+                       
+                       but->str= but->strdata;
+                       BLI_strncpy(but->str, butstr, sizeof(but->strdata));
+                       MEM_freeN(butstr);
+                       
+                       ui_check_but(but);
+               } else {
+                       /* shortcut was removed */
+                       cpoin= strchr(but->str, '|');
+                       if(cpoin) *cpoin= 0;
+               }
        }
-                               
 }
 
+static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
+{
+       uiBlock *block;
+       uiBut *but = (uiBut *)arg;
+       wmKeyMap *km;
+       wmKeyMapItem *kmi;
+       PointerRNA ptr;
+       uiLayout *layout;
+       uiStyle *style= U.uistyles.first;
+       IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+       int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, &km);
+
+       kmi = WM_keymap_item_find_id(km, kmi_id);
+       
+       RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr);
+       
+       block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+       uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
+       uiBlockSetFlag(block, UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT);
+       uiBlockSetDirection(block, UI_CENTER);
+       
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
+       
+       uiItemR(layout, "", 0, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE);
+       
+       uiPopupBoundsBlock(block, 6, 100, 10);
+       uiEndBlock(C, block);
+       
+       return block;
+}
 
-static uiBlock *menu_change_hotkey(bContext *C, ARegion *ar, void *arg_but)
+static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
 {
        uiBlock *block;
-       uiBut *but= arg_but;
-       wmOperatorType *ot= WM_operatortype_find(but->optype->idname, 1);
-       static short dummy[2];
-       char buf[OP_MAX_TYPENAME+10];
+       uiBut *but = (uiBut *)arg;
+       wmKeyMap *km;
+       wmKeyMapItem *kmi;
+       PointerRNA ptr;
+       uiLayout *layout;
+       uiStyle *style= U.uistyles.first;
+       IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
        
-       dummy[0]= 0;
-       dummy[1]= 0;
+       km = WM_keymap_guess_opname(C, but->optype->idname);            
+       kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
+       MEM_freeN(kmi->properties);
+       kmi->properties= IDP_CopyProperty(prop);
        
-       block= uiBeginBlock(C, ar, "_popup", UI_EMBOSSP);
-       uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT);
+       RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr);
        
-       BLI_strncpy(buf, ot->name, OP_MAX_TYPENAME);
-       strcat(buf, " |");
+       block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+       uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
+       uiBlockSetFlag(block, UI_BLOCK_RET_1);
+       uiBlockSetDirection(block, UI_CENTER);
        
-       but= uiDefHotKeyevtButS(block, 0, buf, 0, 0, 200, 20, dummy, dummy+1, "");
-       uiButSetFlag(but, UI_BUT_IMMEDIATE);
-       uiButSetFunc(but, do_menu_change_hotkey, arg_but, dummy);
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
 
-       uiPopupBoundsBlock(block, 6.0f, 50, -10);
+       uiItemR(layout, "", 0, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE);
+       
+       uiPopupBoundsBlock(block, 6, 100, 10);
        uiEndBlock(C, block);
        
        return block;
 }
 
+static void popup_change_shortcut_func(bContext *C, void *arg1, void *arg2)
+{
+       uiBut *but = (uiBut *)arg1;
+       button_timers_tooltip_remove(C, but);
+       uiPupBlock(C, menu_change_shortcut, but);
+}
+
+static void remove_shortcut_func(bContext *C, void *arg1, void *arg2)
+{
+       uiBut *but = (uiBut *)arg1;
+       wmKeyMap *km;
+       wmKeyMapItem *kmi;
+       IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+       int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, &km);
+       
+       kmi = WM_keymap_item_find_id(km, kmi_id);
+       WM_keymap_remove_item(km, kmi);
+       
+       but_shortcut_name_func(C, but, 0);
+}
+
+static void popup_add_shortcut_func(bContext *C, void *arg1, void *arg2)
+{
+       uiBut *but = (uiBut *)arg1;
+       button_timers_tooltip_remove(C, but);
+       uiPupBlock(C, menu_add_shortcut, but);
+}
+
+
 static int ui_but_menu(bContext *C, uiBut *but)
 {
        uiPopupMenu *pup;
@@ -3512,7 +3576,36 @@ static int ui_but_menu(bContext *C, uiBut *but)
                uiItemS(layout);
        }
 
+       /* Operator buttons */
+       if(but->optype) {
+               uiBlock *block = uiLayoutGetBlock(layout);
+               uiBut *but2;
+               IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+               int w = uiLayoutGetWidth(layout);
+               char buf[512];
+
+               /* keyboard shortcuts */
+               if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
+
+                       // would rather use a block but, but gets weirdly positioned...
+                       //uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, "");
+                       
+                       but2 = uiDefIconTextBut(block, BUT, 0, 0, "Change Shortcut", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+                       uiButSetFunc(but2, popup_change_shortcut_func, but, NULL);
+
+                       but2 = uiDefIconTextBut(block, BUT, 0, 0, "Remove Shortcut", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+                       uiButSetFunc(but2, remove_shortcut_func, but, NULL);
+               }
+               /* only show 'add' if there's a suitable key map for it to go in */
+               else if (WM_keymap_guess_opname(C, but->optype->idname)) {
+                       but2 = uiDefIconTextBut(block, BUT, 0, 0, "Add Shortcut", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+                       uiButSetFunc(but2, popup_add_shortcut_func, but, NULL);
+               }
+               
+               uiItemS(layout);
+       }
 
+       
        {       /* Docs */
                char buf[512];
                PointerRNA ptr_props;
@@ -3605,18 +3698,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                /* handle menu */
                else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
                        /* RMB has two options now */
-
-                       if((but->block->flag & UI_BLOCK_LOOP) && but->optype) {
-                               IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
-                               char buf[512];
-                               
-                               if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
-                                       button_timers_tooltip_remove(C, but);
-                                       uiPupBlock(C, menu_change_hotkey, but);
-
-                               }
-                       }
-                       else if (ui_but_menu(C, but)) {
+                       if (ui_but_menu(C, but)) {
                                return WM_UI_HANDLER_BREAK;
                        }
                }
@@ -3958,7 +4040,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
                                int time;
 
                                if(but->block->auto_open==2) time= 1;    // test for toolbox
-                               else if(but->block->flag & UI_BLOCK_LOOP || but->block->auto_open) time= 5*U.menuthreshold2;
+                               else if((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open) time= 5*U.menuthreshold2;
                                else if(U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1;
                                else time= -1;
 
index 97ef1f1ea176bb62593ad6ab2759e36d12758acd..02808f9c2e76e34fcd18b112602b13ec68e3b197 100644 (file)
@@ -199,7 +199,8 @@ struct uiBut {
 
        BIFIconID icon;
        short but_align;        /* aligning buttons, horiz/vertical */
-       short lock, win;
+       short lock;
+       short modifier_key;
        short iconadd, dt;
 
        /* IDPOIN data */
index 9dd5535ea30d21e78daea5c4a66c1976af44e2e6..e512c1f6bf81e6cc7de5b3fd78a8c6a1f075a6ff 100644 (file)
@@ -486,12 +486,11 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr,
 static void ui_keymap_but_cb(bContext *C, void *but_v, void *key_v)
 {
        uiBut *but= but_v;
-       short modifier= *((short*)key_v);
 
-       RNA_boolean_set(&but->rnapoin, "shift", (modifier & KM_SHIFT) != 0);
-       RNA_boolean_set(&but->rnapoin, "ctrl", (modifier & KM_CTRL) != 0);
-       RNA_boolean_set(&but->rnapoin, "alt", (modifier & KM_ALT) != 0);
-       RNA_boolean_set(&but->rnapoin, "oskey", (modifier & KM_OSKEY) != 0);
+       RNA_boolean_set(&but->rnapoin, "shift", (but->modifier_key & KM_SHIFT) != 0);
+       RNA_boolean_set(&but->rnapoin, "ctrl", (but->modifier_key & KM_CTRL) != 0);
+       RNA_boolean_set(&but->rnapoin, "alt", (but->modifier_key & KM_ALT) != 0);
+       RNA_boolean_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) != 0);
 }
 
 /* create label + button for RNA property */
@@ -533,14 +532,14 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
        }
        else if(flag & UI_ITEM_R_FULL_EVENT) {
                if(RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
-                       static short dummy = 0;
                        char buf[128];
 
                        WM_keymap_item_to_string(ptr->data, buf, sizeof(buf));
 
                        but= uiDefButR(block, HOTKEYEVT, 0, buf, x, y, w, h, ptr, RNA_property_identifier(prop), 0, 0, 0, -1, -1, NULL);
-                       but->func_arg3= &dummy; // XXX abuse
-                       uiButSetFunc(but, ui_keymap_but_cb, but, &dummy);
+                       uiButSetFunc(but, ui_keymap_but_cb, but, NULL);
+                       if (flag & UI_ITEM_R_IMMEDIATE)
+                               uiButSetFlag(but, UI_BUT_IMMEDIATE);
                }
        }
        else
index b2ae5572a05428d5b82ae3d8b9c16b37c41b5e25..47bbbd9292cee9508c670f9d96bb80827231e944 100644 (file)
@@ -46,6 +46,7 @@
 #include "DNA_userdef_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -1269,6 +1270,47 @@ void init_userdef_do_versions(void)
        if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 5))
                U.gameflags |= USER_DISABLE_VBO;
        
+       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 8)) {
+               wmKeyMap *km;
+               
+               for(km=U.keymaps.first; km; km=km->next) {
+                       if (strcmp(km->idname, "Armature_Sketch")==0)
+                               strcpy(km->idname, "Armature Sketch");
+                       else if (strcmp(km->idname, "View3D")==0)
+                               strcpy(km->idname, "3D View");
+                       else if (strcmp(km->idname, "View3D Generic")==0)
+                               strcpy(km->idname, "3D View Generic");
+                       else if (strcmp(km->idname, "EditMesh")==0)
+                               strcpy(km->idname, "Mesh");
+                       else if (strcmp(km->idname, "TimeLine")==0)
+                               strcpy(km->idname, "Timeline");
+                       else if (strcmp(km->idname, "UVEdit")==0)
+                               strcpy(km->idname, "UV Editor");
+                       else if (strcmp(km->idname, "Animation_Channels")==0)
+                               strcpy(km->idname, "Animation Channels");
+                       else if (strcmp(km->idname, "GraphEdit Keys")==0)
+                               strcpy(km->idname, "Graph Editor");
+                       else if (strcmp(km->idname, "GraphEdit Generic")==0)
+                               strcpy(km->idname, "Graph Editor Generic");
+                       else if (strcmp(km->idname, "Action_Keys")==0)
+                               strcpy(km->idname, "Dopesheet");
+                       else if (strcmp(km->idname, "NLA Data")==0)
+                               strcpy(km->idname, "NLA Editor");
+                       else if (strcmp(km->idname, "Node Generic")==0)
+                               strcpy(km->idname, "Node Editor");
+                       else if (strcmp(km->idname, "Logic Generic")==0)
+                               strcpy(km->idname, "Logic Editor");
+                       else if (strcmp(km->idname, "File")==0)
+                               strcpy(km->idname, "File Browser");
+                       else if (strcmp(km->idname, "FileMain")==0)
+                               strcpy(km->idname, "File Browser Main");
+                       else if (strcmp(km->idname, "FileButtons")==0)
+                               strcpy(km->idname, "File Browser Buttons");
+                       else if (strcmp(km->idname, "Buttons Generic")==0)
+                               strcpy(km->idname, "Property Editor");
+               }
+       }
+       
        /* GL Texture Garbage Collection (variable abused above!) */
        if (U.textimeout == 0) {
                U.texcollectrate = 60;
index 11b5f3a903160f8518cda6961caeb24259176f16..c41ac9f6550ca15273ce712e0b753a384f79be21 100644 (file)
@@ -207,7 +207,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
        
-       keymap= WM_keymap_find(keyconf, "EditMesh", 0, 0);
+       keymap= WM_keymap_find(keyconf, "Mesh", 0, 0);
        keymap->poll= ED_operator_editmesh;
        
        WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0);
index b4c9fee84696281f3c4ba23c495f4b19e9584793..68c354b2b871d90a28c4fc458b329dab3e9b51ed 100644 (file)
@@ -175,7 +175,7 @@ void action_keymap(wmKeyConfig *keyconf)
         */
        
        /* keyframes */
-       keymap= WM_keymap_find(keyconf, "Action_Keys", SPACE_ACTION, 0);
+       keymap= WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0);
        action_keymap_keyframes(keyconf, keymap);
 }
 
index 6a53e565e75cd43115234c13774ec50df5101a2d..57a39b3225ed5c3f999f94a561fea9adaa7c8a44 100644 (file)
@@ -159,7 +159,7 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "Action_Keys", SPACE_ACTION, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -222,7 +222,7 @@ static void action_channel_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "Animation_Channels", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 9a4ac872ceb5e3cf72b81608ebb7a9db003938b8..7f9c1477ee7d8a4f63c8f9070d5002c7d993b719 100644 (file)
@@ -142,7 +142,7 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar)
 
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_find(wm->defaultconf, "Buttons Generic", SPACE_BUTS, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Property Editor", SPACE_BUTS, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -193,7 +193,7 @@ void buttons_operatortypes(void)
 
 void buttons_keymap(struct wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "Buttons Generic", SPACE_BUTS, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "Property Editor", SPACE_BUTS, 0);
        
        WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0);
 }
index 8714e772852e6e330826467d29f0c59f38cc118b..e0915010e16087052425e41a77aa10555e654fc7 100644 (file)
@@ -253,10 +253,10 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymaps */
-       keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       keymap= WM_keymap_find(wm->defaultconf, "FileMain", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "File Browser Main", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
                                                           
 
@@ -368,7 +368,7 @@ void file_keymap(struct wmKeyConfig *keyconf)
 {
        wmKeyMapItem *kmi;
        /* keys for all areas */
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "File", SPACE_FILE, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "File Browser", SPACE_FILE, 0);
        WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "FILE_OT_bookmark_add", BKEY, KM_PRESS, KM_CTRL, 0);
@@ -380,7 +380,7 @@ void file_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0);
 
        /* keys for main area */
-       keymap= WM_keymap_find(keyconf, "FileMain", SPACE_FILE, 0);
+       keymap= WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
        WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
        kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
        RNA_boolean_set(kmi->ptr, "extend", 1);
@@ -404,7 +404,7 @@ void file_keymap(struct wmKeyConfig *keyconf)
        RNA_int_set(kmi->ptr, "increment",-100);
        
        /* keys for button area (top) */
-       keymap= WM_keymap_find(keyconf, "FileButtons", SPACE_FILE, 0);
+       keymap= WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0);
        kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
        RNA_int_set(kmi->ptr, "increment", 1);
        kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
@@ -427,7 +427,7 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
        ED_region_panels_init(wm, ar);
 
        /* own keymaps */
-       keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0); 
+       keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); 
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
@@ -463,10 +463,10 @@ static void file_ui_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
 
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "File", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       keymap= WM_keymap_find(wm->defaultconf, "FileButtons", SPACE_FILE, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index cddb19659640796f2a32786d92252c88bb2813de..5b62761ae74f0646cb764a3759bcb4787121f004 100644 (file)
@@ -363,7 +363,7 @@ void graphedit_keymap(wmKeyConfig *keyconf)
        wmKeyMap *keymap;
        
        /* keymap for all regions */
-       keymap= WM_keymap_find(keyconf, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0);
        WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0);
 
        /* channels */
@@ -373,7 +373,7 @@ void graphedit_keymap(wmKeyConfig *keyconf)
         */
        
        /* keyframes */
-       keymap= WM_keymap_find(keyconf, "GraphEdit Keys", SPACE_IPO, 0);
+       keymap= WM_keymap_find(keyconf, "Graph Editor", SPACE_IPO, 0);
        graphedit_keymap_keyframes(keyconf, keymap);
 }
 
index 8111ee8f77953e5ff32637431639902939821eec..cf99e3602dd6176dc7640088288490da5172c4b0 100644 (file)
@@ -213,9 +213,9 @@ static void graph_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Keys", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Graph Editor", SPACE_IPO, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -312,9 +312,9 @@ static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "Animation_Channels", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
-       keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -365,7 +365,7 @@ static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar)
        
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_find(wm->defaultconf, "GraphEdit Generic", SPACE_IPO, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 5b05c8f8944482d0dae214fe6ab380cc7ce2541d..d82364fed2f16a4c0229f54a7e8d4d1b586ef22b 100644 (file)
@@ -391,7 +391,7 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
        keymap= WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 
-       keymap= WM_keymap_find(wm->defaultconf, "UVEdit", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "UV Editor", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        /* own keymaps */
index c2918dd0925ac823822ea4c3e66c56400c072ef3..06e92ee5fce288e79c58d17761fe342c81ebde74 100644 (file)
@@ -188,7 +188,7 @@ void logic_operatortypes(void)
 
 void logic_keymap(struct wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "Logic Generic", SPACE_LOGIC, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "Logic Editor", SPACE_LOGIC, 0);
        
        WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0);
 }
@@ -243,7 +243,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
        /* own keymaps */
-       keymap= WM_keymap_find(wm->defaultconf, "Logic Generic", SPACE_LOGIC, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -284,7 +284,7 @@ static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_find(wm->defaultconf, "Logic Generic", SPACE_LOGIC, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
index 8f057c2d751b63a4cb8f2e9b2c6b03327752dbf8..bec3a003b1ef2c6b2cee6dc550950da682a787c4 100644 (file)
@@ -301,7 +301,7 @@ void nla_keymap(wmKeyConfig *keyconf)
        nla_keymap_channels(keyconf, keymap);
        
        /* data */
-       keymap= WM_keymap_find(keyconf, "NLA Data", SPACE_NLA, 0);
+       keymap= WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0);
        nla_keymap_main(keyconf, keymap);
 }
 
index ddab0817c588b10e3c4472fa374a097351ff9e74..b384a30de566d124b5f86f1778066b23faf0a4c9 100644 (file)
@@ -264,7 +264,7 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "NLA Data", SPACE_NLA, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "NLA Editor", SPACE_NLA, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
        keymap= WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
index 2a32ce6b65a08b4d22b0ceb6670a8fe4d7dcd03f..534ca0aa99ce035e4b41905956b798ee4a47e731 100644 (file)
@@ -98,7 +98,7 @@ void node_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0);
        
        /* Main Area only ----------------- */
-       keymap= WM_keymap_find(keyconf, "Node", SPACE_NODE, 0);
+       keymap= WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0);
        
        /* mouse select in nodes used to be both keys, but perhaps this should be reduced? 
         * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize
index 650390a8727a6e7067ef2d679084bea1acb0f9a8..dcd07690f0e9e9741fbdf23f895ee7ce5f68beb6 100644 (file)
@@ -271,7 +271,7 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar)
        keymap= WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm->defaultconf, "Node", SPACE_NODE, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Node Editor", SPACE_NODE, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index eea5891a720fd0a58719a48b06299db9ebfb11ed..eb578e093df1d9380c97ae28122d20045c2c2459 100644 (file)
@@ -187,7 +187,7 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_find(wm->defaultconf, "TimeLine", SPACE_TIME, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Timeline", SPACE_TIME, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
index 83b310dba804f9a0fbcb54813c74ae0c93f2dc94..c80f13336cb7c90c587db0db0e69b833753140e4 100644 (file)
@@ -187,7 +187,7 @@ void time_operatortypes(void)
 
 void time_keymap(wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "TimeLine", SPACE_TIME, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0);
        
        WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
index b4f3605c55906581f001d24058239ae685b38fe1..f1db3ca53fc9332ef7692b81c3e7a4e2c99bbf30 100644 (file)
@@ -340,7 +340,7 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
        keymap= WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
-       keymap= WM_keymap_find(wm->defaultconf, "EditMesh", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Mesh", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
        
        keymap= WM_keymap_find(wm->defaultconf, "Curve", 0, 0);
@@ -359,7 +359,7 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* armature sketching needs to take over mouse */
-       keymap= WM_keymap_find(wm->defaultconf, "Armature_Sketch", 0, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "Armature Sketch", 0, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        keymap= WM_keymap_find(wm->defaultconf, "Particle", 0, 0);
@@ -376,10 +376,10 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
        /* own keymap, last so modes can override it */
-       keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
-       keymap= WM_keymap_find(wm->defaultconf, "View3D", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -541,7 +541,7 @@ static void view3d_main_area_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void view3d_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0);
+       wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
@@ -582,7 +582,7 @@ static void view3d_buttons_area_init(wmWindowManager *wm, ARegion *ar)
 
        ED_region_panels_init(wm, ar);
        
-       keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
@@ -658,7 +658,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar)
        
        ED_region_panels_init(wm, ar);
 
-       keymap= WM_keymap_find(wm->defaultconf, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0);
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
index 27c062fee8c521c59eb35f11de0785af3e8484d7..4bb65ec4ed47823c3d1068c2115be617b65abcdb 100644 (file)
@@ -108,13 +108,13 @@ void view3d_keymap(wmKeyConfig *keyconf)
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
        
-       keymap= WM_keymap_find(keyconf, "View3D Generic", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0);
        
        WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0);
        
        /* only for region 3D window */
-       keymap= WM_keymap_find(keyconf, "View3D", SPACE_VIEW3D, 0);
+       keymap= WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
        
        WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
        /*
index b592d5a62f16f8668184336b0a9f0fc11e13502e..0ee6115bbfe5a2e1a21c59493a607d69be4963df 100644 (file)
@@ -3198,7 +3198,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap;
        
-       keymap= WM_keymap_find(keyconf, "UVEdit", 0, 0);
+       keymap= WM_keymap_find(keyconf, "UV Editor", 0, 0);
        keymap->poll= ED_operator_uvedit;
        
        /* pick selection */
index 1702149cf8b506a19e129efab3dc31727c4de068..8fe7ac39b353d82bf97cfee31f56b940f2503656 100644 (file)
@@ -104,17 +104,22 @@ wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, char *idname, int type
                                                                 int val, int modifier, int keymodifier);
 wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, char *idname, int type,
                                                                 int val, int modifier, int keymodifier);
+
 void         WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
 char            *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len);
 
-wmKeyMap       *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid);
 wmKeyMap       *WM_keymap_list_find(ListBase *lb, char *idname, int spaceid, int regionid);
+wmKeyMap       *WM_keymap_find(struct wmKeyConfig *keyconf, char *idname, int spaceid, int regionid);
+wmKeyMap       *WM_keymap_find_all(const struct bContext *C, char *idname, int spaceid, int regionid);
 wmKeyMap       *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap);
+wmKeyMap       *WM_keymap_guess_opname(const struct bContext *C, char *opname);
 int                     WM_keymap_user_init(struct wmWindowManager *wm, struct wmKeyMap *keymap);
 wmKeyMap       *WM_keymap_copy_to_user(struct wmKeyMap *keymap);
 void           WM_keymap_restore_to_default(struct wmKeyMap *keymap);
 void           WM_keymap_properties_reset(struct wmKeyMapItem *kmi);
 void           WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+
+wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id);
 int                    WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
 int                    WM_userdef_event_map(int kmitype);
 
@@ -124,8 +129,8 @@ wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, in
 void           WM_modalkeymap_assign(struct wmKeyMap *km, char *opname);
 
 const char     *WM_key_event_string(short type);
+int                    WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, struct wmKeyMap **keymap_r);
 char           *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
-void           WM_key_event_operator_change(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, short key, short modifier);
 
                        /* handlers */
 
index 7de7b3c45e1ca856a316433b08b4efb1fb205d60..447a7ecb92fe67c04d8518bd618eaae437414682 100644 (file)
@@ -28,7 +28,9 @@
 
 #include <string.h>
 
+#include "DNA_object_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
 
@@ -267,6 +269,33 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, char *idname, int spaceid, int re
        return km;
 }
 
+wmKeyMap *WM_keymap_find_all(const bContext *C, char *idname, int spaceid, int regionid)
+{
+       wmWindowManager *wm = CTX_wm_manager(C);
+       wmKeyConfig *keyconf;
+       wmKeyMap *km;
+       
+       /* first user defined keymaps */
+       km= WM_keymap_list_find(&U.keymaps, idname, spaceid, regionid);
+       if (km)
+               return km;
+       
+       /* then user key config */
+       keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
+       if(keyconf) {
+               km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
+               if (km)
+                       return km;
+       }
+       
+       /* then use default */
+       km= WM_keymap_list_find(&wm->defaultconf->keymaps, idname, spaceid, regionid);
+       if (km)
+               return km;
+       else
+               return NULL;
+}
+
 /* ****************** modal keymaps ************ */
 
 /* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
@@ -458,6 +487,16 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op
        return NULL;
 }
 
+int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, wmKeyMap **keymap_r)
+{
+       wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, keymap_r);
+       
+       if(kmi)
+               return kmi->id;
+       else
+               return 0;
+}
+
 int    WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
 {
        int k1type, k2type;
@@ -664,25 +703,150 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap)
        }
 }
 
-/* searches context and changes keymap item, if found */
-void WM_key_event_operator_change(const bContext *C, const char *opname, int opcontext, IDProperty *properties, short key, short modifier)
+wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       wmKeyMap *keymap;
        wmKeyMapItem *kmi;
        
-       kmi= wm_keymap_item_find(C, opname, opcontext, properties, &keymap);
+       for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
+               if (kmi->id == id)
+                       return kmi;
+       }
+       
+       return NULL;
+}
 
-       if(kmi) {
-               /* if the existing one is in a default keymap, copy it
-                  to user preferences, and lookup again so we get a
-                  key map item from the user preferences we can modify */
-               if(BLI_findindex(&wm->defaultconf->keymaps, keymap) >= 0) {
-                       WM_keymap_copy_to_user(keymap);
-                       kmi= wm_keymap_item_find(C, opname, opcontext, properties, NULL);
+/* Guess an appropriate keymap from the operator name */
+/* Needs to be kept up to date with Keymap and Operator naming */
+wmKeyMap *WM_keymap_guess_opname(const bContext *C, char *opname)
+{
+       wmKeyMap *km=NULL;
+       SpaceLink *sl = CTX_wm_space_data(C);
+       
+       /* Window */
+       if (strstr(opname, "WM_OT")) {
+               km = WM_keymap_find_all(C, "Window", 0, 0);
+       }
+       /* Screen */
+       else if (strstr(opname, "SCREEN_OT")) {
+               km = WM_keymap_find_all(C, "Screen", 0, 0);
+       }
+       /* Grease Pencil */
+       else if (strstr(opname, "GPENCIL_OT")) {
+               km = WM_keymap_find_all(C, "Grease Pencil", 0, 0);
+       }
+       /* Markers */
+       else if (strstr(opname, "MARKER_OT")) {
+               km = WM_keymap_find_all(C, "Markers", 0, 0);
+       }
+       
+       
+       /* 3D View */
+       else if (strstr(opname, "VIEW3D_OT")) {
+               km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
+       }
+       else if (strstr(opname, "OBJECT_OT")) {
+               km = WM_keymap_find_all(C, "Object Mode", 0, 0);
+       }
+       
+       /* Editing Modes */
+       else if (strstr(opname, "MESH_OT")) {
+               km = WM_keymap_find_all(C, "Mesh", 0, 0);
+       }
+       else if (strstr(opname, "CURVE_OT")) {
+               km = WM_keymap_find_all(C, "Curve", 0, 0);
+       }
+       else if (strstr(opname, "ARMATURE_OT")) {
+               km = WM_keymap_find_all(C, "Armature", 0, 0);
+       }
+       else if (strstr(opname, "POSE_OT")) {
+               km = WM_keymap_find_all(C, "Pose", 0, 0);
+       }
+       else if (strstr(opname, "SCULPT_OT")) {
+               km = WM_keymap_find_all(C, "Sculpt", 0, 0);
+       }
+       else if (strstr(opname, "MBALL_OT")) {
+               km = WM_keymap_find_all(C, "Metaball", 0, 0);
+       }
+       else if (strstr(opname, "LATTICE_OT")) {
+               km = WM_keymap_find_all(C, "Lattice", 0, 0);
+       }
+       else if (strstr(opname, "PARTICLE_OT")) {
+               km = WM_keymap_find_all(C, "Particle", 0, 0);
+       }
+       else if (strstr(opname, "FONT_OT")) {
+               km = WM_keymap_find_all(C, "Font", 0, 0);
+       }
+       else if (strstr(opname, "PAINT_OT")) {
+               
+               /* check for relevant mode */
+               switch(CTX_data_mode_enum(C)) {
+                       case OB_MODE_WEIGHT_PAINT:
+                               km = WM_keymap_find_all(C, "Weight Paint", 0, 0);
+                               break;
+                       case OB_MODE_VERTEX_PAINT:
+                               km = WM_keymap_find_all(C, "Vertex Paint", 0, 0);
+                               break;
+                       case OB_MODE_TEXTURE_PAINT:
+                               km = WM_keymap_find_all(C, "Image Paint", 0, 0);
+                               break;
                }
-
-               keymap_event_set(kmi, key, KM_PRESS, modifier, 0);
        }
+       /* Paint Face Mask */
+       else if (strstr(opname, "PAINT_OT_face_select")) {
+               km = WM_keymap_find_all(C, "Face Mask", sl->spacetype, 0);
+       }
+       /* Timeline */
+       else if (strstr(opname, "TIME_OT")) {
+               km = WM_keymap_find_all(C, "Timeline", sl->spacetype, 0);
+       }
+       /* Image Editor */
+       else if (strstr(opname, "IMAGE_OT")) {
+               km = WM_keymap_find_all(C, "Image", sl->spacetype, 0);
+       }
+       /* UV Editor */
+       else if (strstr(opname, "UV_OT")) {
+               km = WM_keymap_find_all(C, "UV Editor", sl->spacetype, 0);
+       }
+       /* Node Editor */
+       else if (strstr(opname, "NODE_OT")) {
+               km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0);
+       }
+       /* Animation Editor Channels */
+       else if (strstr(opname, "ANIM_OT_channels")) {
+               km = WM_keymap_find_all(C, "Animation Channels", sl->spacetype, 0);
+       }
+       /* Animation Generic - after channels */
+       else if (strstr(opname, "ANIM_OT")) {
+               km = WM_keymap_find_all(C, "Animation", 0, 0);
+       }
+       /* Graph Editor */
+       else if (strstr(opname, "GRAPH_OT")) {
+               km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0);
+       }
+       /* Dopesheet Editor */
+       else if (strstr(opname, "ACTION_OT")) {
+               km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0);
+       }
+       /* NLA Editor */
+       else if (strstr(opname, "NLA_OT")) {
+               km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0);
+       }
+       /* Script */
+       else if (strstr(opname, "SCRIPT_OT")) {
+               km = WM_keymap_find_all(C, "Script", sl->spacetype, 0);
+       }
+       /* Text */
+       else if (strstr(opname, "TEXT_OT")) {
+               km = WM_keymap_find_all(C, "Text", sl->spacetype, 0);
+       }
+       /* Sequencer */
+       else if (strstr(opname, "SEQUENCER_OT")) {
+               km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0);
+       }
+       /* Console */
+       else if (strstr(opname, "CONSOLE_OT")) {
+               km = WM_keymap_find_all(C, "Console", sl->spacetype, 0);
+       }
+       
+       return km;
 }
-