Fix T58327: Quick Favorites "Remove from Favorites" missing for added
Modifiers Since user menu entries from SPACE_BUTS/SPACE_TOPBAR are also shown in other Editors (SPACE_VIEW3D), also allow these entries to be removed from Quick Favorites from these Editors. Match and deduplicate logic from screen_user_menu_draw() and ui_popup_context_menu_for_button(). Reviewers: campbellbarton, brecht Maniphest Tasks: T58327 Differential Revision: https://developer.blender.org/D4112
This commit is contained in:
parent
e6e2f65585
commit
c79b849097
Notes:
blender-bot
2023-02-14 04:51:54 +01:00
Referenced by issue #58327, Quick Favorites "Remove from Favorites" missing for added Modifiers
|
@ -310,7 +310,7 @@ bool ED_operator_camera(struct bContext *C);
|
|||
|
||||
/* screen_user_menu.c */
|
||||
|
||||
struct bUserMenu *ED_screen_user_menu_find(struct bContext *C);
|
||||
bUserMenu **ED_screen_user_menus_find(struct bContext *C, uint *r_len);
|
||||
struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C);
|
||||
|
||||
|
||||
|
|
|
@ -699,8 +699,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
|
|||
"Add to a user defined context menu (stored in the user preferences)");
|
||||
UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL);
|
||||
|
||||
bUserMenu *um = ED_screen_user_menu_find(C);
|
||||
if (um) {
|
||||
uint um_array_len;
|
||||
bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len);
|
||||
for (int um_index = 0; um_index < um_array_len; um_index++) {
|
||||
bUserMenu *um = um_array[um_index];
|
||||
if (um == NULL) {
|
||||
continue;
|
||||
}
|
||||
bUserMenuItem *umi = ui_but_user_menu_find(C, but, um);
|
||||
if (umi != NULL) {
|
||||
but2 = uiDefIconTextBut(
|
||||
|
@ -710,6 +715,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
|
|||
UI_but_func_set(but2, popup_user_menu_remove_func, um, umi);
|
||||
}
|
||||
}
|
||||
MEM_freeN(um_array);
|
||||
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,11 +62,19 @@
|
|||
/** \name Menu Type
|
||||
* \{ */
|
||||
|
||||
bUserMenu *ED_screen_user_menu_find(bContext *C)
|
||||
bUserMenu **ED_screen_user_menus_find(bContext *C, uint *r_len)
|
||||
{
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
const char *context = CTX_data_mode_string(C);
|
||||
return BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context);
|
||||
|
||||
uint array_len = 3;
|
||||
bUserMenu **um_array = MEM_calloc_arrayN(array_len, sizeof(*um_array), __func__);
|
||||
um_array[0] = BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context);
|
||||
um_array[1] = (sl->spacetype != SPACE_TOPBAR) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context) : NULL;
|
||||
um_array[2] = (sl->spacetype == SPACE_VIEW3D) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_BUTS, context) : NULL;
|
||||
|
||||
*r_len = array_len;
|
||||
return um_array;
|
||||
}
|
||||
|
||||
bUserMenu *ED_screen_user_menu_ensure(bContext *C)
|
||||
|
@ -182,15 +190,10 @@ void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi)
|
|||
|
||||
static void screen_user_menu_draw(const bContext *C, Menu *menu)
|
||||
{
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
const char *context = CTX_data_mode_string(C);
|
||||
bUserMenu *um_array[] = {
|
||||
BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context),
|
||||
(sl->spacetype != SPACE_TOPBAR) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_TOPBAR, context) : NULL,
|
||||
(sl->spacetype == SPACE_VIEW3D) ? BKE_blender_user_menu_find(&U.user_menus, SPACE_BUTS, context) : NULL,
|
||||
};
|
||||
uint um_array_len;
|
||||
bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len);
|
||||
bool is_empty = true;
|
||||
for (int um_index = 0; um_index < ARRAY_SIZE(um_array); um_index++) {
|
||||
for (int um_index = 0; um_index < um_array_len; um_index++) {
|
||||
bUserMenu *um = um_array[um_index];
|
||||
if (um == NULL) {
|
||||
continue;
|
||||
|
@ -258,6 +261,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
|
|||
}
|
||||
}
|
||||
}
|
||||
MEM_freeN(um_array);
|
||||
|
||||
if (is_empty) {
|
||||
uiItemL(menu->layout, IFACE_("No menu items found."), ICON_NONE);
|
||||
|
|
Loading…
Reference in New Issue