[Bf-blender-cvs] [0137777137c] soc-2020-custom-menus: Custom Menus : fix minor bugs

TempoDev noreply at git.blender.org
Sat Aug 15 03:54:31 CEST 2020


Commit: 0137777137cd0e545df499e4783ab2699c0b3039
Author: TempoDev
Date:   Fri Aug 14 03:05:34 2020 +0200
Branches: soc-2020-custom-menus
https://developer.blender.org/rB0137777137cd0e545df499e4783ab2699c0b3039

Custom Menus : fix minor bugs

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

M	release/scripts/modules/rna_user_menus_ui.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M	release/scripts/startup/bl_operators/userpref.py
M	release/scripts/startup/bl_operators/wm.py
M	source/blender/blenkernel/intern/blender_user_menu.c
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/screen_user_menu.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/modules/rna_user_menus_ui.py b/release/scripts/modules/rna_user_menus_ui.py
index 3ea07348da4..7b058d0c5c5 100644
--- a/release/scripts/modules/rna_user_menus_ui.py
+++ b/release/scripts/modules/rna_user_menus_ui.py
@@ -73,7 +73,7 @@ def draw_button(context, box, item, index):
     row.prop(item, "is_selected", icon=item.icon, text=name, toggle=1)
     if item.type == "SUBMENU":
         sm = item.get_submenu()
-        if um.active_group.is_pie and index >= 0:
+        if um.active_group.type == "PIE" and index >= 0:
             row.operator("preferences.pie_menuitem_add", text="", icon='ADD').index = index
             row.operator("preferences.menuitem_remove", text="", icon='REMOVE')
             row.operator("preferences.menuitem_up", text="", icon='TRIA_UP')
@@ -213,9 +213,9 @@ def draw_user_menu_preference(context, layout):
     if umg != qf:
         row.prop(umg, "name")
         pie_text = "List"
-        if umg.is_pie:
+        if umg.type == "PIE":
             pie_text = "Pie"
-        row.prop(umg, "is_pie", text=pie_text, toggle=True)
+        row.prop(umg, "type", text=pie_text, expand=True)
     if kmi:
         row.prop(kmi, "map_type", text="")
         map_type = kmi.map_type
@@ -284,7 +284,7 @@ def draw_user_menus(context, layout):
     row = layout.row()
     row.separator()
 
-    if um.active_group.is_pie:
+    if um.active_group.type == "PIE":
         draw_pie(context=context, row=row)
     else:
         draw_item_box(context=context, row=row)
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 105f0c18a7f..3a7bebf8be3 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -409,7 +409,7 @@ def km_window(params):
         ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None),
 
         # Quick menu and toolbar
