[Bf-blender-cvs] [4e04c9b874a] soc-2020-custom-menus: Custom menu: Add section in preference

TempoDev noreply at git.blender.org
Wed Jun 3 14:37:01 CEST 2020


Commit: 4e04c9b874a1eee340280c84b416df3a918a6bfe
Author: TempoDev
Date:   Tue Jun 2 16:49:33 2020 +0200
Branches: soc-2020-custom-menus
https://developer.blender.org/rB4e04c9b874a1eee340280c84b416df3a918a6bfe

Custom menu: Add section in preference

===================================================================

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/tools

===================================================================

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 0fd21a7cc38..a6b1e6365f5 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 0fd21a7cc382066d184fda8153f925bb825af2c6
+Subproject commit a6b1e6365f57a83b323cf781e50ada3fa1b3f73f
diff --git a/release/scripts/addons b/release/scripts/addons
index 9a9832d5d7f..5d33d1a1c25 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 9a9832d5d7fe61a446516f2e2722f8356bd7e709
+Subproject commit 5d33d1a1c2531e64bda78d46b517571f2b1e98e7
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 63fc44aed38..46a3da683b4 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1668,7 +1668,37 @@ class USERPREF_PT_keymap(KeymapPanel, Panel):
         # Keymap Settings
         draw_keymaps(context, layout)
 
-        # print("runtime", time.time() - start)
+# -----------------------------------------------------------------------------
+# Custom Menu Editor Panels
+
+class CustomMenuPanel:
+    bl_space_type = 'PREFERENCES'
+    bl_region_type = 'WINDOW'
+    bl_context = "CustomMenu"
+
+
+#class USERPREF_MT_keyconfigs(Menu):
+#    bl_label = "KeyPresets"
+#    preset_subdir = "keyconfig"
+#    preset_operator = "preferences.keyconfig_activate"
+
+#    def draw(self, context):
+#        Menu.draw_preset(self, context)
+
+
+class USERPREF_PT_custom_menu(CustomMenuPanel, Panel):
+    bl_label = "CustomMenu"
+    bl_options = {'HIDE_HEADER'}
+
+    def draw(self, context):
+        from rna_keymap_ui import draw_keymaps
+
+        layout = self.layout
+
+        import time
+        start = time.time()
+        draw_keymaps(context, layout)
+        print("runtime", time.time() - start)
 
 
 # -----------------------------------------------------------------------------
