Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_user_menu.c
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
| /** \name Menu Item | /** \name Menu Item | ||||
| * \{ */ | * \{ */ | ||||
| bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb, | bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb, | ||||
| const wmOperatorType *ot, | const wmOperatorType *ot, | ||||
| IDProperty *prop, | IDProperty *prop, | ||||
| short opcontext) | short opcontext) | ||||
| { | { | ||||
| for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { | LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { | ||||
| if (umi->type == USER_MENU_TYPE_OPERATOR) { | if (umi->type == USER_MENU_TYPE_OPERATOR) { | ||||
| bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; | bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; | ||||
| if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) && | if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) && | ||||
| (IDP_EqualsProperties(prop, umi_op->prop))) { | (IDP_EqualsProperties(prop, umi_op->prop))) { | ||||
| return umi_op; | return umi_op; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb, | struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb, | ||||
| const struct MenuType *mt) | const struct MenuType *mt) | ||||
| { | { | ||||
| for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { | LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { | ||||
| if (umi->type == USER_MENU_TYPE_MENU) { | if (umi->type == USER_MENU_TYPE_MENU) { | ||||
| bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; | bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi; | ||||
| if (STREQ(mt->idname, umi_mt->mt_idname)) { | if (STREQ(mt->idname, umi_mt->mt_idname)) { | ||||
| return umi_mt; | return umi_mt; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *lb, | struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *lb, | ||||
| const char *context_data_path, | const char *context_data_path, | ||||
| const char *prop_id, | const char *prop_id, | ||||
| int prop_index) | int prop_index) | ||||
| { | { | ||||
| for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { | LISTBASE_FOREACH (bUserMenuItem *, umi, lb) { | ||||
| if (umi->type == USER_MENU_TYPE_PROP) { | if (umi->type == USER_MENU_TYPE_PROP) { | ||||
| bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; | bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; | ||||
| if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) && | if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) && | ||||
| (prop_index == umi_pr->prop_index)) { | (prop_index == umi_pr->prop_index)) { | ||||
| return umi_pr; | return umi_pr; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void screen_user_menu_draw(const bContext *C, Menu *menu) | ||||
| 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); | ||||
| bool is_empty = true; | bool is_empty = true; | ||||
| 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; | ||||
| } | } | ||||
| for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { | LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) { | ||||
| const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; | const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL; | ||||
| if (umi->type == USER_MENU_TYPE_OPERATOR) { | if (umi->type == USER_MENU_TYPE_OPERATOR) { | ||||
| bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; | bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; | ||||
| wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false); | wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false); | ||||
| if (ot != NULL) { | if (ot != NULL) { | ||||
| IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : 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); | uiItemFullO_ptr(menu->layout, ot, ui_name, ICON_NONE, prop, umi_op->opcontext, 0, NULL); | ||||
| is_empty = false; | is_empty = false; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||