Merging r39050 through r39101 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 6 Aug 2011 14:52:45 +0000 (14:52 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 6 Aug 2011 14:52:45 +0000 (14:52 +0000)
35 files changed:
build_files/scons/config/darwin-config.py
intern/ghost/intern/GHOST_SystemSDL.cpp
release/scripts/startup/bl_ui/space_userpref.py
release/scripts/startup/bl_ui/space_userpref_keymap.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/intern/blender.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/curve/editfont.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/object/object_edit.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/makesrna/intern/rna_wm.c
source/blender/makesrna/intern/rna_wm_api.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_keymap.h [new file with mode: 0644]
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 00b0c6ebf00da08a10d0d34faa09a34c49451ad4..560b6d9cb60fe68a7ba7bb16a15f876ad9a57cae 100644 (file)
@@ -21,14 +21,16 @@ cmd = 'uname -p'
 MAC_PROC=commands.getoutput(cmd) 
 cmd = 'uname -r'
 cmd_res=commands.getoutput(cmd) 
-if cmd_res[0]=='7':
+if cmd_res[:2]=='7':
        MAC_CUR_VER='10.3'
-elif cmd_res[0]=='8':
+elif cmd_res[:2]=='8':
        MAC_CUR_VER='10.4'
-elif cmd_res[0]=='9':
+elif cmd_res[:2]=='9':
        MAC_CUR_VER='10.5'
-elif cmd_res[0]=='10':
+elif cmd_res[:2]=='10':
        MAC_CUR_VER='10.6'
+elif cmd_res[:2]=='11':
+       MAC_CUR_VER='10.7'
 
 if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
        USE_QTKIT=True # Carbon quicktime is not available for 64bit
@@ -37,8 +39,8 @@ if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64':
 # Default target OSX settings per architecture
 # Can be customized
 
-if MACOSX_ARCHITECTURE == 'ppc':
-# ppc release are now made for 10.4
+if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4':
+# all releases are now made for 10.5 !
 #      MAC_MIN_VERS = '10.3'
 #      MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
 #      LCGDIR = '#../lib/darwin-6.1-powerpc'
@@ -50,13 +52,21 @@ if MACOSX_ARCHITECTURE == 'ppc':
        LCGDIR = '#../lib/darwin-8.0.0-powerpc'
        CC = 'gcc-4.0'
        CXX = 'g++-4.0'
-elif MACOSX_ARCHITECTURE == 'i386':
+elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4':
        MAC_MIN_VERS = '10.4'
        MACOSX_DEPLOYMENT_TARGET = '10.4'
        MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
        LCGDIR = '#../lib/darwin-8.x.i386'
        CC = 'gcc-4.0'
        CXX = 'g++-4.0'
+elif MAC_CUR_VER >= '10.6':
+       # OSX 10.6 and 10.7 developer tools do not come with sdk < 10.6 anymore !
+       MAC_MIN_VERS = '10.6'
+       MACOSX_DEPLOYMENT_TARGET = '10.6'
+       MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk'
+       LCGDIR = '#../lib/darwin-9.x.universal'
+       CC = 'llvm-gcc-4.2'
+       CXX = 'llvm-g++-4.2'
 else :
        MAC_MIN_VERS = '10.5'
        MACOSX_DEPLOYMENT_TARGET = '10.5'
@@ -71,8 +81,8 @@ LIBDIR = '${LCGDIR}'
 ###################          Dependency settings           ##################
 #############################################################################
 
-#Defaults openMP to true if compiler (currently only gcc 4.2) handles it
-if CC == 'gcc-4.2':
+#Defaults openMP to true if compiler handles it
+if CC == 'gcc-4.2' or CC == 'llvm-gcc-4.2':
     WITH_BF_OPENMP = True  # multithreading for fluids, cloth and smoke
 else:
     WITH_BF_OPENMP = False
index 2c61acc2d931d648884787382ffd03bb40859c8a..69a9f936cf693bea950be2b365b5c3b8cdba8567 100644 (file)
@@ -180,6 +180,7 @@ convertSDLKey(SDL_Scancode key)
                GXMAP(type,SDL_SCANCODE_RCTRL,          GHOST_kKeyRightControl);
                GXMAP(type,SDL_SCANCODE_LALT,           GHOST_kKeyLeftAlt);
                GXMAP(type,SDL_SCANCODE_RALT,           GHOST_kKeyRightAlt);
+               GXMAP(type,SDL_SCANCODE_LGUI,           GHOST_kKeyOS);
                GXMAP(type,SDL_SCANCODE_RGUI,           GHOST_kKeyOS);
 
                GXMAP(type,SDL_SCANCODE_INSERT,         GHOST_kKeyInsert);
@@ -228,6 +229,7 @@ convertSDLKey(SDL_Scancode key)
         GXMAP(type,SDL_SCANCODE_AUDIONEXT,      GHOST_kKeyMediaLast);
 
                default:
+                       printf("Unknown\n");
                        type= GHOST_kKeyUnknown;
                        break;
                }
@@ -372,6 +374,7 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
        case SDL_KEYUP:
                {
                        SDL_KeyboardEvent &sdl_sub_evt= sdl_event->key;
+                       SDL_Keycode sym= sdl_sub_evt.keysym.sym;
                        GHOST_TEventType type= (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp;
 
                        GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
@@ -379,7 +382,45 @@ GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
 
                        GHOST_TKey gkey= convertSDLKey(sdl_sub_evt.keysym.scancode);
                        /* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */
-                       g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sdl_sub_evt.keysym.sym);
+                       if(sym > 127) {
+                               sym= 0;
+                       }
+                       else {
+                               if(sdl_sub_evt.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) {
+                                       /* lame US keyboard assumptions */
+                                       if(sym >= 'a' && sym <= ('a' + 32)) {
+                                               sym -= 32;
+                                       }
+                                       else {
+                                               switch(sym) {
+                                                       case '`': sym= '~'; break;
+                                                       case '1': sym= '!'; break;
+                                                       case '2': sym= '@'; break;
+                                                       case '3': sym= '#'; break;
+                                                       case '4': sym= '$'; break;
+                                                       case '5': sym= '%'; break;
+                                                       case '6': sym= '^'; break;
+                                                       case '7': sym= '&'; break;
+                                                       case '8': sym= '*'; break;
+                                                       case '9': sym= '('; break;
+                                                       case '0': sym= ')'; break;
+                                                       case '-': sym= '_'; break;
+                                                       case '=': sym= '+'; break;
+                                                       case '[': sym= '{'; break;
+                                                       case ']': sym= '}'; break;
+                                                       case '\\': sym= '|'; break;
+                                                       case ';': sym= ':'; break;
+                                                       case '\'': sym= '"'; break;
+                                                       case ',': sym= '<'; break;
+                                                       case '.': sym= '>'; break;
+                                                       case '/': sym= '?'; break;
+                                                       default:            break;
+                                               }
+                                       }
+                               }
+                       }
+
+                       g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sym);
                }
                break;
        }
index 1feb1eec0c504a242b46f3bc6cd4ac0a0ad89966..e27bd8ef07aa3d4f96d8d3cdbc774b53e7a749eb 100644 (file)
@@ -755,6 +755,31 @@ class USERPREF_PT_file(bpy.types.Panel):
 from bl_ui.space_userpref_keymap import InputKeyMapPanel
 
 
+class USERPREF_MT_ndof_settings(bpy.types.Menu):
+    # accessed from the window keybindings in C (only)
+    bl_label = "3D Mouse Settings"
+
+    def draw(self, context):
+        layout = self.layout
+        input_prefs = context.user_preferences.inputs
+
+        layout.separator()
+        layout.prop(input_prefs, "ndof_sensitivity")
+
+        if context.space_data.type == 'VIEW_3D':
+            layout.separator()
+            layout.prop(input_prefs, "ndof_show_guide")
+
+            layout.separator()
+            layout.label(text="orbit options")
+            layout.prop(input_prefs, "ndof_orbit_invert_axes")
+
+            layout.separator()
+            layout.label(text="fly options")
+            layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
+            layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
+
+
 class USERPREF_PT_input(bpy.types.Panel, InputKeyMapPanel):
     bl_space_type = 'USER_PREFERENCES'
     bl_label = "Input"
index a138d48f9ebf9e4382b6cf696b5d9aed22a51273..1622e922065751fe1b208cfeefd39c62c4ba8f34 100644 (file)
@@ -191,10 +191,10 @@ class InputKeyMapPanel:
 
         if km.is_modal:
             row.label(text="", icon='LINKED')
-        if km.is_user_defined:
+        if km.is_user_modified:
             row.operator("wm.keymap_restore", text="Restore")
         else:
-            row.operator("wm.keymap_edit", text="Edit")
+            row.label()
 
         if km.show_expanded_children:
             if children:
@@ -215,7 +215,6 @@ class InputKeyMapPanel:
                 # "Add New" at end of keymap item list
                 col = self.indented_layout(col, level + 1)
                 subcol = col.split(percentage=0.2).column()
-                subcol.enabled = km.is_user_defined
                 subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
 
             col.separator()
@@ -246,7 +245,7 @@ class InputKeyMapPanel:
 
         col = self.indented_layout(layout, level)
 
-        if km.is_user_defined:
+        if kmi.show_expanded:
             col = col.column(align=True)
             box = col.box()
         else:
@@ -259,7 +258,6 @@ class InputKeyMapPanel:
         row.prop(kmi, "show_expanded", text="", emboss=False)
 
         row = split.row()
-        row.enabled = km.is_user_defined
         row.prop(kmi, "active", text="", emboss=False)
 
         if km.is_modal:
@@ -268,7 +266,6 @@ class InputKeyMapPanel:
             row.label(text=kmi.name)
 
         row = split.row()
-        row.enabled = km.is_user_defined
         row.prop(kmi, "map_type", text="")
         if map_type == 'KEYBOARD':
             row.prop(kmi, "type", text="", full_event=True)
@@ -285,18 +282,17 @@ class InputKeyMapPanel:
         else:
             row.label()
 
-        if not kmi.is_user_defined:
+        if (not kmi.is_user_defined) and kmi.is_user_modified:
             op = row.operator("wm.keyitem_restore", text="", icon='BACK')
             op.item_id = kmi.id
-        op = row.operator("wm.keyitem_remove", text="", icon='X')
-        op.item_id = kmi.id
+        else:
+            op = row.operator("wm.keyitem_remove", text="", icon='X')
+            op.item_id = kmi.id
 
         # Expanded, additional event settings
         if kmi.show_expanded:
             box = col.box()
 
-            box.enabled = km.is_user_defined
-
             if map_type not in {'TEXTINPUT', 'TIMER'}:
                 split = box.split(percentage=0.4)
                 sub = split.row()
@@ -355,10 +351,10 @@ class InputKeyMapPanel:
                 row.label()
                 row.label()
 
-                if km.is_user_defined:
+                if km.is_user_modified:
                     row.operator("wm.keymap_restore", text="Restore")
                 else:
-                    row.operator("wm.keymap_edit", text="Edit")
+                    row.label()
 
                 for kmi in filtered_items:
                     self.draw_kmi(display_keymaps, kc, km, kmi, col, 1)
@@ -366,7 +362,6 @@ class InputKeyMapPanel:
                 # "Add New" at end of keymap item list
                 col = self.indented_layout(layout, 1)
                 subcol = col.split(percentage=0.2).column()
-                subcol.enabled = km.is_user_defined
                 subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
 
     def draw_hierarchy(self, display_keymaps, layout):
@@ -375,8 +370,7 @@ class InputKeyMapPanel:
 
     def draw_keymaps(self, context, layout):
         wm = context.window_manager
-        kc = wm.keyconfigs.active
-        defkc = wm.keyconfigs.default
+        kc = wm.keyconfigs.user
 
         col = layout.column()
         sub = col.column()
@@ -401,7 +395,7 @@ class InputKeyMapPanel:
 
         col.separator()
 
-        display_keymaps = _merge_keymaps(kc, defkc)
+        display_keymaps = _merge_keymaps(kc, kc)
         if context.space_data.filter_text != "":
             filter_text = context.space_data.filter_text.lower()
             self.draw_filtered(display_keymaps, filter_text, col)
@@ -612,7 +606,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
 
         # Generate a list of keymaps to export:
         #
-        # First add all user_defined keymaps (found in inputs.edited_keymaps list),
+        # First add all user_modified keymaps (found in keyconfigs.user.keymaps list),
         # then add all remaining keymaps from the currently active custom keyconfig.
         #
         # This will create a final list of keymaps that can be used as a 'diff' against
@@ -622,7 +616,9 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
         class FakeKeyConfig():
             keymaps = []
         edited_kc = FakeKeyConfig()
-        edited_kc.keymaps.extend(context.user_preferences.inputs.edited_keymaps)
+        for km in wm.keyconfigs.user.keymaps:
+            if km.is_user_modified:
+                edited_kc.keymaps.append(km)
         # merge edited keymaps with non-default keyconfig, if it exists
         if kc != wm.keyconfigs.default:
             export_keymaps = _merge_keymaps(edited_kc, kc)
