From 552f5da3c4852cdcdfd745bf256de21a2d264f34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 May 2019 15:30:48 +1000 Subject: Mitigate T64346: Quick Favorites items cant be removed For now don't show missing quick favorite menu items which are missing. Once menu editing is supported they could be displayed. --- source/blender/editors/include/UI_interface.h | 1 + .../blender/editors/interface/interface_layout.c | 18 ++++++---- source/blender/editors/screen/screen_user_menu.c | 40 +++++++++++++++++----- 3 files changed, 43 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index fddd8f09b87..bf728ec7772 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2251,6 +2251,7 @@ void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ /* label icon for dragging */ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* menu */ +void uiItemM_ptr(uiLayout *layout, struct MenuType *mt, const char *name, int icon); void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon); /* menu contents */ void uiItemMContents(uiLayout *layout, const char *menuname); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a3906879fd7..b89767171ab 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2773,14 +2773,8 @@ static uiBut *ui_item_menu(uiLayout *layout, return but; } -void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) +void uiItemM_ptr(uiLayout *layout, MenuType *mt, const char *name, int icon) { - MenuType *mt = WM_menutype_find(menuname, false); - if (mt == NULL) { - RNA_warning("not found %s", menuname); - return; - } - if (!name) { name = CTX_IFACE_(mt->translation_context, mt->label); } @@ -2799,6 +2793,16 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) false); } +void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) +{ + MenuType *mt = WM_menutype_find(menuname, false); + if (mt == NULL) { + RNA_warning("not found %s", menuname); + return; + } + uiItemM_ptr(layout, mt, name, icon); +} + void uiItemMContents(uiLayout *layout, const char *menuname) { MenuType *mt = WM_menutype_find(menuname, false); diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c index 0ec989db12b..08b9d010f79 100644 --- a/source/blender/editors/screen/screen_user_menu.c +++ b/source/blender/editors/screen/screen_user_menu.c @@ -194,6 +194,10 @@ void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi) static void screen_user_menu_draw(const bContext *C, Menu *menu) { + /* Enable when we have the ability to edit menus. */ + const bool show_missing = false; + char label[512]; + uint um_array_len; bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len); bool is_empty = true; @@ -206,15 +210,32 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; - IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; - uiItemFullO( - menu->layout, umi_op->op_idname, ui_name, ICON_NONE, prop, umi_op->opcontext, 0, NULL); - is_empty = false; + wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false); + if (ot != NULL) { + IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : NULL; + uiItemFullO_ptr(menu->layout, ot, ui_name, ICON_NONE, prop, umi_op->opcontext, 0, NULL); + is_empty = false; + } + else { + if (show_missing) { + SNPRINTF(label, "Missing: %s", umi_op->op_idname); + uiItemL(menu->layout, label, ICON_NONE); + } + } } else if (umi->type == USER_MENU_TYPE_MENU) { bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; - uiItemM(menu->layout, umi_mt->mt_idname, ui_name, ICON_NONE); - is_empty = false; + MenuType *mt = WM_menutype_find(umi_mt->mt_idname, false); + if (mt != NULL) { + uiItemM_ptr(menu->layout, mt, ui_name, ICON_NONE); + is_empty = false; + } + else { + if (show_missing) { + SNPRINTF(label, "Missing: %s", umi_mt->mt_idname); + uiItemL(menu->layout, label, ICON_NONE); + } + } } else if (umi->type == USER_MENU_TYPE_PROP) { bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; @@ -252,9 +273,10 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) } } if (!ok) { - char label[512]; - SNPRINTF(label, "Missing: %s.%s", umi_pr->context_data_path, umi_pr->prop_id); - uiItemL(menu->layout, label, ICON_NONE); + if (show_missing) { + SNPRINTF(label, "Missing: %s.%s", umi_pr->context_data_path, umi_pr->prop_id); + uiItemL(menu->layout, label, ICON_NONE); + } } } else if (umi->type == USER_MENU_TYPE_SEP) { -- cgit v1.2.3