@@ -2223,6 +2253,7 @@ classes = (
     USERPREF_PT_navigation_fly_walk_gravity,
 
     USERPREF_PT_keymap,
+    USERPREF_PT_custom_menu,
     USERPREF_PT_addons,
 
     USERPREF_PT_studiolight_lights,
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 019e4c9ea9e..d7dfea2105e 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -909,16 +909,17 @@ typedef enum eUserPref_Section {
   USER_SECTION_ADDONS = 6,
   USER_SECTION_LIGHT = 7,
   USER_SECTION_KEYMAP = 8,
+  USER_SECTION_CUSTOM_MENU = 9,
 #ifdef WITH_USERDEF_WORKSPACES
-  USER_SECTION_WORKSPACE_CONFIG = 9,
-  USER_SECTION_WORKSPACE_ADDONS = 10,
-  USER_SECTION_WORKSPACE_KEYMAPS = 11,
+  USER_SECTION_WORKSPACE_CONFIG = 10,
+  USER_SECTION_WORKSPACE_ADDONS = 11,
+  USER_SECTION_WORKSPACE_KEYMAPS = 12,
 #endif
-  USER_SECTION_VIEWPORT = 12,
-  USER_SECTION_ANIMATION = 13,
-  USER_SECTION_NAVIGATION = 14,
-  USER_SECTION_FILE_PATHS = 15,
-  USER_SECTION_EXPERIMENTAL = 16,
+  USER_SECTION_VIEWPORT = 13,
+  USER_SECTION_ANIMATION = 14,
+  USER_SECTION_NAVIGATION = 15,
+  USER_SECTION_FILE_PATHS = 16,
+  USER_SECTION_EXPERIMENTAL = 17,
 } eUserPref_Section;
 
 /** #UserDef_SpaceData.flag (State of the user preferences UI). */
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 65c43ebc151..682451310ad 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -472,6 +472,7 @@ extern StructRNA RNA_PreferencesEdit;
 extern StructRNA RNA_PreferencesFilePaths;
 extern StructRNA RNA_PreferencesInput;
 extern StructRNA RNA_PreferencesKeymap;
+extern StructRNA RNA_PreferencesCustomMenu;
 extern StructRNA RNA_PreferencesSystem;
 extern StructRNA RNA_PreferencesView;
 extern StructRNA RNA_Property;
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 7a439a11a54..9149c7c368b 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1840,7 +1840,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
 {
   StructRNA *srna = DefRNA.laststruct;
   int i, defaultfound = 0;
-
+  
   switch (prop->type) {
     case PROP_ENUM: {
       EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 479d0a0d1a7..fca59b842e2 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -88,6 +88,7 @@ const EnumPropertyItem rna_enum_preference_section_items[] = {
     {USER_SECTION_INPUT, "INPUT", 0, "Input", ""},
     {USER_SECTION_NAVIGATION, "NAVIGATION", 0, "Navigation", ""},
     {USER_SECTION_KEYMAP, "KEYMAP", 0, "Keymap", ""},
+    {USER_SECTION_CUSTOM_MENU, "CUSTOM_MENU", 0, "Custom Menu", ""},
     {0, "", 0, NULL, NULL},
     {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""},
     {USER_SECTION_SAVE_LOAD, "SAVE_LOAD", 0, "Save & Load", ""},
@@ -527,6 +528,11 @@ static PointerRNA rna_UserDef_keymap_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_PreferencesKeymap, ptr->data);
 }
 
+static PointerRNA rna_UserDef_custom_menu_get(PointerRNA *ptr)
+{
+  return rna_pointer_inherit_refine(ptr, &RNA_PreferencesCustomMenu, ptr->data);
+}
+
 static PointerRNA rna_UserDef_filepaths_get(PointerRNA *ptr)
 {
   return rna_pointer_inherit_refine(ptr, &RNA_PreferencesFilePaths, ptr->data);
@@ -5880,6 +5886,26 @@ static void rna_def_userdef_keymap(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Key Config", "The name of the active key configuration");
 }
 
+static void rna_def_userdef_custom_menu(BlenderRNA *brna)
+{
+  PropertyRNA *prop;
+
+  StructRNA *srna = RNA_def_struct(brna, "PreferencesCustomMenu", NULL);
+  RNA_def_struct_sdna(srna, "UserDef");
+  RNA_def_struct_nested(brna, srna, "Preferences");
+  RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+  RNA_def_struct_ui_text(srna, "Custom Menu", "custom menu editor");
+
+  prop = RNA_def_property(srna, "show_ui_keyconfig", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(
+      prop, NULL, "space_data.flag", USER_SPACEDATA_INPUT_HIDE_UI_KEYCONFIG);
+  RNA_def_property_ui_text(prop, "Show UI Key-Config", "");
+
+  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");
+}
+
 static void rna_def_userdef_filepaths(BlenderRNA *brna)
 {
   PropertyRNA *prop;
@@ -6200,6 +6226,12 @@ void RNA_def_userdef(BlenderRNA *brna)
   RNA_def_property_pointer_funcs(prop, "rna_UserDef_keymap_get", NULL, NULL, NULL);
   RNA_def_property_ui_text(prop, "Keymap", "Shortcut setup for keyboards and other input devices");
 
+  prop = RNA_def_property(srna, "custom_menu", PROP_POINTER, PROP_NONE);
+  RNA_def_property_flag(prop, PROP_NEVER_NULL);
+  RNA_def_property_struct_type(prop, "PreferencesCustomMenu");
+  RNA_def_property_pointer_funcs(prop, "rna_UserDef_custom_menu_get", NULL, NULL, NULL);
+  RNA_def_property_ui_text(prop, "Custom Menu", "Custom Menu Editor");
+
   prop = RNA_def_property(srna, "filepaths", PROP_POINTER, PROP_NONE);
   RNA_def_property_flag(prop, PROP_NEVER_NULL);
   RNA_def_property_struct_type(prop, "PreferencesFilePaths");
@@ -6267,6 +6299,7 @@ void RNA_def_userdef(BlenderRNA *brna)
   rna_def_userdef_edit(brna);
   rna_def_userdef_input(brna);
   rna_def_userdef_keymap(brna);
+  rna_def_userdef_custom_menu(brna);
   rna_def_userdef_filepaths(brna);
   rna_def_userdef_system(brna);
   rna_def_userdef_addon(brna);
diff --git a/source/tools b/source/tools
index 8a36c2833db..5cf2fc3e5dc 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 8a36c2833db48ed78c436ee19534ce5cf3b2eeee
+Subproject commit 5cf2fc3e5dc28025394b57d8743401295528f310



More information about the Bf-blender-cvs mailing list