@@ -672,17 +668,6 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
         return {'RUNNING_MODAL'}
 
 
-class WM_OT_keymap_edit(bpy.types.Operator):
-    "Edit stored key map"
-    bl_idname = "wm.keymap_edit"
-    bl_label = "Edit Key Map"
-
-    def execute(self, context):
-        km = context.keymap
-        km.copy_to_user()
-        return {'FINISHED'}
-
-
 class WM_OT_keymap_restore(bpy.types.Operator):
     "Restore key map(s)"
     bl_idname = "wm.keymap_restore"
@@ -694,7 +679,7 @@ class WM_OT_keymap_restore(bpy.types.Operator):
         wm = context.window_manager
 
         if self.all:
-            for km in wm.keyconfigs.default.keymaps:
+            for km in wm.keyconfigs.user.keymaps:
                 km.restore_to_default()
         else:
             km = context.keymap
@@ -713,13 +698,13 @@ class WM_OT_keyitem_restore(bpy.types.Operator):
     @classmethod
     def poll(cls, context):
         keymap = getattr(context, "keymap", None)
-        return keymap and keymap.is_user_defined
+        return keymap
 
     def execute(self, context):
         km = context.keymap
         kmi = km.keymap_items.from_id(self.item_id)
 
-        if not kmi.is_user_defined:
+        if (not kmi.is_user_defined) and kmi.is_user_modified:
             km.restore_item_to_default(kmi)
 
         return {'FINISHED'}
@@ -756,7 +741,7 @@ class WM_OT_keyitem_remove(bpy.types.Operator):
 
     @classmethod
     def poll(cls, context):
-        return hasattr(context, "keymap") and context.keymap.is_user_defined
+        return hasattr(context, "keymap")
 
     def execute(self, context):
         km = context.keymap
index a180da1556396461779e38b831950ffeb5411c8e..001151a6709878b6dd10391ca94cf6af5ef96686 100644 (file)
@@ -349,30 +349,6 @@ class VIEW3D_MT_view_navigation(bpy.types.Menu):
         layout.operator("view3d.fly")
 
 
-class VIEW3D_MT_ndof_settings(bpy.types.Menu):
-    bl_label = "3D Mouse Settings"
-
-    def draw(self, context):
-        layout = self.layout
-        input_prefs = context.user_preferences.inputs
-
-        layout.separator()
-        layout.prop(input_prefs, "ndof_sensitivity")
-
-        if context.space_data.type == 'VIEW_3D':
-            layout.separator()
-            layout.prop(input_prefs, "ndof_show_guide")
-
-            layout.separator()
-            layout.label(text="orbit options")
-            layout.prop(input_prefs, "ndof_orbit_invert_axes")
-
-            layout.separator()
-            layout.label(text="fly options")
-            layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
-            layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
-
-
 class VIEW3D_MT_view_align(bpy.types.Menu):
     bl_label = "Align View"
 
index 91cfd22b3d654c6a2609e79a03f6842538529430..85dd6f7da5e190d5613be932aa1eaafddcb06e9a 100644 (file)
@@ -88,8 +88,9 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel):
 
             col = layout.column(align=True)
             col.label(text="Shading:")
-            col.operator("object.shade_smooth", text="Smooth")
-            col.operator("object.shade_flat", text="Flat")
+            row = col.row(align=True)
+            row.operator("object.shade_smooth", text="Smooth")
+            row.operator("object.shade_flat", text="Flat")
 
         draw_keyframing_tools(context, layout)
 
@@ -155,8 +156,9 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel):
 
         col = layout.column(align=True)
         col.label(text="Shading:")
-        col.operator("mesh.faces_shade_smooth", text="Smooth")
-        col.operator("mesh.faces_shade_flat", text="Flat")
+        row = col.row(align=True)
+        row.operator("mesh.faces_shade_smooth", text="Smooth")
+        row.operator("mesh.faces_shade_flat", text="Flat")
 
         draw_repeat_tools(context, layout)
 
index f50affc1bb5f9013cea20eb4856c7184795dd7c4..4085ce1da76f0c4ca1343940b4ec1341913921da 100644 (file)
@@ -332,28 +332,45 @@ static int handle_subversion_warning(Main *main)
        return 1;
 }
 
+static void keymap_item_free(wmKeyMapItem *kmi)
+{
+       if(kmi->properties) {
+               IDP_FreeProperty(kmi->properties);
+               MEM_freeN(kmi->properties);
+       }
+       if(kmi->ptr)
+               MEM_freeN(kmi->ptr);
+}
+
 void BKE_userdef_free(void)
 {
        wmKeyMap *km;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
 
-       for(km=U.keymaps.first; km; km=km->next) {
-               for(kmi=km->items.first; kmi; kmi=kmi->next) {
-                       if(kmi->properties) {
-                               IDP_FreeProperty(kmi->properties);
-                               MEM_freeN(kmi->properties);
+       for(km=U.user_keymaps.first; km; km=km->next) {
+               for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       if(kmdi->add_item) {
+                               keymap_item_free(kmdi->add_item);
+                               MEM_freeN(kmdi->add_item);
+                       }
+                       if(kmdi->remove_item) {
+                               keymap_item_free(kmdi->remove_item);
+                               MEM_freeN(kmdi->remove_item);
                        }
-                       if(kmi->ptr)
-                               MEM_freeN(kmi->ptr);
                }
 
+               for(kmi=km->items.first; kmi; kmi=kmi->next)
+                       keymap_item_free(kmi);
+
+               BLI_freelistN(&km->diff_items);
                BLI_freelistN(&km->items);
        }
        
        BLI_freelistN(&U.uistyles);
        BLI_freelistN(&U.uifonts);
        BLI_freelistN(&U.themes);
-       BLI_freelistN(&U.keymaps);
+       BLI_freelistN(&U.user_keymaps);
        BLI_freelistN(&U.addons);
 }
 
index 4a1441cf1d57fd90794f64ae9bdaeb09e3f33be7..a25f2ebda26f1a2f5f36cad9386280e651f039b7 100644 (file)
@@ -4769,6 +4769,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
 
        wm->keyconfigs.first= wm->keyconfigs.last= NULL;
        wm->defaultconf= NULL;
+       wm->addonconf= NULL;
+       wm->userconf= NULL;
 
        wm->jobs.first= wm->jobs.last= NULL;
        wm->drags.first= wm->drags.last= NULL;
@@ -11913,33 +11915,57 @@ static void lib_link_all(FileData *fd, Main *main)
        lib_link_library(fd, main);             /* only init users */
 }
 
+static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
+{
+       kmi->properties= newdataadr(fd, kmi->properties);
+       if(kmi->properties)
+               IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+       kmi->ptr= NULL;
+       kmi->flag &= ~KMI_UPDATE;
+}
 
 static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
 {
        UserDef *user;
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
 
        bfd->user= user= read_struct(fd, bhead, "user def");
 
        /* read all data into fd->datamap */
        bhead= read_data_into_oldnewmap(fd, bhead, "user def");
 
+       if(user->keymaps.first) {
+               /* backwards compatibility */
+               user->user_keymaps= user->keymaps;
+               user->keymaps.first= user->keymaps.last= NULL;
+       }
+
        link_list(fd, &user->themes);
-       link_list(fd, &user->keymaps);
+       link_list(fd, &user->user_keymaps);
        link_list(fd, &user->addons);
 
-       for(keymap=user->keymaps.first; keymap; keymap=keymap->next) {
+       for(keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
                keymap->modal_items= NULL;
                keymap->poll= NULL;
+               keymap->flag &= ~KEYMAP_UPDATE;
 
+               link_list(fd, &keymap->diff_items);
                link_list(fd, &keymap->items);
-               for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
-                       kmi->properties= newdataadr(fd, kmi->properties);
-                       if(kmi->properties)
-                               IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-                       kmi->ptr= NULL;
+               
+               for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       kmdi->remove_item= newdataadr(fd, kmdi->remove_item);
+                       kmdi->add_item= newdataadr(fd, kmdi->add_item);
+
+                       if(kmdi->remove_item)
+                               direct_link_keymapitem(fd, kmdi->remove_item);
+                       if(kmdi->add_item)
+                               direct_link_keymapitem(fd, kmdi->add_item);
                }
+
+               for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+                       direct_link_keymapitem(fd, kmi);
        }
 
        // XXX
index 560f715d94938ce1b144a446a790ef94272208ba..d85cf69d3f76429102b8986aaf8f7bd99d6c890a 100644 (file)
@@ -718,11 +718,19 @@ static void write_renderinfo(WriteData *wd, Main *mainvar)                /* for renderdeamon
        }
 }
 
+static void write_keymapitem(WriteData *wd, wmKeyMapItem *kmi)
+{
+       writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
+       if(kmi->properties)
+               IDP_WriteProperty(kmi->properties, wd);
+}
+
 static void write_userdef(WriteData *wd)
 {
        bTheme *btheme;
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
        bAddon *bext;
        uiStyle *style;
        
@@ -731,15 +739,19 @@ static void write_userdef(WriteData *wd)
        for(btheme= U.themes.first; btheme; btheme=btheme->next)
                writestruct(wd, DATA, "bTheme", 1, btheme);
 
-       for(keymap= U.keymaps.first; keymap; keymap=keymap->next) {
+       for(keymap= U.user_keymaps.first; keymap; keymap=keymap->next) {
                writestruct(wd, DATA, "wmKeyMap", 1, keymap);
 
-               for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
-                       writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
-
-                       if(kmi->properties)
-                               IDP_WriteProperty(kmi->properties, wd);
+               for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       writestruct(wd, DATA, "wmKeyMapDiffItem", 1, kmdi);
+                       if(kmdi->remove_item)
+                               write_keymapitem(wd, kmdi->remove_item);
+                       if(kmdi->add_item)
+                               write_keymapitem(wd, kmdi->add_item);
                }
+
+               for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+                       write_keymapitem(wd, kmi);
        }
 
        for(bext= U.addons.first; bext; bext=bext->next)
index 649ff9e953a7d6d5dd1842e432c4e8322d278c36..6c95df53d3988666dc7485bb4db9222c914b9a4c 100644 (file)
@@ -1649,10 +1649,10 @@ static int open_exec(bContext *C, wmOperator *op)
        VFont *font;
        PropertyPointerRNA *pprop;
        PointerRNA idptr;
-       char str[FILE_MAX];
-       RNA_string_get(op->ptr, "filepath", str);
+       char filepath[FILE_MAX];
+       RNA_string_get(op->ptr, "filepath", filepath);
 
-       font = load_vfont(str);
+       font= load_vfont(filepath);
 
        if(!font) {
                if(op->customdata) MEM_freeN(op->customdata);
index 314e1e8feed02aad7d8f7fefc187c24a39e62a4b..c081b839066c4929653a471be657e142ecaa31c2 100644 (file)
@@ -164,6 +164,9 @@ typedef struct uiLayout uiLayout;
 /* scale fixed button widths by this to account for DPI
  * 8.4852 == sqrtf(72.0f)) */
 #define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f)
+#define UI_DPI_ICON_FAC (((float)U.dpi) / 72.0f)
+/* 16 to copy ICON_DEFAULT_HEIGHT */
+#define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_ICON_FAC)
 
 /* Button types, bits stored in 1 value... and a short even!
 - bits 0-4:  bitnr (0-31)
index 237db58f36896da689e07d421000fa375b9f7178..940de7265df9a66698cebf0d6400e2e86da9da12 100644 (file)
@@ -1301,7 +1301,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
        else if(ELEM(but->type, TEX, SEARCH_MENU)) {
                startx += 5;
                if (but->flag & UI_HAS_ICON)
-                       startx += 16;
+                       startx += UI_DPI_ICON_SIZE;
        }
        
        /* mouse dragged outside the widget to the left */
@@ -4161,7 +4161,6 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
                
                /* complex code to change name of button */
                if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
-                       wmKeyMap *km= NULL;
                        char *butstr_orig;
 
                        // XXX but->str changed... should not, remove the hotkey from it
@@ -4174,10 +4173,6 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
                        but->str= but->strdata;
 
                        ui_check_but(but);
-
-                       /* set the keymap editable else the key wont save */
-                       WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
-                       WM_keymap_copy_to_user(km);
                }
                else {
                        /* shortcut was removed */
@@ -4189,6 +4184,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
 
 static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
 {
+       wmWindowManager *wm= CTX_wm_manager(C);
        uiBlock *block;
        uiBut *but = (uiBut *)arg;
        wmKeyMap *km;
@@ -4201,7 +4197,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
 
        kmi = WM_keymap_item_find_id(km, kmi_id);
        
-       RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr);
+       RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
        
        block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
        uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
@@ -4220,6 +4216,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
 
 static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
 {
+       wmWindowManager *wm= CTX_wm_manager(C);
        uiBlock *block;
        uiBut *but = (uiBut *)arg;
        wmKeyMap *km;
@@ -4228,19 +4225,25 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
        uiLayout *layout;
        uiStyle *style= U.uistyles.first;
        IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+       int kmi_id;
        
        /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
        km = WM_keymap_guess_opname(C, but->optype->idname);            
        kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0);
+       kmi_id = kmi->id;
 
-       if (prop) {
+       /* copy properties, prop can be NULL for reset */       
+       if(prop)
                prop= IDP_CopyProperty(prop);
-       }
-
-       /* prop can be NULL */  
        WM_keymap_properties_reset(kmi, prop);
 
-       RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr);
+       /* update and get pointers again */
+       WM_keyconfig_update(wm);
+
+       km = WM_keymap_guess_opname(C, but->optype->idname);            
+       kmi = WM_keymap_item_find_id(km, kmi_id);
+
+       RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
 
        block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
        uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
index 3bf2a9ddd02426381643b450a7df2b3e75ac1dd5..412c0233c352f36dd54b6bb4c43f2c0d4650ba6a 100644 (file)
@@ -742,6 +742,7 @@ static DrawInfo *icon_create_drawinfo(void)
        return di;
 }
 