-        op_user_menu("USER_MT_QUICK_FAVORITES", {"type": 'Q', "value": 'PRESS'}),
+        op_user_menu("QUICK_FAVORITES", {"type": 'Q', "value": 'PRESS'}),
 
         # Fast editor switching
         *(
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index 3de1f3480b0..90de33d8d3c 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -212,7 +212,7 @@ def km_window(params):
         ("wm.quit_blender", {"type": 'Q', "value": 'PRESS', "ctrl": True}, None),
 
         # Quick menu and toolbar
-        op_user_menu("USER_MT_QUICK_FAVORITES", {"type": 'Q', "value": 'PRESS'}),
+        op_user_menu("QUICK_FAVORITES", {"type": 'Q', "value": 'PRESS'}),
 
         # NDOF settings
         op_panel("USERPREF_PT_ndof_settings", {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'}),
diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py
index 73179e302fc..95820f1dc06 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -1197,7 +1197,16 @@ class PREFERENCES_OT_usermenus_add(Operator):
 
 class PREFERENCES_OT_usermenus_remove(Operator):
     bl_idname = "preferences.usermenus_remove"
-    bl_label = "add an user menus group"
+    bl_label = "remove an user menus group"
+
+    @classmethod
+    def poll(self, context):
+        prefs = context.preferences
+        um = prefs.user_menus
+
+        if um.active_group.idname == "QUICK_FAVORITES":
+            return False
+        return True
 
     def execute(self, _context):
         prefs = _context.preferences
@@ -1231,9 +1240,9 @@ class PREFERENCES_OT_menuitem_remove(Operator):
         prefs = context.preferences
         um = prefs.user_menus
         can_remove = um.active_item
-        is_pie = um.active_group.is_pie
+        um_type = um.active_group.type
 
-        if is_pie and can_remove:
+        if um_type == "PIE" and can_remove:
             if not can_remove.parent:
                 return False
         return can_remove
@@ -1256,11 +1265,11 @@ class PREFERENCES_OT_menuitem_up(Operator):
         prefs = context.preferences
         um = prefs.user_menus
         current = um.active_item
-        is_pie = um.active_group.is_pie
+        um_type = um.active_group.type
         if not current:
             return False
         
-        if is_pie:
+        if um_type == "PIE":
             if not current.parent:
                 return False
             prev_item = current.prev
@@ -1292,12 +1301,12 @@ class PREFERENCES_OT_menuitem_down(Operator):
     def poll(self, context):
         prefs = context.preferences
         um = prefs.user_menus
-        is_pie = um.active_group.is_pie
+        um_type = um.active_group.type
         current = um.active_item
         if not current:
             return False
         
-        if is_pie:
+        if um_type == "PIE":
             if not current.parent:
                 return False
             next_item = current.next
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 0b2fb3892d2..9925cf6dbe0 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -2636,7 +2636,7 @@ class WM_OT_call_user_menu(Operator):
         umg = um.get_group(idname=self.name)
 
         layout = menu.layout
-        if umg.is_pie:
+        if umg.type == "PIE":
             layout = layout.menu_pie()
         um.draw_menu(context=context, layout=layout, menu=umg)
 
@@ -2646,7 +2646,7 @@ class WM_OT_call_user_menu(Operator):
         wm = context.window_manager
         umg = um.get_group(idname=self.name)
 
-        if umg.is_pie:
+        if umg.type == "PIE":
             wm.popup_menu_pie(draw_func=self.draw_menu, title=umg.name, event=event)
         else:
             wm.popup_menu(self.draw_menu, title=umg.name)
diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c
index 26068930737..cb77adff108 100644
--- a/source/blender/blenkernel/intern/blender_user_menu.c
+++ b/source/blender/blenkernel/intern/blender_user_menu.c
@@ -64,7 +64,6 @@ void BKE_blender_user_menus_group_idname_update(bUserMenusGroup *umg)
 {
   char name[64];
 
-  STRNCPY(umg->idname, "USER_MT_");
   STRNCPY(name, umg->name);
   for (int i = 0; name[i]; i++) {
     if (name[i] == ' ')
@@ -72,7 +71,7 @@ void BKE_blender_user_menus_group_idname_update(bUserMenusGroup *umg)
     if (name[i] >= 'a' && name[i] <= 'z')
       name[i] += 'A' - 'a';
   }
-  strcat(umg->idname, name);
+  STRNCPY(umg->idname, name);
   BLI_uniquename(&U.user_menus,
                  umg,
                  umg->idname,
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 747200e9aeb..96fb8a689dd 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -618,8 +618,8 @@ UserDef *BKE_blendfile_userdef_from_defaults(void)
   {
     bUserMenusGroup *umg = MEM_mallocN(sizeof(*umg), __func__);
     STRNCPY(umg->name, "Quick Favorites");
-    STRNCPY(umg->idname, "USER_MT_QUICK_FAVORITES");
-    umg->pie = false;
+    STRNCPY(umg->idname, "QUICK_FAVORITES");
+    umg->type = 0;
     umg->prev = NULL;
     umg->next = NULL;
     BLI_listbase_clear(&umg->menus);
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 7ce93f65f06..df1d08f7c76 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -422,10 +422,10 @@ void ED_screen_user_menu_register(void);
 bool screen_user_menu_draw_items(const struct bContext *C,
                                  struct uiLayout *layout,
                                  struct ListBase *lb,
-                                 bool is_pie);
+                                 char type);
 void screen_user_menu_draw_begin(struct bContext *C,
                                  struct uiLayout *layout,
-                                 bool is_pie,
+                                 char type,
                                  struct bUserMenusGroup *umg);
 
 /* Cache display helpers */
diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c
index e64d8a12962..ead17156f9c 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -275,17 +275,17 @@ static void screen_user_menu_draw_submenu(bContext *C, uiLayout *layout, void *a
   screen_user_menu_draw_items(C, layout, lb, false);
 }
 
-bool screen_user_menu_draw_items(const bContext *C, uiLayout *layout, ListBase *lb, bool is_pie)
+bool screen_user_menu_draw_items(const bContext *C, uiLayout *layout, ListBase *lb, char type)
 {
   /* Enable when we have the ability to edit menus. */
   char label[512];
-  const bool show_missing = is_pie;
+  const bool show_missing = type;
   bool is_empty = true;
 
   int i = 0;
 
   LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
-    if (is_pie && i > 7)
+    if (type == 1 && i > 7)
       return is_empty;
     const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL;
     if (umi->type == USER_MENU_TYPE_OPERATOR) {
@@ -375,7 +375,7 @@ bool screen_user_menu_draw_items(const bContext *C, uiLayout *layout, ListBase *
   return is_empty;
 }
 
-void screen_user_menu_draw_begin(bContext *C, uiLayout *layout, bool is_pie, bUserMenusGroup *umg)
+void screen_user_menu_draw_begin(bContext *C, uiLayout *layout, char type, bUserMenusGroup *umg)
 {
   uint um_array_len;
   bUserMenu **um_array = ED_screen_user_menus_find_menu(C, &um_array_len, umg);
@@ -391,7 +391,7 @@ void screen_user_menu_draw_begin(bContext *C, uiLayout *layout, bool is_pie, bUs
     MEM_freeN(um_array);
   }
 
-  if (is_empty && !is_pie) {
+  if (is_empty && type == 0) {
     uiItemL(layout, TIP_("No menu items found"), ICON_NONE);
     uiItemL(lay

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list