Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_context_menu.c
| Show First 20 Lines • Show All 685 Lines • ▼ Show 20 Lines | if (but->rnapoin.data && but->rnaprop) { | ||||
| } | } | ||||
| } | } | ||||
| /* Favorites Menu */ | /* Favorites Menu */ | ||||
| if (ui_but_is_user_menu_compatible(C, but)) { | if (ui_but_is_user_menu_compatible(C, but)) { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| const int w = uiLayoutGetWidth(layout); | const int w = uiLayoutGetWidth(layout); | ||||
| uiBut *but2; | uiBut *but2; | ||||
| bool item_found = false; | |||||
| but2 = uiDefIconTextBut( | |||||
| block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, | |||||
| CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"), | |||||
| 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, | |||||
| "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); | |||||
| uint um_array_len; | uint um_array_len; | ||||
| bUserMenu **um_array = ED_screen_user_menus_find(C, &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++) { | for (int um_index = 0; um_index < um_array_len; um_index++) { | ||||
| bUserMenu *um = um_array[um_index]; | bUserMenu *um = um_array[um_index]; | ||||
| if (um == NULL) { | if (um == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bUserMenuItem *umi = ui_but_user_menu_find(C, but, um); | bUserMenuItem *umi = ui_but_user_menu_find(C, but, um); | ||||
| if (umi != NULL) { | if (umi != NULL) { | ||||
| but2 = uiDefIconTextBut( | but2 = uiDefIconTextBut( | ||||
| block, UI_BTYPE_BUT, 0, ICON_BLANK1, | block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, | ||||
| CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Quick Favorites"), | CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Quick Favorites"), | ||||
| 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| UI_but_func_set(but2, popup_user_menu_remove_func, um, umi); | UI_but_func_set(but2, popup_user_menu_remove_func, um, umi); | ||||
| item_found = true; | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(um_array); | MEM_freeN(um_array); | ||||
| if (!item_found) { | |||||
| but2 = uiDefIconTextBut( | |||||
| block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, | |||||
| CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"), | |||||
| 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, | |||||
| "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); | |||||
| } | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
| } | } | ||||
| /* Operator buttons */ | /* Operator buttons */ | ||||
| if (but->optype) { | if (but->optype) { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| uiBut *but2; | uiBut *but2; | ||||
| IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; | IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; | ||||
| ▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines | |||||