+/* note!, returns unscaled by DPI, may need to multiply result by UI_DPI_ICON_FAC */
 int UI_icon_get_width(int icon_id)
 {
        Icon *icon = NULL;
@@ -952,7 +953,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
        Icon *icon = NULL;
        DrawInfo *di = NULL;
        IconImage *iimg;
-       float fdraw_size= UI_DPI_FAC*draw_size;
+       float fdraw_size= UI_DPI_ICON_FAC*draw_size;
        int w, h;
        
        icon = BKE_icon_get(icon_id);
index 5f2a757d2e36732392acdc5847753c8da83e2c13..8d4b42091207f9c6b705249bf5d31ae60efd03db 100644 (file)
@@ -149,9 +149,9 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
        int xofs=0, yofs;
        
        uiStyleFontSet(fs);
-       
-       height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
-       yofs= floor( 0.5f*(rect->ymax - rect->ymin - height));
+
+       height= BLF_ascender(fs->uifont_id);
+       yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
 
        if(fs->align==UI_STYLE_TEXT_CENTER) {
                xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
@@ -206,9 +206,9 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
 
        uiStyleFontSet(fs);
 
-       height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
+       height= BLF_ascender(fs->uifont_id);
        /* becomes x-offset when rotated */
-       xofs= floor( 0.5f*(rect->ymax - rect->ymin - height)) + 1;
+       xofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
 
        /* ignore UI_STYLE, always aligned to top */
 
index bccedbe60fc3cd81e4f17e6a11b08894a43a28a9..214cdb9ac21733c4f81f085ece342775e7c39be9 100644 (file)
@@ -771,7 +771,6 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
 
 
 /* icons have been standardized... and this call draws in untransformed coordinates */
-#define ICON_HEIGHT            UI_DPI_FAC*16.0f
 
 static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
 {
@@ -791,15 +790,15 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
        if(aspect != but->aspect) {
                /* prevent scaling up icon in pupmenu */
                if (aspect < 1.0f) {                    
-                       height= ICON_HEIGHT;
+                       height= UI_DPI_ICON_SIZE;
                        aspect = 1.0f;
                        
                }
                else 
-                       height= ICON_HEIGHT/aspect;
+                       height= UI_DPI_ICON_SIZE/aspect;
        }
        else
-               height= ICON_HEIGHT;
+               height= UI_DPI_ICON_SIZE;
        
        /* calculate blend color */
        if ELEM4(but->type, TOG, ROW, TOGN, LISTROW) {
@@ -866,7 +865,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
        int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10;
        int okwidth= rect->xmax-rect->xmin - border;
        
-       if (but->flag & UI_HAS_ICON) okwidth -= 16;
+       if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
        
        /* need to set this first */
        uiStyleFontSet(fstyle);
@@ -1149,7 +1148,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
                if (but->flag & UI_HAS_ICON) {
                        widget_draw_icon(but, but->icon+but->iconadd, 1.0f, rect);
                        
-                       rect->xmin += UI_icon_get_width(but->icon+but->iconadd);
+                       rect->xmin += (int)((float)UI_icon_get_width(but->icon+but->iconadd) * UI_DPI_ICON_FAC);
                        
                        if(but->editstr || (but->flag & UI_TEXT_LEFT)) 
                                rect->xmin += 5;
@@ -3137,7 +3136,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
        
        /* text location offset */
        rect->xmin+=5;
-       if(iconid) rect->xmin+= ICON_HEIGHT;
+       if(iconid) rect->xmin+= UI_DPI_ICON_SIZE;
 
        /* cut string in 2 parts? */
        cpoin= strchr(name, '|');
@@ -3162,7 +3161,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
 
        if(iconid) {
                int xs= rect->xmin+4;
-               int ys= 1 + (rect->ymin+rect->ymax- ICON_HEIGHT)/2;
+               int ys= 1 + (rect->ymin+rect->ymax- UI_DPI_ICON_SIZE)/2;
                glEnable(GL_BLEND);
                UI_icon_draw_aspect(xs, ys, iconid, 1.2f, 0.5f); /* XXX scale weak get from fstyle? */
                glDisable(GL_BLEND);
index bc179d584aba39f86ac73ec02a4ef11de4a91523..aeacdac5d141eaed557c178af9324bb7a7cc3856 100644 (file)
@@ -1463,7 +1463,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
                wmKeyMap *km;
                
-               for(km=U.keymaps.first; km; km=km->next) {
+               for(km=U.user_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)
index 395705dc029c8b501d156d2cfaf79438cc16a707..c8d3821853348b36a97f3c9e5627b6886e849b1e 100644 (file)
@@ -1049,109 +1049,6 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob)
        }
 }
 
-static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *ob)
-{
-       Base *base;
-       int i, event;
-       char str[512];
-       const char *errorstr= NULL;
-
-       strcpy(str, "Copy Modifiers %t");
-
-       sprintf(str+strlen(str), "|All%%x%d|%%l", NUM_MODIFIER_TYPES);
-
-       for (i=eModifierType_None+1; i<NUM_MODIFIER_TYPES; i++) {
-               ModifierTypeInfo *mti = modifierType_getInfo(i);
-
-               if(ELEM3(i, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance)) continue;
-               
-               if(i == eModifierType_Collision)
-                       continue;
-
-               if (    (mti->flags&eModifierTypeFlag_AcceptsCVs) || 
-                               (ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) {
-                       sprintf(str+strlen(str), "|%s%%x%d", mti->name, i);
-               }
-       }
-
-       event = pupmenu(str);
-       if(event<=0) return;
-
-       for (base= FIRSTBASE; base; base= base->next) {
-               if(base->object != ob) {
-                       if(TESTBASELIB(v3d, base)) {
-
-                               base->object->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
-
-                               if (base->object->type==ob->type) {
-                                       /* copy all */
-                                       if (event==NUM_MODIFIER_TYPES) {
-                                               ModifierData *md;
-                                               object_free_modifiers(base->object);
-
-                                               for (md=ob->modifiers.first; md; md=md->next) {
-                                                       ModifierData *nmd = NULL;
-                                                       
-                                                       if(ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance)) continue;
-               
-                                                       if(md->type == eModifierType_Collision)
-                                                               continue;
-                                                       
-                                                       nmd = modifier_new(md->type);
-                                                       modifier_copyData(md, nmd);
-                                                       BLI_addtail(&base->object->modifiers, nmd);
-                                                       modifier_unique_name(&base->object->modifiers, nmd);
-                                               }
-
-                                               copy_object_particlesystems(base->object, ob);
-                                               copy_object_softbody(base->object, ob);
-                                       } else {
-                                               /* copy specific types */
-                                               ModifierData *md, *mdn;
-                                               
-                                               /* remove all with type 'event' */
-                                               for (md=base->object->modifiers.first; md; md=mdn) {
-                                                       mdn= md->next;
-                                                       if(md->type==event) {
-                                                               BLI_remlink(&base->object->modifiers, md);
-                                                               modifier_free(md);
-                                                       }
-                                               }
-                                               
-                                               /* copy all with type 'event' */
-                                               for (md=ob->modifiers.first; md; md=md->next) {
-                                                       if (md->type==event) {
-                                                               
-                                                               mdn = modifier_new(event);
-                                                               BLI_addtail(&base->object->modifiers, mdn);
-                                                               modifier_unique_name(&base->object->modifiers, mdn);
-
-                                                               modifier_copyData(md, mdn);
-                                                       }
-                                               }
-
-                                               if(event == eModifierType_ParticleSystem) {
-                                                       object_free_particlesystems(base->object);
-                                                       copy_object_particlesystems(base->object, ob);
-                                               }
-                                               else if(event == eModifierType_Softbody) {
-                                                       object_free_softbody(base->object);
-                                                       copy_object_softbody(base->object, ob);
-                                               }
-                                       }
-                               }
-                               else
-                                       errorstr= "Did not copy modifiers to other Object types";
-                       }
-               }
-       }
-       
-//     if(errorstr) notice(errorstr);
-       
-       DAG_scene_sort(bmain, scene);
-       
-}
-
 /* both pointers should exist */
 static void copy_texture_space(Object *to, Object *ob)
 {
@@ -1196,6 +1093,7 @@ static void copy_texture_space(Object *to, Object *ob)
        
 }
 
+/* UNUSED, keep incase we want to copy functionality for use elsewhere */
 static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
 {
        Object *ob;
@@ -1221,7 +1119,8 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
                return;
        }
        else if(event==24) {
-               copymenu_modifiers(bmain, scene, v3d, ob);
+               /* moved to object_link_modifiers */
+               /* copymenu_modifiers(bmain, scene, v3d, ob); */
                return;
        }
 
index 6d64a15e9028b820fc666a29f1f253b6fda81531..b8d44bc798b2d3abc2320dfe6828dbb77fd51545 100644 (file)
@@ -347,7 +347,8 @@ typedef struct UserDef {
        struct ListBase themes;
        struct ListBase uifonts;
        struct ListBase uistyles;
-       struct ListBase keymaps;
+       struct ListBase keymaps;                /* deprecated in favor of user_keymaps */
+       struct ListBase user_keymaps;
        struct ListBase addons;
        char keyconfigstr[64];
        
index 31e59f18626a61a57fdb65d7e677d8239dc348ad..1f0ae28a00d8a63f48ce8c2a0aedf871aed21564 100644 (file)
@@ -144,7 +144,9 @@ typedef struct wmWindowManager {
        ListBase drags;                 /* active dragged items */
        
        ListBase keyconfigs;                            /* known key configurations */
-       struct wmKeyConfig *defaultconf;        /* default configuration, not saved */
+       struct wmKeyConfig *defaultconf;        /* default configuration */
+       struct wmKeyConfig *addonconf;          /* addon configuration */
+       struct wmKeyConfig *userconf;           /* user configuration */
 
        ListBase timers;                                        /* active timers */
        struct wmTimer *autosavetimer;          /* timer for auto save */
@@ -239,15 +241,26 @@ typedef struct wmKeyMapItem {
        struct PointerRNA *ptr;                 /* rna pointer to access properties */
 } wmKeyMapItem;
 
+/* used instead of wmKeyMapItem for diff keymaps */
+typedef struct wmKeyMapDiffItem {
+       struct wmKeyMapDiffItem *next, *prev;
+
+       wmKeyMapItem *remove_item;
+       wmKeyMapItem *add_item;
+} wmKeyMapDiffItem;
+
 /* wmKeyMapItem.flag */
-#define KMI_INACTIVE   1
-#define KMI_EXPANDED   2
+#define KMI_INACTIVE           1
+#define KMI_EXPANDED           2
+#define KMI_USER_MODIFIED      4
+#define KMI_UPDATE                     8
 
 /* stored in WM, the actively used keymaps */
 typedef struct wmKeyMap {
        struct wmKeyMap *next, *prev;
        
        ListBase items;
+       ListBase diff_items;
        
        char idname[64];        /* global editor keymaps, or for more per space/region */
        short spaceid;          /* same IDs as in DNA_space_types.h */
@@ -263,9 +276,12 @@ typedef struct wmKeyMap {
 
 /* wmKeyMap.flag */
 #define KEYMAP_MODAL                           1       /* modal map, not using operatornames */
-#define KEYMAP_USER                                    2       /* user created keymap */
+#define KEYMAP_USER                                    2       /* user keymap */
 #define KEYMAP_EXPANDED                                4
 #define KEYMAP_CHILDREN_EXPANDED       8
+#define KEYMAP_DIFF                                    16      /* diff keymap for user preferences */
+#define KEYMAP_USER_MODIFIED           32      /* keymap has user modifications */
+#define KEYMAP_UPDATE                          64
 
 typedef struct wmKeyConfig {
        struct wmKeyConfig *next, *prev;
index 1676a7705142a46c2db646b7065f4f2fc4c81da7..14df6cc57020ff7474687f9c1c48a2b19f2ca344 100644 (file)
@@ -240,9 +240,12 @@ void RNA_api_image(struct StructRNA *srna);
 void RNA_api_operator(struct StructRNA *srna);
 void RNA_api_macro(struct StructRNA *srna);
 void RNA_api_keyconfig(struct StructRNA *srna);
+void RNA_api_keyconfigs(struct StructRNA *srna);
 void RNA_api_keyingset(struct StructRNA *srna);
 void RNA_api_keymap(struct StructRNA *srna);
+void RNA_api_keymaps(struct StructRNA *srna);
 void RNA_api_keymapitem(struct StructRNA *srna);
+void RNA_api_keymapitems(struct StructRNA *srna);
 void RNA_api_area(struct StructRNA *srna);
 void RNA_api_main(struct StructRNA *srna);
 void RNA_api_material(StructRNA *srna);
index 6a169a482fb0bc1604c80f3bcb28c9cd02aba3ea..4570bcf7731d61ac2cdfa254b0a50fd3d374e08d 100644 (file)
@@ -1418,7 +1418,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
        prop= RNA_def_property(srna, "layers_zmask", PROP_BOOLEAN, PROP_LAYER);
        RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1);
        RNA_def_property_array(prop, 20);
-       RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers");
+       RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers for solid faces");
        if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
index c1f12e5ad969228c620054e72a013931f85a0a66..bda5f99aad49665f74f9ae53f02e5be573f77b77 100644 (file)
@@ -2878,12 +2878,6 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_range(prop, 0, 32);
        RNA_def_property_ui_text(prop, "Wheel Scroll Lines", "The number of lines scrolled at a time with the mouse wheel");
        
-       /* U.keymaps - custom keymaps that have been edited from default configs */
-       prop= RNA_def_property(srna, "edited_keymaps", PROP_COLLECTION, PROP_NONE);
-       RNA_def_property_collection_sdna(prop, NULL, "keymaps", NULL);
-       RNA_def_property_struct_type(prop, "KeyMap");
-       RNA_def_property_ui_text(prop, "Edited Keymaps", "");
-       
        prop= RNA_def_property(srna, "active_keyconfig", PROP_STRING, PROP_DIRPATH);
        RNA_def_property_string_sdna(prop, NULL, "keyconfigstr");
        RNA_def_property_ui_text(prop, "Key Config", "The name of the active key configuration");
index a046be59ab512739bbb29c6f63f0ed85a249d9fa..307cf0e175add145871a4bbf490ec584328f7f9b 100644 (file)
@@ -578,22 +578,6 @@ static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA
        wmKeyConfig *kc;
        wmKeyMap *km;
 
-       /* check user keymaps */
-       for(km=U.keymaps.first; km; km=km->next) {
-               wmKeyMapItem *kmi;
-               for (kmi=km->items.first; kmi; kmi=kmi->next) {
-                       if (kmi == ptr->data) {
-                               if (!km->modal_items) {
-                                       if (!WM_keymap_user_init(wm, km)) {
-                                               return keymap_propvalue_items; /* ERROR */
-                                       }
-                               }
-
-                               return km->modal_items;
-                       }
-               }
-       }
-
        for(kc=wm->keyconfigs.first; kc; kc=kc->next) {
                for(km=kc->keymaps.first; km; km=km->next) {
                        /* only check if it's a modal keymap */
@@ -654,12 +638,13 @@ static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
 }
 
-static void rna_WindowManager_active_keyconfig_set(PointerRNA *UNUSED(ptr), PointerRNA value)
+static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
 {
+       wmWindowManager *wm= ptr->data;
        wmKeyConfig *kc= value.data;
 
        if(kc)
-               BLI_strncpy(U.keyconfigstr, kc->idname, sizeof(U.keyconfigstr));
+               WM_keyconfig_set_active(wm, kc->idname);
 }
 
 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
@@ -1130,93 +1115,6 @@ static StructRNA* rna_MacroOperator_refine(PointerRNA *opr)
        return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Macro;
 }
 
-static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
-{
-//     wmWindowManager *wm = CTX_wm_manager(C);
-       char idname_bl[OP_MAX_TYPENAME];
-       int modifier= 0;
-
-       /* only on non-modal maps */
-       if (km->flag & KEYMAP_MODAL) {
-               BKE_report(reports, RPT_ERROR, "Not a non-modal keymap.");
-               return NULL;
-       }
-
-       WM_operator_bl_idname(idname_bl, idname);
-
-       if(shift) modifier |= KM_SHIFT;
-       if(ctrl) modifier |= KM_CTRL;
-       if(alt) modifier |= KM_ALT;
-       if(oskey) modifier |= KM_OSKEY;
-
-       if(any) modifier = KM_ANY;
-
-       return WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
-}
-
-static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, bContext *C, ReportList *reports, const char *propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
-{
-       wmWindowManager *wm = CTX_wm_manager(C);
-       int modifier= 0;
-       int propvalue = 0;
-
-       /* only modal maps */
-       if ((km->flag & KEYMAP_MODAL) == 0) {
-               BKE_report(reports, RPT_ERROR, "Not a modal keymap.");
-               return NULL;
-       }
-
-       if (!km->modal_items) {
-               if(!WM_keymap_user_init(wm, km)) {
-                       BKE_report(reports, RPT_ERROR, "User defined keymap doesn't correspond to a system keymap.");
-                       return NULL;
-               }
-       }
-
-       if (!km->modal_items) {
-               BKE_report(reports, RPT_ERROR, "No property values defined.");
-               return NULL;
-       }
-
-
-       if(RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue)==0) {
-               BKE_report(reports, RPT_WARNING, "Property value not in enumeration.");
-       }
-
-       if(shift) modifier |= KM_SHIFT;
-       if(ctrl) modifier |= KM_CTRL;
-       if(alt) modifier |= KM_ALT;
-       if(oskey) modifier |= KM_OSKEY;
-
-       if(any) modifier = KM_ANY;
-
-       return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
-}
-
-static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal)
-{
-       if (modal == 0) {
-               return WM_keymap_find(keyconf, idname, spaceid, regionid);
-       } else {
-               return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
-       }
-}
-
-static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
-{
-       return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
-}
-
-static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char *idname)
-{
-       wmOperatorType *ot = WM_operatortype_find(idname, 0);
-
-       if (!ot)
-               return NULL;
-       else
-               return ot->modalkeymap;
-}
-
 /* just to work around 'const char *' warning and to ensure this is a python op */
 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
 {
@@ -1242,6 +1140,12 @@ static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
        else            assert(!"setting the bl_description on a non-builtin operator");
 }
 
+static void rna_KeyMapItem_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       wmKeyMapItem *kmi= ptr->data;
+       WM_keyconfig_update_tag(NULL, kmi);
+}
+
 #else /* RNA_RUNTIME */
 
 static void rna_def_operator(BlenderRNA *brna)
@@ -1566,9 +1470,6 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
        StructRNA *srna;
        PropertyRNA *prop;
 
-       FunctionRNA *func;
-       PropertyRNA *parm;
-
        RNA_def_property_srna(cprop, "KeyConfigurations");
        srna= RNA_def_struct(brna, "KeyConfigurations", NULL);
        RNA_def_struct_sdna(srna, "wmWindowManager");
@@ -1578,23 +1479,24 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_property_struct_type(prop, "KeyConfig");
        RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get", "rna_WindowManager_active_keyconfig_set", NULL, NULL);
        RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Active KeyConfig", "Active wm KeyConfig");
+       RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
        
        prop= RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
        RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
        RNA_def_property_struct_type(prop, "KeyConfig");
-       RNA_def_property_ui_text(prop, "Default Key Configuration", "");
+       RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
+
+       prop= RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
+       RNA_def_property_pointer_sdna(prop, NULL, "addonconf");
+       RNA_def_property_struct_type(prop, "KeyConfig");
+       RNA_def_property_ui_text(prop, "Addon Key Configuration", "Key configuration that can be extended by addons, and is added to the active configuration when handling events");
+
+       prop= RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
+       RNA_def_property_pointer_sdna(prop, NULL, "userconf");
+       RNA_def_property_struct_type(prop, "KeyConfig");
+       RNA_def_property_ui_text(prop, "User Key Configuration", "Final key configuration that combines keymaps from the active and addon configurations, and can be edited by the user");
        
-       /* funcs */
-       func= RNA_def_function(srna, "new", "WM_keyconfig_new_user"); // add_keyconfig
-       parm= RNA_def_string(func, "name", "", 0, "Name", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration.");
-       RNA_def_function_return(func, parm);
-
-       func= RNA_def_function(srna, "remove", "WM_keyconfig_remove"); // remove_keyconfig
-       parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration.");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_api_keyconfigs(srna);
 }
 
 static void rna_def_windowmanager(BlenderRNA *brna)
@@ -1631,107 +1533,30 @@ static void rna_def_windowmanager(BlenderRNA *brna)
 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
 {
        StructRNA *srna;
-//     PropertyRNA *prop;
-
-       FunctionRNA *func;
-       PropertyRNA *parm;
        
        RNA_def_property_srna(cprop, "KeyMapItems");
        srna= RNA_def_struct(brna, "KeyMapItems", NULL);
        RNA_def_struct_sdna(srna, "wmKeyMap");
        RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
 
-       func= RNA_def_function(srna, "new", "rna_KeyMap_item_new");
-       RNA_def_function_flag(func, FUNC_USE_REPORTS);
-       parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_boolean(func, "any", 0, "Any", "");
-       RNA_def_boolean(func, "shift", 0, "Shift", "");
-       RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
-       RNA_def_boolean(func, "alt", 0, "Alt", "");
-       RNA_def_boolean(func, "oskey", 0, "OS Key", "");
-       RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
-       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
-       RNA_def_function_return(func, parm);
-
-       func= RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
-       RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
-       parm= RNA_def_string(func, "propvalue", "", 0, "Property Value", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_boolean(func, "any", 0, "Any", "");
-       RNA_def_boolean(func, "shift", 0, "Shift", "");
-       RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
-       RNA_def_boolean(func, "alt", 0, "Alt", "");
-       RNA_def_boolean(func, "oskey", 0, "OS Key", "");
-       RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
-       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
-       RNA_def_function_return(func, parm);
-       
-       func= RNA_def_function(srna, "remove", "WM_keymap_remove_item");
-       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-
-       func= RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
-       parm= RNA_def_property(func, "id", PROP_INT, PROP_NONE);
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_property_ui_text(parm, "id", "ID of the item");
-       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
-       RNA_def_function_return(func, parm);
-       
+       RNA_api_keymapitems(srna);
 }
 
 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
 {
        StructRNA *srna;
-       //PropertyRNA *prop;
-
-       FunctionRNA *func;
-       PropertyRNA *parm;
-
 
        RNA_def_property_srna(cprop, "KeyMaps");
        srna= RNA_def_struct(brna, "KeyMaps", NULL);
        RNA_def_struct_sdna(srna, "wmKeyConfig");
        RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
 
-       func= RNA_def_function(srna, "new", "rna_keymap_new"); // add_keymap
-       parm= RNA_def_string(func, "name", "", 0, "Name", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
-       RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
-       RNA_def_boolean(func, "modal", 0, "Modal", "");
-       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map.");
-       RNA_def_function_return(func, parm);
-
-       func= RNA_def_function(srna, "find", "rna_keymap_find"); // find_keymap
-       parm= RNA_def_string(func, "name", "", 0, "Name", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
-       RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
-       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
-       RNA_def_function_return(func, parm);
-
-       func= RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); // find_keymap_modal
-       parm= RNA_def_string(func, "name", "", 0, "Operator Name", "");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
-       RNA_def_function_return(func, parm);
-       
+       RNA_api_keymaps(srna);
 }
 
 static void rna_def_keyconfig(BlenderRNA *brna)
 {
        StructRNA *srna;
-       // FunctionRNA *func;
-       // PropertyRNA *parm;
        PropertyRNA *prop;
 
        static EnumPropertyItem map_type_items[] = {
@@ -1794,8 +1619,8 @@ static void rna_def_keyconfig(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
        rna_def_keymap_items(brna, prop);
 
-       prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NEVER_NULL);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER);
+       prop= RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NEVER_NULL);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER_MODIFIED);
        RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
 
        prop= RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
@@ -1826,6 +1651,7 @@ static void rna_def_keyconfig(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
        RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set");
        RNA_def_struct_name_property(srna, prop);
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
        
        prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1836,62 +1662,73 @@ static void rna_def_keyconfig(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "OperatorProperties");
        RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "maptype");
        RNA_def_property_enum_items(prop, map_type_items);
        RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
        RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
        RNA_def_property_enum_items(prop, event_type_items);
        RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
        RNA_def_property_ui_text(prop, "Type", "Type of event");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "val");
        RNA_def_property_enum_items(prop, event_value_items);
        RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
        RNA_def_property_ui_text(prop, "Value", "");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "id");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "id", "ID of the item");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_getf", "rna_KeyMapItem_any_setf");
        RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
 //     RNA_def_property_enum_sdna(prop, NULL, "shift");
 //     RNA_def_property_enum_items(prop, keymap_modifiers_items);
        RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
 //     RNA_def_property_enum_sdna(prop, NULL, "ctrl");
 //     RNA_def_property_enum_items(prop, keymap_modifiers_items);
        RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
 //     RNA_def_property_enum_sdna(prop, NULL, "alt");
 //     RNA_def_property_enum_items(prop, keymap_modifiers_items);
        RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
 //     RNA_def_property_enum_sdna(prop, NULL, "oskey");
 //     RNA_def_property_enum_items(prop, keymap_modifiers_items);
        RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
        RNA_def_property_enum_items(prop, event_type_items);
        RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
@@ -1903,15 +1740,21 @@ static void rna_def_keyconfig(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, keymap_propvalue_items);
        RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
        RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
+       RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
 
        prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
        RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
        RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
 
+       prop= RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_USER_MODIFIED);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
+
        prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "User Defined", "Is this keymap item user defined (doesn't just override a builtin item)");
+       RNA_def_property_ui_text(prop, "User Defined", "Is this keymap item user defined (doesn't just replace a builtin item)");
        RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
 
        RNA_api_keymapitem(srna);
index d44b68950f796d16a082ee901b95b504274948d9..89e946f498ae734b49dfc9e1a96dee01cccefaee 100644 (file)
@@ -84,6 +84,85 @@ void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
        WM_event_remove_timer(wm, timer->win, timer);
 }
 
+static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
+{
+//     wmWindowManager *wm = CTX_wm_manager(C);
+       char idname_bl[OP_MAX_TYPENAME];
+       int modifier= 0;
+
+       /* only on non-modal maps */
+       if (km->flag & KEYMAP_MODAL) {
+               BKE_report(reports, RPT_ERROR, "Not a non-modal keymap.");
+               return NULL;
+       }
+
+       WM_operator_bl_idname(idname_bl, idname);
+
+       if(shift) modifier |= KM_SHIFT;
+       if(ctrl) modifier |= KM_CTRL;
+       if(alt) modifier |= KM_ALT;
+       if(oskey) modifier |= KM_OSKEY;
+
+       if(any) modifier = KM_ANY;
+
+       return WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
+}
+
+static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, ReportList *reports, const char *propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
+{
+       int modifier= 0;
+       int propvalue = 0;
+
+       /* only modal maps */
+       if ((km->flag & KEYMAP_MODAL) == 0) {
+               BKE_report(reports, RPT_ERROR, "Not a modal keymap.");
+               return NULL;
+       }
+
+       if (!km->modal_items) {
+               BKE_report(reports, RPT_ERROR, "No property values defined.");
+               return NULL;
+       }
+
+
+       if(RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue)==0) {
+               BKE_report(reports, RPT_WARNING, "Property value not in enumeration.");
+       }
+
+       if(shift) modifier |= KM_SHIFT;
+       if(ctrl) modifier |= KM_CTRL;
+       if(alt) modifier |= KM_ALT;
+       if(oskey) modifier |= KM_OSKEY;
+
+       if(any) modifier = KM_ANY;
+
+       return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
+}
+
+static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal)
+{
+       if (modal == 0) {
+               return WM_keymap_find(keyconf, idname, spaceid, regionid);
+       } else {
+               return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
+       }
+}
+
+static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
+{
+       return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
+}
+
+static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char *idname)
+{
+       wmOperatorType *ot = WM_operatortype_find(idname, 0);
+
+       if (!ot)
+               return NULL;
+       else
+               return ot->modalkeymap;
+}
+
 #else
 
 #define WM_GEN_INVOKE_EVENT (1<<0)
@@ -301,11 +380,8 @@ void RNA_api_keymap(StructRNA *srna)
        parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map.");
        RNA_def_function_return(func, parm);
 
-       func= RNA_def_function(srna, "copy_to_user", "WM_keymap_copy_to_user");
-       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "User editable key map.");
-       RNA_def_function_return(func, parm);
-
-       RNA_def_function(srna, "restore_to_default", "WM_keymap_restore_to_default");
+       func= RNA_def_function(srna, "restore_to_default", "WM_keymap_restore_to_default");
+       RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 
        func= RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
@@ -324,5 +400,102 @@ void RNA_api_keymapitem(StructRNA *srna)
        parm= RNA_def_boolean(func, "result", 0, "Comparison result", "");
        RNA_def_function_return(func, parm);
 }
+
+void RNA_api_keymapitems(StructRNA *srna)
+{
+       FunctionRNA *func;
+       PropertyRNA *parm;
+
+       func= RNA_def_function(srna, "new", "rna_KeyMap_item_new");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "any", 0, "Any", "");
+       RNA_def_boolean(func, "shift", 0, "Shift", "");
+       RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
+       RNA_def_boolean(func, "alt", 0, "Alt", "");
+       RNA_def_boolean(func, "oskey", 0, "OS Key", "");
+       RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
+       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       parm= RNA_def_string(func, "propvalue", "", 0, "Property Value", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "any", 0, "Any", "");
+       RNA_def_boolean(func, "shift", 0, "Shift", "");
+       RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
+       RNA_def_boolean(func, "alt", 0, "Alt", "");
+       RNA_def_boolean(func, "oskey", 0, "OS Key", "");
+       RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
+       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
+       RNA_def_function_return(func, parm);
+       
+       func= RNA_def_function(srna, "remove", "WM_keymap_remove_item");
+       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+
+       func= RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
+       parm= RNA_def_property(func, "id", PROP_INT, PROP_NONE);
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_property_ui_text(parm, "id", "ID of the item");
+       parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
+       RNA_def_function_return(func, parm);
+}
+
+void RNA_api_keymaps(StructRNA *srna)
+{
+       FunctionRNA *func;
+       PropertyRNA *parm;
+
+       func= RNA_def_function(srna, "new", "rna_keymap_new"); // add_keymap
+       parm= RNA_def_string(func, "name", "", 0, "Name", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
+       RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+       RNA_def_boolean(func, "modal", 0, "Modal", "");
+       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map.");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "find", "rna_keymap_find"); // find_keymap
+       parm= RNA_def_string(func, "name", "", 0, "Name", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
+       RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); // find_keymap_modal
+       parm= RNA_def_string(func, "name", "", 0, "Operator Name", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
+       RNA_def_function_return(func, parm);
+}
+
+void RNA_api_keyconfigs(StructRNA *srna)
+{
+       FunctionRNA *func;
+       PropertyRNA *parm;
+
+       func= RNA_def_function(srna, "new", "WM_keyconfig_new_user"); // add_keyconfig
+       parm= RNA_def_string(func, "name", "", 0, "Name", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration.");
+       RNA_def_function_return(func, parm);
+
+       func= RNA_def_function(srna, "remove", "WM_keyconfig_remove"); // remove_keyconfig
+       parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+}
+
 #endif
 
index 4a17c45ae3884bcf3904862afe5d8c4c8f66949f..4b05a9c0c728c5802cee04d0e1e5058c7fde402a 100644 (file)
@@ -397,7 +397,9 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
 
        
        pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
+#ifdef PYRNA_FREE_SUPPORT
        pyrna->freeptr= TRUE;
+#endif
        return (PyObject *)pyrna;
 }
 
index 502b25842de25ef89529965148c593d8742ed12f..4447a0476f4f87c8dec518f8eae67fc8d20bd69c 100644 (file)
@@ -908,6 +908,13 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self)
        return ret;
 }
 
+
+static PyObject *pyrna_func_repr(BPy_FunctionRNA *self)
+{
+       return PyUnicode_FromFormat("<%.200s %.200s.%.200s()>", Py_TYPE(self)->tp_name, RNA_struct_identifier(self->ptr.type), RNA_function_identifier(self->func));
+}
+
+
 static long pyrna_struct_hash(BPy_StructRNA *self)
 {
        return _Py_HashPointer(self->ptr.data);
@@ -950,11 +957,13 @@ static int pyrna_struct_clear(BPy_StructRNA *self)
 /* use our own dealloc so we can free a property if we use one */
 static void pyrna_struct_dealloc(BPy_StructRNA *self)
 {
+#ifdef PYRNA_FREE_SUPPORT
        if (self->freeptr && self->ptr.data) {
                IDP_FreeProperty(self->ptr.data);
                MEM_freeN(self->ptr.data);
                self->ptr.data= NULL;
        }
+#endif /* PYRNA_FREE_SUPPORT */
 
 #ifdef USE_WEAKREFS
        if (self->in_weakreflist != NULL) {
@@ -1344,36 +1353,16 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
        return error_val;
 }
 
-static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw);
 
-static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func)
+static PyObject *pyrna_func_to_py(PointerRNA *ptr, FunctionRNA *func)
 {
-       static PyMethodDef func_meth= {"<generic rna function>", (PyCFunction)pyrna_func_call, METH_VARARGS|METH_KEYWORDS, "python rna function"};
-       PyObject *self;
-       PyObject *ret;
-
-       if(func==NULL) {
-               PyErr_Format(PyExc_RuntimeError,
-                            "%.200s: type attempted to get NULL function",
-                            RNA_struct_identifier(pyrna->ptr.type));
-               return NULL;
-       }
-
-       self= PyTuple_New(2);
-
-       PyTuple_SET_ITEM(self, 0, (PyObject *)pyrna);
-       Py_INCREF(pyrna);
-
-       PyTuple_SET_ITEM(self, 1, PyCapsule_New((void *)func, NULL, NULL));
-
-       ret= PyCFunction_New(&func_meth, self);
-       Py_DECREF(self);
-
-       return ret;
+       BPy_FunctionRNA* pyfunc= (BPy_FunctionRNA *) PyObject_NEW(BPy_FunctionRNA, &pyrna_func_Type);
+       pyfunc->ptr= *ptr;
+       pyfunc->func= func;
+       return (PyObject *)pyfunc;
 }
 
 
-
 static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix)
 {
        /* XXX hard limits should be checked here */
@@ -3001,7 +2990,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
        }
        /* RNA function only if callback is declared (no optional functions) */
        else if ((func= RNA_struct_find_function(&self->ptr, name)) && RNA_function_defined(func)) {
-               ret= pyrna_func_to_py((BPy_DummyPointerRNA *)self, func);
+               ret= pyrna_func_to_py(&self->ptr, func);
        }
        else if (self->ptr.type == &RNA_Context) {
                bContext *C= self->ptr.data;
@@ -3303,7 +3292,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
                        }
                        else if ((func= RNA_struct_find_function(&r_ptr, name))) {
                                PyObject *self_collection= pyrna_struct_CreatePyObject(&r_ptr);
-                               ret= pyrna_func_to_py((BPy_DummyPointerRNA *)self_collection, func);
+                               ret= pyrna_func_to_py(&((BPy_DummyPointerRNA *)self_collection)->ptr, func);
                                Py_DECREF(self_collection);
 
                                return ret;
@@ -4257,11 +4246,11 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
        return ret;
 }
 
-static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
+static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject *kw)
 {
        /* Note, both BPy_StructRNA and BPy_PropertyRNA can be used here */
-       PointerRNA *self_ptr= &(((BPy_DummyPointerRNA *)PyTuple_GET_ITEM(self, 0))->ptr);
-       FunctionRNA *self_func= PyCapsule_GetPointer(PyTuple_GET_ITEM(self, 1), NULL);
+       PointerRNA *self_ptr= &self->ptr;
+       FunctionRNA *self_func= self->func;
 
        PointerRNA funcptr;
        ParameterList parms;
@@ -5045,6 +5034,91 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= {
        NULL
 };
 
+/*-----------------------BPy_PropertyRNA method def------------------------------*/
+PyTypeObject pyrna_func_Type= {
+       PyVarObject_HEAD_INIT(NULL, 0)
+       "bpy_func",             /* tp_name */
+       sizeof(BPy_FunctionRNA),                        /* tp_basicsize */
+       0,                      /* tp_itemsize */
+       /* methods */
+       NULL,                                           /* tp_dealloc */
+       NULL,                                           /* printfunc tp_print; */
+       NULL,                                           /* getattrfunc tp_getattr; */
+       NULL,                       /* setattrfunc tp_setattr; */
+       NULL,                                           /* tp_compare */ /* DEPRECATED in python 3.0! */
+       (reprfunc) pyrna_func_repr,     /* tp_repr */
+
+       /* Method suites for standard classes */
+
+       NULL,                       /* PyNumberMethods *tp_as_number; */
+       NULL,                                           /* PySequenceMethods *tp_as_sequence; */
+       NULL,                                           /* PyMappingMethods *tp_as_mapping; */
+
+       /* More standard operations (here for binary compatibility) */
+
+       NULL,                                           /* hashfunc tp_hash; */
+       (ternaryfunc)pyrna_func_call,            /* ternaryfunc tp_call; */
+       NULL,                                           /* reprfunc tp_str; */
+
+       /* will only use these if this is a subtype of a py class */
+       NULL,                                           /* getattrofunc tp_getattro; */
+       NULL,                                           /* setattrofunc tp_setattro; */
+
+       /* Functions to access object as input/output buffer */
+       NULL,                       /* PyBufferProcs *tp_as_buffer; */
+
+  /*** Flags to define presence of optional/expanded features ***/
+       Py_TPFLAGS_DEFAULT,         /* long tp_flags; */
+
+       NULL,                                           /*  char *tp_doc;  Documentation string */
+  /*** Assigned meaning in release 2.0 ***/
+       /* call function for all accessible objects */
+       NULL,                       /* traverseproc tp_traverse; */
+
+       /* delete references to contained objects */
+       NULL,                       /* inquiry tp_clear; */
+
+  /***  Assigned meaning in release 2.1 ***/
+  /*** rich comparisons ***/
+       NULL,                                           /* richcmpfunc tp_richcompare; */
+
+  /***  weak reference enabler ***/
+#ifdef USE_WEAKREFS
+       offsetof(BPy_PropertyRNA, in_weakreflist),      /* long tp_weaklistoffset; */
+#else
+       0,
+#endif
+
+  /*** Added in release 2.2 ***/
+       /*   Iterators */
+       NULL,                                           /* getiterfunc tp_iter; */
+       NULL,                       /* iternextfunc tp_iternext; */
+
+  /*** Attribute descriptor and subclassing stuff ***/
+       NULL,                                           /* struct PyMethodDef *tp_methods; */
+       NULL,                       /* struct PyMemberDef *tp_members; */
+       NULL,                                   /* struct PyGetSetDef *tp_getset; */
+       NULL,                       /* struct _typeobject *tp_base; */
+       NULL,                       /* PyObject *tp_dict; */
+       NULL,                       /* descrgetfunc tp_descr_get; */
+       NULL,                       /* descrsetfunc tp_descr_set; */
+       0,                          /* long tp_dictoffset; */
+       NULL,                       /* initproc tp_init; */
+       NULL,                       /* allocfunc tp_alloc; */
+       NULL,                                           /* newfunc tp_new; */
+       /*  Low-level free-memory routine */
+       NULL,                       /* freefunc tp_free;  */
+       /* For PyObject_IS_GC */
+       NULL,                       /* inquiry tp_is_gc;  */
+       NULL,                       /* PyObject *tp_bases; */
+       /* method resolution order */
+       NULL,                       /* PyObject *tp_mro;  */
+       NULL,                       /* PyObject *tp_cache; */
+       NULL,                       /* PyObject *tp_subclasses; */
+       NULL,                       /* PyObject *tp_weaklist; */
+       NULL
+};
+
 #ifdef USE_PYRNA_ITER
 /* --- collection iterator: start --- */
 /* wrap rna collection iterator functions */
@@ -5423,7 +5497,9 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
        }
 
        pyrna->ptr= *ptr;
+#ifdef PYRNA_FREE_SUPPORT
        pyrna->freeptr= FALSE;
+#endif
 
 #ifdef USE_PYRNA_STRUCT_REFERENCE
        pyrna->reference= NULL;
@@ -5516,6 +5592,9 @@ void BPY_rna_init(void)
        if(PyType_Ready(&pyrna_prop_collection_idprop_Type) < 0)
                return;
 
+       if(PyType_Ready(&pyrna_func_Type) < 0)
+               return;
+
 #ifdef USE_PYRNA_ITER
        if(PyType_Ready(&pyrna_prop_collection_iter_Type) < 0)
                return;
index 5db352af53dc12ed9630cee6052debca0c6acb8c..30f6c02115aa70b51034ed46281e48b4ac43459c 100644 (file)
 #if defined(USE_PYRNA_INVALIDATE_GC) && defined(USE_PYRNA_INVALIDATE_WEAKREF)
 #error "Only 1 reference check method at a time!"
 #endif
+
+/* only used by operator introspection get_rna(), this is only used for doc gen
+ * so prefer the leak to the memory bloat for now. */
+// #define PYRNA_FREE_SUPPORT
+
 /* --- end bpy build options --- */
 
 struct ID;
@@ -71,6 +76,7 @@ extern PyTypeObject pyrna_struct_Type;
 extern PyTypeObject pyrna_prop_Type;
 extern PyTypeObject pyrna_prop_array_Type;
 extern PyTypeObject pyrna_prop_collection_Type;
+extern PyTypeObject pyrna_func_Type;
 
 #define BPy_StructRNA_Check(v)                 (PyObject_TypeCheck(v, &pyrna_struct_Type))
 #define BPy_StructRNA_CheckExact(v)            (Py_TYPE(v) == &pyrna_struct_Type)
@@ -107,7 +113,10 @@ typedef struct {
         * hold onto the collection iterator to prevent it from freeing allocated data we may use */
        PyObject *reference;
 #endif /* !USE_PYRNA_STRUCT_REFERENCE */
+
+#ifdef PYRNA_FREE_SUPPORT
        int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */
+#endif /* PYRNA_FREE_SUPPORT */
 } BPy_StructRNA;
 
 typedef struct {
@@ -142,6 +151,15 @@ typedef struct {
        CollectionPropertyIterator iter;
 } BPy_PropertyCollectionIterRNA;
 
+typedef struct {
+       PyObject_HEAD /* required python macro   */
+#ifdef USE_WEAKREFS
+       PyObject *in_weakreflist;
+#endif
+       PointerRNA ptr;
+       FunctionRNA *func;
+} BPy_FunctionRNA;
+
 /* cheap trick */
 #define BPy_BaseTypeRNA BPy_PropertyRNA
 
index e6325e2101a4bd356eff34234cd029d83080b56f..42c3096dfc9fed028f7d15497bc062e024ad74b8 100644 (file)
@@ -41,6 +41,7 @@
 
 /* dna-savable wmStructs here */
 #include "DNA_windowmanager_types.h"
+#include "WM_keymap.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -114,50 +115,9 @@ void               WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
 
 void           WM_cursor_warp          (struct wmWindow *win, int x, int y);
 
-                       /* keyconfig and keymap */
-wmKeyConfig *WM_keyconfig_new  (struct wmWindowManager *wm, const char *idname);
-wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
-void           WM_keyconfig_remove     (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
-void           WM_keyconfig_free       (struct wmKeyConfig *keyconf);
-void           WM_keyconfig_userdef(void);
-
-void           WM_keymap_init          (struct bContext *C);
-void           WM_keymap_free          (struct wmKeyMap *keymap);
-
-wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, const char *idname, int type, 
-                                                                int val, int modifier, int keymodifier);
-wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type, 
-                                                                int val, int modifier, int keymodifier);
-wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const 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_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
-wmKeyMap       *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
-wmKeyMap       *WM_keymap_find_all(const struct bContext *C, const 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, const 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, struct IDProperty *properties);
-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);
+                       /* event map */
 int                    WM_userdef_event_map(int kmitype);
 
-wmKeyMap       *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items);
-wmKeyMap       *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
-wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
-void           WM_modalkeymap_assign(struct wmKeyMap *km, const 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, int hotkey, 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);
-
                        /* handlers */
 
 struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
new file mode 100644 (file)
index 0000000..e00cd28
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef WM_KEYMAP_H
+#define WM_KEYMAP_H
+
+/** \file WM_keymap.h
+ *  \ingroup wm
+ */
+
+/* dna-savable wmStructs here */
+#include "DNA_windowmanager_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct EnumPropertyItem;
+
+/* Key Configuration */
+
+wmKeyConfig *WM_keyconfig_new  (struct wmWindowManager *wm, const char *idname);
+wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
+void           WM_keyconfig_remove     (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
+void           WM_keyconfig_free       (struct wmKeyConfig *keyconf);
+
+void           WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname);
+
+void           WM_keyconfig_update(struct wmWindowManager *wm);
+void           WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+
+/* Keymap */
+
+void           WM_keymap_init          (struct bContext *C);
+void           WM_keymap_free          (struct wmKeyMap *keymap);
+
+wmKeyMapItem *WM_keymap_verify_item(struct wmKeyMap *keymap, const char *idname, int type, 
+                                                                int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_item(struct wmKeyMap *keymap, const char *idname, int type, 
+                                                                int val, int modifier, int keymodifier);
+wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const 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_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
+wmKeyMap       *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
+wmKeyMap       *WM_keymap_find_all(const struct bContext *C, const 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, const char *opname);
+
+wmKeyMapItem *WM_keymap_item_find_id(struct wmKeyMap *keymap, int id);
+int                    WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
+
+/* Modal Keymap */
+
+wmKeyMap       *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items);
+wmKeyMap       *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
+wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
+void           WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
+
+/* Keymap Editor */
+
+void           WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
+void           WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
+void           WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+
+/* Key Event */
+
+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, int hotkey, 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WM_KEYMAP_H */
+
index a535c0bc1f8e783439e8aa0451de86ab4f81ba5a..1d5cf1cdc53b73b6934a1fd87ced440b41ce0992 100644 (file)
@@ -210,12 +210,18 @@ void WM_keymap_init(bContext *C)
 
        if(!wm->defaultconf)
                wm->defaultconf= WM_keyconfig_new(wm, "Blender");
+       if(!wm->addonconf)
+               wm->addonconf= WM_keyconfig_new(wm, "Blender Addon");
+       if(!wm->userconf)
+               wm->userconf= WM_keyconfig_new(wm, "Blender User");
        
-       if(wm && CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) {
+       if(CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) {
                /* create default key config */
                wm_window_keymap(wm->defaultconf);
                ED_spacetypes_keymap(wm->defaultconf);
-               WM_keyconfig_userdef();
+
+               WM_keyconfig_update_tag(NULL, NULL);
+               WM_keyconfig_update(wm);
 
                wm->initialized |= WM_INIT_KEYMAP;
        }
index 2f0c1a72be9d9447f4ebbd8f822a63c9549db3e3..0dac0bd74015e2cccdea08285a24bfe56e812aa7 100644 (file)
@@ -1735,6 +1735,9 @@ void wm_event_do_handlers(bContext *C)
        wmWindowManager *wm= CTX_wm_manager(C);
        wmWindow *win;
 
+       /* update key configuration before handling events */
+       WM_keyconfig_update(wm);
+
        for(win= wm->windows.first; win; win= win->next) {
                wmEvent *event;
                
@@ -1938,6 +1941,9 @@ void wm_event_do_handlers(bContext *C)
                
                CTX_wm_window_set(C, NULL);
        }
+
+       /* update key configuration after handling events */
+       WM_keyconfig_update(wm);
 }
 
 /* ********** filesector handling ************ */
index 27fc0caecccc11996f8b25cdeffc6bb9f2c2b1e0..20f9d2237c2d9e0905c6f89ba077cdf286467557 100644 (file)
@@ -224,6 +224,14 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
                        oldwm= oldwmlist->first;
                        wm= G.main->wm.first;
 
+                       /* move addon key configuration to new wm, to preserve their keymaps */
+                       if(oldwm->addonconf) {
+                               wm->addonconf= oldwm->addonconf;
+                               BLI_remlink(&oldwm->keyconfigs, oldwm->addonconf);
+                               oldwm->addonconf= NULL;
+                               BLI_addtail(&wm->keyconfigs, wm->addonconf);
+                       }
+
                        /* ensure making new keymaps and set space types */
                        wm->initialized= 0;
                        wm->winactive= NULL;
@@ -794,11 +802,14 @@ int WM_write_homefile(bContext *C, wmOperator *op)
        wmWindow *win= CTX_wm_window(C);
        char filepath[FILE_MAXDIR+FILE_MAXFILE];
        int fileflags;
-       
+
        /* check current window and close it if temp */
        if(win->screen->temp)
                wm_window_close(C, wm, win);
        
+       /* update keymaps in user preferences */
+       WM_keyconfig_update(wm);
+       
        BLI_make_file_string("/", filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
        printf("trying to save homefile at %s ", filepath);
        
index 1720c738dd730687d2252dcf6bbd36f1e6bbdff2..bf48f0e21e42907477e2a7c753d6d34f6d0dca35 100644 (file)
 #include "wm_event_system.h"
 #include "wm_event_types.h"
 
-/* ********************* key config ***********************/
+/******************************* Keymap Item **********************************
+ * Item in a keymap, that maps from an event to an operator or modal map item */
 
-static void keymap_properties_set(wmKeyMapItem *kmi)
+static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
+{
+       wmKeyMapItem *kmin = MEM_dupallocN(kmi);
+
+       kmin->prev= kmin->next= NULL;
+       kmin->flag &= ~KMI_UPDATE;
+
+       if(kmin->properties) {
+               kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
+               WM_operator_properties_create(kmin->ptr, kmin->idname);
+
+               kmin->properties= IDP_CopyProperty(kmin->properties);
+               kmin->ptr->data= kmin->properties;
+       }
+
+       return kmin;
+}
+
+static void wm_keymap_item_free(wmKeyMapItem *kmi)
+{
+       /* not kmi itself */
+       if(kmi->ptr) {
+               WM_operator_properties_free(kmi->ptr);
+               MEM_freeN(kmi->ptr);
+       }
+}
+
+static void wm_keymap_item_properties_set(wmKeyMapItem *kmi)
 {
        WM_operator_properties_alloc(&(kmi->ptr), &(kmi->properties), kmi->idname);
        WM_operator_properties_sanitize(kmi->ptr, 1);
 }
 
+static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b)
+{
+       if(strcmp(a->idname, b->idname) != 0)
+               return 0;
+       
+       if(!((a->ptr==NULL && b->ptr==NULL) ||
+            (a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data))))
+               return 0;
+       
+       return (a->propvalue == b->propvalue);
+}
+
+static int wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
+{
+       return (wm_keymap_item_equals_result(a, b) &&
+               a->type == b->type &&
+               a->val == b->val &&
+               a->shift == b->shift &&
+               a->ctrl == b->ctrl &&
+               a->alt == b->alt &&
+               a->oskey == b->oskey &&
+               a->keymodifier == b->keymodifier &&
+               a->maptype == b->maptype);
+}
+
 /* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */
 void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
 {
@@ -78,9 +131,41 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties
        kmi->ptr = NULL;
        kmi->properties = properties;
 
-       keymap_properties_set(kmi);
+       wm_keymap_item_properties_set(kmi);
+}
+
+/**************************** Keymap Diff Item *********************************
+ * Item in a diff keymap, used for saving diff of keymaps in user preferences */
+
+static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
+{
+       wmKeyMapDiffItem *kmdin = MEM_dupallocN(kmdi);
+
+       kmdin->next = kmdin->prev = NULL;
+       if(kmdi->add_item)
+               kmdin->add_item = wm_keymap_item_copy(kmdi->add_item);
+       if(kmdi->remove_item)
+               kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item);
+       
+       return kmdin;
+}
+
+static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
+{
+       if(kmdi->remove_item) {
+               wm_keymap_item_free(kmdi->remove_item);
+               MEM_freeN(kmdi->remove_item);
+       }
+       if(kmdi->add_item) {
+               wm_keymap_item_free(kmdi->add_item);
+               MEM_freeN(kmdi->add_item);
+       }
 }
 
+/***************************** Key Configuration ******************************
+ * List of keymaps for all editors, modes, ... . There is a builtin default key
+ * configuration, a user key configuration, and other preset configurations. */
+
 wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname)
 {
        wmKeyConfig *keyconf;
@@ -106,6 +191,7 @@ void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
        if (keyconf) {
                if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) {
                        BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
+                       WM_keyconfig_update_tag(NULL, NULL);
                }
 
                BLI_remlink(&wm->keyconfigs, keyconf);
@@ -125,21 +211,6 @@ void WM_keyconfig_free(wmKeyConfig *keyconf)
        MEM_freeN(keyconf);
 }
 
-void WM_keyconfig_userdef(void)
-{
-       wmKeyMap *km;
-       wmKeyMapItem *kmi;
-
-       for(km=U.keymaps.first; km; km=km->next) {
-               /* modal keymaps don't have operator properties */
-               if ((km->flag & KEYMAP_MODAL) == 0) {
-                       for(kmi=km->items.first; kmi; kmi=kmi->next) {
-                               keymap_properties_set(kmi);
-                       }
-               }
-       }
-}
-
 static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
 {
        wmKeyConfig *kc;
@@ -151,23 +222,84 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
        return NULL;
 }
 
-/* ************************ free ************************* */
+wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
+{
+       wmKeyConfig *keyconf;
 
-void WM_keymap_free(wmKeyMap *keymap)
+       /* first try from preset */
+       keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
+       if(keyconf)
+               return keyconf;
+       
+       /* otherwise use default */
+       return wm->defaultconf;
+}
+
+void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
 {
-       wmKeyMapItem *kmi;
+       /* setting a different key configuration as active: we ensure all is
+          updated properly before and after making the change */
+
+       WM_keyconfig_update(wm);
+
+       BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr));
+
+       WM_keyconfig_update_tag(NULL, NULL);
+       WM_keyconfig_update(wm);
+}
+
+/********************************** Keymap *************************************
+ * List of keymap items for one editor, mode, modal operator, ... */
+
+static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
+{
+       wmKeyMap *km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
+
+       BLI_strncpy(km->idname, idname, KMAP_MAX_NAME);
+       km->spaceid= spaceid;
+       km->regionid= regionid;
+
+       return km;
+}
+
+static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
+{
+       wmKeyMap *keymapn = MEM_dupallocN(keymap);
+       wmKeyMapItem *kmi, *kmin;
+       wmKeyMapDiffItem *kmdi, *kmdin;
+
+       keymapn->modal_items= keymap->modal_items;
+       keymapn->poll= keymap->poll;
+       keymapn->items.first= keymapn->items.last= NULL;
+       keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED);
+
+       for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+               kmdin= wm_keymap_diff_item_copy(kmdi);
+               BLI_addtail(&keymapn->items, kmdin);
+       }
 
        for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
-               if(kmi->ptr) {
-                       WM_operator_properties_free(kmi->ptr);
-                       MEM_freeN(kmi->ptr);
-               }
+               kmin= wm_keymap_item_copy(kmi);
+               BLI_addtail(&keymapn->items, kmin);
        }
 
-       BLI_freelistN(&keymap->items);
+       return keymapn;
 }
 
-/* ***************** generic call, exported **************** */
+void WM_keymap_free(wmKeyMap *keymap)
+{
+       wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
+
+       for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next)
+               wm_keymap_diff_item_free(kmdi);
+
+       for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+               wm_keymap_item_free(kmi);
+
+       BLI_freelistN(&keymap->diff_items);
+       BLI_freelistN(&keymap->items);
+}
 
 static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier)
 {
@@ -229,7 +361,7 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty
                keymap_item_set_id(keymap, kmi);
 
                keymap_event_set(kmi, type, val, modifier, keymodifier);
-               keymap_properties_set(kmi);
+               wm_keymap_item_properties_set(kmi);
        }
        return kmi;
 }
@@ -243,10 +375,12 @@ wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type,
        BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
 
        keymap_event_set(kmi, type, val, modifier, keymodifier);
-       keymap_properties_set(kmi);
+       wm_keymap_item_properties_set(kmi);
 
        keymap_item_set_id(keymap, kmi);
 
+       WM_keyconfig_update_tag(keymap, kmi);
+
        return kmi;
 }
 
@@ -266,6 +400,232 @@ void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
                        MEM_freeN(kmi->ptr);
                }
                BLI_freelinkN(&keymap->items, kmi);
+
+               WM_keyconfig_update_tag(keymap, kmi);
+       }
+}
+
+/************************** Keymap Diff and Patch ****************************
+ * Rather than saving the entire keymap for user preferences, we only save a
+ * diff so that changes in the defaults get synced. This system is not perfect
+ * but works better than overriding the keymap entirely when only few items
+ * are changed. */
+
+static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
+{
+       wmKeyMapItem *kmi, *kmin;
+
+       for(kmi=addonmap->items.first; kmi; kmi=kmi->next) {
+               kmin = wm_keymap_item_copy(kmi);
+               keymap_item_set_id(keymap, kmin);
+               BLI_addhead(&keymap->items, kmin);
+       }
+}
+
+static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *needle)
+{
+       wmKeyMapItem *kmi;
+
+       for(kmi=km->items.first; kmi; kmi=kmi->next)
+               if(wm_keymap_item_equals(kmi, needle))
+                       return kmi;
+       
+       return NULL;
+}
+
+static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapItem *needle)
+{
+       wmKeyMapItem *kmi;
+
+       for(kmi=km->items.first; kmi; kmi=kmi->next)
+               if(wm_keymap_item_equals_result(kmi, needle))
+                       return kmi;
+       
+       return NULL;
+}
+
+static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km, wmKeyMap *orig_km, wmKeyMap *addon_km)
+{
+       wmKeyMapItem *kmi, *to_kmi, *orig_kmi;
+       wmKeyMapDiffItem *kmdi;
+
+       for(kmi=from_km->items.first; kmi; kmi=kmi->next) {
+               to_kmi = WM_keymap_item_find_id(to_km, kmi->id);
+
+               if(!to_kmi) {
+                       /* remove item */
+                       kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
+                       kmdi->remove_item = wm_keymap_item_copy(kmi);
+                       BLI_addtail(&diff_km->diff_items, kmdi);
+               }
+               else if(to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) {
+                       /* replace item */
+                       kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
+                       kmdi->remove_item = wm_keymap_item_copy(kmi);
+                       kmdi->add_item = wm_keymap_item_copy(to_kmi);
+                       BLI_addtail(&diff_km->diff_items, kmdi);
+               }
+
+               /* sync expanded flag back to original so we don't loose it on repatch */
+               if(to_kmi) {
+                       orig_kmi = WM_keymap_item_find_id(orig_km, kmi->id);
+
+                       if(!orig_kmi)
+                               orig_kmi = wm_keymap_find_item_equals(addon_km, kmi);
+
+                       if(orig_kmi) {
+                               orig_kmi->flag &= ~KMI_EXPANDED;
+                               orig_kmi->flag |= (to_kmi->flag & KMI_EXPANDED);
+                       }
+               }
+       }
+
+       for(kmi=to_km->items.first; kmi; kmi=kmi->next) {
+               if(kmi->id < 0) {
+                       /* add item */
+                       kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
+                       kmdi->add_item = wm_keymap_item_copy(kmi);
+                       BLI_addtail(&diff_km->diff_items, kmdi);
+               }
+       }
+}
+
+static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
+{
+       wmKeyMapDiffItem *kmdi;
+       wmKeyMapItem *kmi_remove, *kmi_add;
+
+       for(kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) {
+               /* find item to remove */
+               kmi_remove = NULL;
+               if(kmdi->remove_item) {
+                       kmi_remove = wm_keymap_find_item_equals(km, kmdi->remove_item);
+                       if(!kmi_remove)
+                               kmi_remove = wm_keymap_find_item_equals_result(km, kmdi->remove_item);
+               }
+
+               /* add item */
+               if(kmdi->add_item) {
+                       /* only if nothing to remove or item to remove found */
+                       if(!kmdi->remove_item || kmi_remove) {
+                               kmi_add = wm_keymap_item_copy(kmdi->add_item);
+                               kmi_add->flag |= KMI_USER_MODIFIED;
+
+                               if(kmi_remove) {
+                                       kmi_add->flag &= ~KMI_EXPANDED;
+                                       kmi_add->flag |= (kmi_remove->flag & KMI_EXPANDED);
+                                       kmi_add->id = kmi_remove->id;
+                                       BLI_insertlinkbefore(&km->items, kmi_remove, kmi_add);
+                               }
+                               else {
+                                       keymap_item_set_id(km, kmi_add);
+                                       BLI_addtail(&km->items, kmi_add);
+                               }
+                       }
+               }
+
+               /* remove item */
+               if(kmi_remove) {
+                       wm_keymap_item_free(kmi_remove);
+                       BLI_freelinkN(&km->items, kmi_remove);
+               }
+       }
+}
+
+static void wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *addonmap, wmKeyMap *usermap)
+{
+       wmKeyMap *km;
+       int expanded = 0;
+
+       /* remove previous keymap in list, we will replace it */
+       km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid);
+       if(km) {
+               expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED));
+               WM_keymap_free(km);
+               BLI_freelinkN(lb, km);
+       }
+
+       /* copy new keymap from an existing one */
+       if(usermap && !(usermap->flag & KEYMAP_DIFF)) {
+               /* for compatibiltiy with old user preferences with non-diff
+                  keymaps we override the original entirely */
+               wmKeyMapItem *kmi, *orig_kmi;
+
+               km = wm_keymap_copy(usermap);
+               km->modal_items = defaultmap->modal_items;
+               km->poll = defaultmap->poll;
+
+               /* try to find corresponding id's for items */
+               for(kmi=km->items.first; kmi; kmi=kmi->next) {
+                       orig_kmi = wm_keymap_find_item_equals(defaultmap, kmi);
+                       if(!orig_kmi)
+                               orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi);
+
+                       if(orig_kmi)
+                               kmi->id = orig_kmi->id;
+                       else
+                               kmi->id = -(km->kmi_id++);
+               }
+
+               km->flag |= KEYMAP_UPDATE; /* update again to create diff */
+       }
+       else
+               km = wm_keymap_copy(defaultmap);
+
+       /* add addon keymap items */
+       if(addonmap)
+               wm_keymap_addon_add(km, addonmap);
+
+       /* tag as being user edited */
+       if(usermap)
+               km->flag |= KEYMAP_USER_MODIFIED;
+       km->flag |= KEYMAP_USER|expanded;
+
+       /* apply user changes of diff keymap */
+       if(usermap && (usermap->flag & KEYMAP_DIFF))
+               wm_keymap_patch(km, usermap);
+
+       /* add to list */
+       BLI_addtail(lb, km);
+}
+
+static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *addonmap, wmKeyMap *km)
+{
+       wmKeyMap *diffmap, *prevmap, *origmap;
+
+       /* create temporary default + addon keymap for diff */
+       origmap = defaultmap;
+
+       if(addonmap) {
+               defaultmap = wm_keymap_copy(defaultmap);
+               wm_keymap_addon_add(defaultmap, addonmap);
+       }
+
+       /* remove previous diff keymap in list, we will replace it */
+       prevmap = WM_keymap_list_find(lb, km->idname, km->spaceid, km->regionid);
+       if(prevmap) {
+               WM_keymap_free(prevmap);
+               BLI_freelinkN(lb, prevmap);
+       }
+
+       /* create diff keymap */
+       diffmap= wm_keymap_new(km->idname, km->spaceid, km->regionid);
+       diffmap->flag |= KEYMAP_DIFF;
+       wm_keymap_diff(diffmap, defaultmap, km, origmap, addonmap);
+
+       /* add to list if not empty */
+       if(diffmap->diff_items.first) {
+               BLI_addtail(lb, diffmap);
+       }
+       else {
+               WM_keymap_free(diffmap);
+               MEM_freeN(diffmap);
+       }
+
+       /* free temporary default map */
+       if(addonmap) {
+               WM_keymap_free(defaultmap);
+               MEM_freeN(defaultmap);
        }
 }
 
@@ -292,11 +652,10 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid,
        wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
        
        if(km==NULL) {
-               km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
-               BLI_strncpy(km->idname, idname, KMAP_MAX_NAME);
-               km->spaceid= spaceid;
-               km->regionid= regionid;
+               km= wm_keymap_new(idname, spaceid, regionid);
                BLI_addtail(&keyconf->keymaps, km);
+
+               WM_keyconfig_update_tag(km, NULL);
        }
        
        return km;
@@ -304,29 +663,9 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid,
 
 wmKeyMap *WM_keymap_find_all(const bContext *C, const 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;
+       wmWindowManager *wm= CTX_wm_manager(C);
+
+       return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid);
 }
 
 /* ****************** modal keymaps ************ */
@@ -366,6 +705,8 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif
 
        keymap_item_set_id(km, kmi);
 
+       WM_keyconfig_update_tag(km, kmi);
+
        return kmi;
 }
 
@@ -588,169 +929,209 @@ int     WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
        return 1;
 }
 
-/* ***************** user preferences ******************* */
+/************************* Update Final Configuration *************************
+ * On load or other changes, the final user key configuration is rebuilt from
+ * the preset, addon and user preferences keymaps. We also test if the final
+ * configuration changed and write the changes to the user preferences. */
+
+static int WM_KEYMAP_UPDATE = 0;
 
-int WM_keymap_user_init(wmWindowManager *wm, wmKeyMap *keymap)
+void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi)
 {
-       wmKeyConfig *keyconf;
-       wmKeyMap *km;
+       /* quick tag to do delayed keymap updates */
+       WM_KEYMAP_UPDATE= 1;
 
-       if(!keymap)
-               return 0;
+       if(km)
+               km->flag |= KEYMAP_UPDATE;
+       if(kmi)
+               kmi->flag |= KMI_UPDATE;
+}
 
-       /* init from user key config */
-       keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
-       if(keyconf) {
-               km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-               if(km) {
-                       keymap->poll= km->poll; /* lazy init */
-                       keymap->modal_items= km->modal_items;
-                       return 1;
-               }
-       }
+static int wm_keymap_test_and_clear_update(wmKeyMap *km)
+{
+       wmKeyMapItem *kmi;
+       int update;
+       
+       update= (km->flag & KEYMAP_UPDATE);
+       km->flag &= ~KEYMAP_UPDATE;
 
-       /* or from default */
-       km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-       if(km) {
-               keymap->poll= km->poll; /* lazy init */
-               keymap->modal_items= km->modal_items;
-               return 1;
+       for(kmi=km->items.first; kmi; kmi=kmi->next) {
+               update= update || (kmi->flag & KMI_UPDATE);
+               kmi->flag &= ~KMI_UPDATE;
        }
-
-       return 0;
+       
+       return update;
 }
 
-wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
+static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km)
 {
-       wmKeyConfig *keyconf;
-       wmKeyMap *km;
+       wmKeyConfig *keyconf= WM_keyconfig_active(wm);
+       wmKeyMap *keymap;
 
+       keymap= WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid);
        if(!keymap)
-               return NULL;
-       
-       /* first user defined keymaps */
-       km= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-       if(km) {
-               km->poll= keymap->poll; /* lazy init */
-               km->modal_items= keymap->modal_items;
-               return km;
-       }
-       
-       /* then user key config */
-       keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
-       if(keyconf) {
-               km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-               if(km) {
-                       km->poll= keymap->poll; /* lazy init */
-                       km->modal_items= keymap->modal_items;
-                       return km;
-               }
-       }
+               keymap= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
 
-       /* then use default */
-       km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-       return km;
+       return keymap;
 }
 
-wmKeyMap *WM_keymap_copy_to_user(wmKeyMap *keymap)
+void WM_keyconfig_update(wmWindowManager *wm)
 {
-       wmKeyMap *usermap;
+       wmKeyMap *km, *defaultmap, *addonmap, *usermap;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
+       int compat_update = 0;
 
-       usermap= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-
-       /* XXX this function is only used by RMB setting hotkeys, and it clears maps on 2nd try this way */
-       if(keymap==usermap)
-               return keymap;
+       if(!WM_KEYMAP_UPDATE)
+               return;
        
-       if(!usermap) {
-               /* not saved yet, duplicate existing */
-               usermap= MEM_dupallocN(keymap);
-               usermap->modal_items= NULL;
-               usermap->poll= NULL;
-               usermap->flag |= KEYMAP_USER;
+       /* update operator properties for non-modal user keymaps */
+       for(km=U.user_keymaps.first; km; km=km->next) {
+               if((km->flag & KEYMAP_MODAL) == 0) {
+                       for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
+                               if(kmdi->add_item)
+                                       wm_keymap_item_properties_set(kmdi->add_item);
+                               if(kmdi->remove_item)
+                                       wm_keymap_item_properties_set(kmdi->remove_item);
+                       }
 
-               BLI_addtail(&U.keymaps, usermap);
+                       for(kmi=km->items.first; kmi; kmi=kmi->next)
+                               wm_keymap_item_properties_set(kmi);
+               }
        }
-       else {
-               /* already saved, free items for re-copy */
-               WM_keymap_free(usermap);
+
+       /* update U.user_keymaps with user key configuration changes */
+       for(km=wm->userconf->keymaps.first; km; km=km->next) {
+               /* only diff if the user keymap was modified */
+               if(wm_keymap_test_and_clear_update(km)) {
+                       /* find keymaps */
+                       defaultmap= wm_keymap_preset(wm, km);
+                       addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
+
+                       /* diff */
+                       wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km);
+               }
        }
 
-       BLI_duplicatelist(&usermap->items, &keymap->items);
+       /* create user key configuration from preset + addon + user preferences */
+       for(km=wm->defaultconf->keymaps.first; km; km=km->next) {
+               /* find keymaps */
+               defaultmap= wm_keymap_preset(wm, km);
+               addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
+               usermap= WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid);
 
-       for(kmi=usermap->items.first; kmi; kmi=kmi->next) {
-               if(kmi->properties) {
-                       kmi->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
-                       WM_operator_properties_create(kmi->ptr, kmi->idname);
+               /* add */
+               wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap);
 
-                       kmi->properties= IDP_CopyProperty(kmi->properties);
-                       kmi->ptr->data= kmi->properties;
-               }
+               /* in case of old non-diff keymaps, force extra update to create diffs */
+               compat_update = compat_update || (usermap && !(usermap->flag & KEYMAP_DIFF));
        }
 
-       for(kmi=keymap->items.first; kmi; kmi=kmi->next)
-               kmi->flag &= ~KMI_EXPANDED;
+       WM_KEYMAP_UPDATE= 0;
+
+       if(compat_update) {
+               WM_keyconfig_update_tag(NULL, NULL);
+               WM_keyconfig_update(wm);
+       }
+}
+
+/********************************* Event Handling *****************************
+ * Handlers have pointers to the keymap in the default configuration. During
+ * event handling this function is called to get the keymap from the final
+ * configuration. */
+
+wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
+{
+       wmKeyMap *km;
+
+       if(!keymap)
+               return NULL;
+       
+       /* first user defined keymaps */
+       km= WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
+
+       if(km)
+               return km;
 
-       return usermap;
+       return keymap;
 }
 
+/******************************* Keymap Editor ********************************
+ * In the keymap editor the user key configuration is edited. */
+
 void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
 {
        wmWindowManager *wm = CTX_wm_manager(C);
-       wmKeyConfig *keyconf;
-       wmKeyMap *km = NULL;
+       wmKeyMap *defaultmap, *addonmap;
+       wmKeyMapItem *orig;
 
-       /* look in user key config */
-       keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
-       if(keyconf) {
-               km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
-       }
+       if(!keymap)
+               return;
+
+       /* construct default keymap from preset + addons */
+       defaultmap= wm_keymap_preset(wm, keymap);
+       addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
 
-       if (!km) {
-               /* or from default */
-               km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
+       if(addonmap) {
+               defaultmap = wm_keymap_copy(defaultmap);
+               wm_keymap_addon_add(defaultmap, addonmap);
        }
 
-       if (km) {
-               wmKeyMapItem *orig = WM_keymap_item_find_id(km, kmi->id);
+       /* find original item */
+       orig = WM_keymap_item_find_id(defaultmap, kmi->id);
 
-               if (orig) {
-                       if(strcmp(orig->idname, kmi->idname) != 0) {
-                               BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
+       if(orig) {
+               /* restore to original */
+               if(strcmp(orig->idname, kmi->idname) != 0) {
+                       BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
+                       WM_keymap_properties_reset(kmi, NULL);
+               }
 
-                               WM_keymap_properties_reset(kmi, NULL);
-                       }
-                       
-                       if (orig->properties) {
-                               kmi->properties= IDP_CopyProperty(orig->properties);
-                               kmi->ptr->data= kmi->properties;
+               if (orig->properties) {
+                       if(kmi->properties) {
+                               IDP_FreeProperty(kmi->properties);
+                               MEM_freeN(kmi->properties);
+                               kmi->properties= NULL;
                        }
 
-                       kmi->propvalue = orig->propvalue;
-                       kmi->type = orig->type;
-                       kmi->val = orig->val;
-                       kmi->shift = orig->shift;
-                       kmi->ctrl = orig->ctrl;
-                       kmi->alt = orig->alt;
-                       kmi->oskey = orig->oskey;
-                       kmi->keymodifier = orig->keymodifier;
-                       kmi->maptype = orig->maptype;
-
+                       kmi->properties= IDP_CopyProperty(orig->properties);
+                       kmi->ptr->data= kmi->properties;
                }
 
+               kmi->propvalue = orig->propvalue;
+               kmi->type = orig->type;
+               kmi->val = orig->val;
+               kmi->shift = orig->shift;
+               kmi->ctrl = orig->ctrl;
+               kmi->alt = orig->alt;
+               kmi->oskey = orig->oskey;
+               kmi->keymodifier = orig->keymodifier;
+               kmi->maptype = orig->maptype;
+
+               WM_keyconfig_update_tag(keymap, kmi);
+       }
+
+       /* free temporary keymap */
+       if(addonmap) {
+               WM_keymap_free(defaultmap);
+               MEM_freeN(defaultmap);
        }
 }
 
-void WM_keymap_restore_to_default(wmKeyMap *keymap)
+void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C)
 {
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmKeyMap *usermap;
 
-       usermap= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
+       /* remove keymap from U.user_keymaps and update */
+       usermap= WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
 
        if(usermap) {
                WM_keymap_free(usermap);
-               BLI_freelinkN(&U.keymaps, usermap);
+               BLI_freelinkN(&U.user_keymaps, usermap);
+
+               WM_keyconfig_update_tag(NULL, NULL);
+               WM_keyconfig_update(wm);
        }
 }
 
@@ -951,3 +1332,4 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
        
        return km;
 }
+
index d3138f33ad74c94422635ea77ee6a4f5b489cadb..16d6ba4fd169e26d1a86521624ea024c6ff21853 100644 (file)
@@ -3721,7 +3721,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
 
        /* menus that can be accessed anywhere in blender */
        WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_menu(keymap, "VIEW3D_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
+       WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
 
        /* Space switching */
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F2KEY, KM_PRESS, KM_SHIFT, 0); /* new in 2.5x, was DXF export */
index 0c8aa6a59595ac459db52faf016fd326481b2a72..54befa03daaf9edfe9d9b2ffc6a5c7dc53304e36 100644 (file)
@@ -209,10 +209,12 @@ struct wmKeyMap *WM_keymap_list_find(struct ListBase *lb, char *idname, int spac
 struct wmKeyConfig *WM_keyconfig_new(struct wmWindowManager *wm, char *idname){return (struct wmKeyConfig *) NULL;}
 struct wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, char *idname){return (struct wmKeyConfig *) NULL;}
 void WM_keyconfig_remove(struct wmWindowManager *wm, char *idname){}
+void WM_keyconfig_set_active(struct wmWindowManager *wm, const char *idname) {}
 void WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi){}
 void WM_keymap_restore_to_default(struct wmKeyMap *keymap){}
 void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi){}
 void WM_keymap_properties_reset(struct wmKeyMapItem *kmi){}
+void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) {}
 int WM_keymap_user_init(struct wmWindowManager *wm, struct wmKeyMap *keymap) {return 0;}
 int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2){return 0;}