From a5b7f1ef535038be549530612c7eed9109e1d4b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 24 Jun 2018 16:07:34 +0200 Subject: UI: internal changes to user-menu storage - Use per context menu lists to support menu editing. - Support for different kinds of menu items since this may be needed in the future. Only use operator types for now. --- source/blender/blenkernel/BKE_blender_user_menu.h | 48 +++++++++ source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/intern/blender.c | 19 ++-- .../blender/blenkernel/intern/blender_user_menu.c | 114 +++++++++++++++++++++ source/blender/blenloader/intern/readfile.c | 18 ++-- source/blender/blenloader/intern/writefile.c | 23 +++-- source/blender/editors/include/ED_screen.h | 15 ++- .../editors/interface/interface_context_menu.c | 40 ++++---- source/blender/editors/screen/screen_user_menu.c | 104 +++++++++++-------- source/blender/makesdna/DNA_userdef_types.h | 31 ++++-- 10 files changed, 322 insertions(+), 91 deletions(-) create mode 100644 source/blender/blenkernel/BKE_blender_user_menu.h create mode 100644 source/blender/blenkernel/intern/blender_user_menu.c diff --git a/source/blender/blenkernel/BKE_blender_user_menu.h b/source/blender/blenkernel/BKE_blender_user_menu.h new file mode 100644 index 00000000000..9f8d1d62951 --- /dev/null +++ b/source/blender/blenkernel/BKE_blender_user_menu.h @@ -0,0 +1,48 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_BLENDER_USER_MENU_H__ + +/** \file BKE_blender_user_menu.h + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ListBase; +struct bUserMenu; +struct bUserMenuItem; + +struct bUserMenu *BKE_blender_user_menu_find( + struct ListBase *lb, char space_type, const char *context); +struct bUserMenu *BKE_blender_user_menu_ensure( + struct ListBase *lb, char space_type, const char *context); + +struct bUserMenuItem *BKE_blender_user_menu_item_add(struct ListBase *lb, int type); +void BKE_blender_user_menu_item_free(struct bUserMenuItem *umi); +void BKE_blender_user_menu_item_free_list(struct ListBase *lb); + +#ifdef __cplusplus +} +#endif + +#endif /* __BKE_BLENDER_USER_MENU_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 15ccd660d83..94a6fc45303 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -77,6 +77,7 @@ set(SRC intern/blender.c intern/blender_copybuffer.c intern/blender_undo.c + intern/blender_user_menu.c intern/blendfile.c intern/bmfont.c intern/boids.c diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 7b41bb62872..23c2147ff7e 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -48,6 +48,7 @@ #include "BKE_addon.h" #include "BKE_blender.h" /* own include */ #include "BKE_blender_version.h" /* own include */ +#include "BKE_blender_user_menu.h" #include "BKE_blendfile.h" #include "BKE_brush.h" #include "BKE_cachefile.h" @@ -206,6 +207,15 @@ static void userdef_free_keymaps(UserDef *userdef) BLI_listbase_clear(&userdef->user_keymaps); } +static void userdef_free_user_menus(UserDef *userdef) +{ + for (bUserMenu *um = userdef->user_menus.first, *um_next; um; um = um_next) { + um_next = um->next; + BKE_blender_user_menu_item_free_list(&um->items); + MEM_freeN(um); + } +} + static void userdef_free_addons(UserDef *userdef) { for (bAddon *addon = userdef->addons.first, *addon_next; addon; addon = addon_next) { @@ -226,6 +236,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) #endif userdef_free_keymaps(userdef); + userdef_free_user_menus(userdef); userdef_free_addons(userdef); if (clear_fonts) { @@ -241,14 +252,6 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts) BLI_freelistN(&userdef->uifonts); BLI_freelistN(&userdef->themes); - for (bUserMenuItem *umi = userdef->user_menu_items.first, *umi_next; umi; umi = umi_next) { - umi_next = umi->next; - if (umi->prop) { - IDP_FreeProperty(umi->prop); - MEM_freeN(umi->prop); - } - MEM_freeN(umi); - } #undef U } diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c new file mode 100644 index 00000000000..3bb150b8fac --- /dev/null +++ b/source/blender/blenkernel/intern/blender_user_menu.c @@ -0,0 +1,114 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/blender_user_menu.c + * \ingroup bke + * + * User defined menu API. + */ + +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_string.h" + +#include "DNA_userdef_types.h" + +#include "BKE_blender_user_menu.h" +#include "BKE_idprop.h" + +/* -------------------------------------------------------------------- */ +/** \name Menu Type + * \{ */ + +bUserMenu *BKE_blender_user_menu_find( + ListBase *lb, char space_type, const char *context) +{ + for (bUserMenu *um = lb->first; um; um = um->next) { + if ((space_type == um->space_type) && + (STREQ(context, um->context))) + { + return um; + } + } + return NULL; +} + +bUserMenu *BKE_blender_user_menu_ensure( + ListBase *lb, char space_type, const char *context) +{ + bUserMenu *um = BKE_blender_user_menu_find(lb, space_type, context); + if (um == NULL) { + um = MEM_callocN(sizeof(bUserMenu), __func__); + um->space_type = space_type; + STRNCPY(um->context, context); + BLI_addhead(lb, um); + } + return um; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Item + * \{ */ + +bUserMenuItem *BKE_blender_user_menu_item_add(ListBase *lb, int type) +{ + uint size; + + if (type == USER_MENU_TYPE_OPERATOR) { + size = sizeof(bUserMenuItem_Op); + } + else if (type == USER_MENU_TYPE_SEP) { + size = sizeof(bUserMenuItem); + } + else { + BLI_assert(0); + } + + bUserMenuItem *umi = MEM_callocN(size, __func__); + umi->type = type; + BLI_addtail(lb, umi); + return umi; +} + +void BKE_blender_user_menu_item_free(bUserMenuItem *umi) +{ + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + if (umi_op->prop) { + IDP_FreeProperty(umi_op->prop); + MEM_freeN(umi_op->prop); + } + } + MEM_freeN(umi); +} + +void BKE_blender_user_menu_item_free_list(ListBase *lb) +{ + for (bUserMenuItem *umi = lb->first, *umi_next; umi; umi = umi_next) { + umi_next = umi->next; + BKE_blender_user_menu_item_free(umi); + } + BLI_listbase_clear(lb); +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 22bd3ee3a17..aa7c48f4873 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8679,6 +8679,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) link_list(fd, &user->themes); link_list(fd, &user->user_keymaps); + link_list(fd, &user->user_menus); link_list(fd, &user->addons); link_list(fd, &user->autoexec_paths); @@ -8704,6 +8705,17 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) direct_link_keymapitem(fd, kmi); } + for (bUserMenu *um = user->user_menus.first; um; um = um->next) { + link_list(fd, &um->items); + for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + umi_op->prop = newdataadr(fd, umi_op->prop); + IDP_DirectLinkGroup_OrFree(&umi_op->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + } + } + } + for (addon = user->addons.first; addon; addon = addon->next) { addon->prop = newdataadr(fd, addon->prop); IDP_DirectLinkGroup_OrFree(&addon->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); @@ -8713,12 +8725,6 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) user->uifonts.first = user->uifonts.last= NULL; link_list(fd, &user->uistyles); - link_list(fd, &user->user_menu_items); - - for (bUserMenuItem *umi = user->user_menu_items.first; umi; umi = umi->next) { - umi->prop = newdataadr(fd, umi->prop); - IDP_DirectLinkGroup_OrFree(&umi->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } /* free fd->datamap again */ oldnewmap_free_unused(fd->datamap); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 5652ad895d3..1a33b9440b5 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1244,6 +1244,22 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) } } + for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) { + writestruct(wd, DATA, bUserMenu, 1, um); + for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi; + writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op); + if (umi_op->prop) { + IDP_WriteProperty(umi_op->prop, wd); + } + } + else { + writestruct(wd, DATA, bUserMenuItem, 1, umi); + } + } + } + for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) { writestruct(wd, DATA, bAddon, 1, bext); if (bext->prop) { @@ -1258,13 +1274,6 @@ static void write_userdef(WriteData *wd, const UserDef *userdef) for (const uiStyle *style = userdef->uistyles.first; style; style = style->next) { writestruct(wd, DATA, uiStyle, 1, style); } - - for (const bUserMenuItem *umi = userdef->user_menu_items.first; umi; umi = umi->next) { - writestruct(wd, DATA, bUserMenuItem, 1, umi); - if (umi->prop) { - IDP_WriteProperty(umi->prop, wd); - } - } } static void write_boid_state(WriteData *wd, BoidState *state) diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 05b51dff4b4..cb4048ac63e 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -315,13 +315,18 @@ int ED_operator_camera(struct bContext *C); /* screen_user_menu.c */ -void ED_screen_user_menu_add( - struct bContext *C, const char *ui_name, +struct bUserMenu *ED_screen_user_menu_find(struct bContext *C); +struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C); + + +struct bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + struct ListBase *lb, struct wmOperatorType *ot, struct IDProperty *prop, short opcontext); -void ED_screen_user_menu_remove(struct bUserMenuItem *umi); -struct bUserMenuItem *ED_screen_user_menu_find( - struct bContext *C, +void ED_screen_user_menu_item_add_operator( + struct ListBase *lb, const char *ui_name, struct wmOperatorType *ot, struct IDProperty *prop, short opcontext); +void ED_screen_user_menu_item_remove( + struct ListBase *lb, struct bUserMenuItem *umi); void ED_screen_user_menu_register(void); /* Cache display helpers */ diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index fa09b316fb8..f28d80bebe1 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -216,13 +216,11 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) UI_popup_block_ex(C, menu_add_shortcut, NULL, menu_add_shortcut_cancel, but, NULL); } -static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *arg2) +static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2)) { uiBut *but = arg1; - bUserMenuItem *umi = arg2; - if (umi) { - ED_screen_user_menu_remove(umi); - } + bUserMenu *um = ED_screen_user_menu_ensure(C); + char drawstr[sizeof(but->drawstr)]; STRNCPY(drawstr, but->drawstr); if (but->flag & UI_BUT_HAS_SEP_CHAR) { @@ -231,13 +229,16 @@ static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *a *sep = '\0'; } } - ED_screen_user_menu_add(C, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); + ED_screen_user_menu_item_add_operator( + &um->items, drawstr, + but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); } -static void popup_user_menu_remove_func(bContext *UNUSED(C), void *UNUSED(arg1), void *arg2) +static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2) { + bUserMenu *um = arg1; bUserMenuItem *umi = arg2; - ED_screen_user_menu_remove(umi); + ED_screen_user_menu_item_remove(&um->items, umi); } static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop) @@ -616,21 +617,24 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) uiItemS(layout); { - bUserMenuItem *umi = ED_screen_user_menu_find( - C, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext); - but2 = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Favorites Menu"), 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, umi); - if (umi) { - but2 = uiDefIconTextBut( - block, UI_BTYPE_BUT, 0, ICON_CANCEL, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Favorites Menu"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - UI_but_func_set(but2, popup_user_menu_remove_func, NULL, umi); + UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL); + + bUserMenu *um = ED_screen_user_menu_find(C); + if (um) { + bUserMenuItem_Op *umi_op = ED_screen_user_menu_item_find_operator( + &um->items, but->optype, prop, but->opcontext); + if (umi_op != NULL) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_CANCEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Favorites Menu"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + UI_but_func_set(but2, popup_user_menu_remove_func, um, umi_op); + } } } diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c index 682439f0db3..ab5a3a4008c 100644 --- a/source/blender/editors/screen/screen_user_menu.c +++ b/source/blender/editors/screen/screen_user_menu.c @@ -43,6 +43,7 @@ #include "BLT_translation.h" +#include "BKE_blender_user_menu.h" #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_idprop.h" @@ -56,57 +57,66 @@ #include "UI_resources.h" /* -------------------------------------------------------------------- */ -/** \name Utilities +/** \name Menu Type * \{ */ -void ED_screen_user_menu_add( - bContext *C, const char *ui_name, - wmOperatorType *ot, IDProperty *prop, short opcontext) +bUserMenu *ED_screen_user_menu_find(bContext *C) { SpaceLink *sl = CTX_wm_space_data(C); - bUserMenuItem *umi = MEM_callocN(sizeof(bUserMenuItem), __func__); - umi->space_type = sl ? sl->spacetype : SPACE_EMPTY; - umi->opcontext = opcontext; - if (!STREQ(ui_name, ot->name)) { - BLI_strncpy(umi->ui_name, ui_name, OP_MAX_TYPENAME); - } - BLI_strncpy(umi->opname, ot->idname, OP_MAX_TYPENAME); - BLI_strncpy(umi->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); - umi->prop = prop ? IDP_CopyProperty(prop) : NULL; - BLI_addtail(&U.user_menu_items, umi); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_find(&U.user_menus, sl->spacetype, context); } -void ED_screen_user_menu_remove(bUserMenuItem *umi) +bUserMenu *ED_screen_user_menu_ensure(bContext *C) { - BLI_remlink(&U.user_menu_items, umi); - if (umi->prop) { - IDP_FreeProperty(umi->prop); - MEM_freeN(umi->prop); - } - MEM_freeN(umi); + SpaceLink *sl = CTX_wm_space_data(C); + const char *context = CTX_data_mode_string(C); + return BKE_blender_user_menu_ensure(&U.user_menus, sl->spacetype, context); } -bUserMenuItem *ED_screen_user_menu_find( - bContext *C, +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Menu Item + * \{ */ + +bUserMenuItem_Op *ED_screen_user_menu_item_find_operator( + ListBase *lb, wmOperatorType *ot, IDProperty *prop, short opcontext) { - SpaceLink *sl = CTX_wm_space_data(C); - const char *context = CTX_data_mode_string(C); - for (bUserMenuItem *umi = U.user_menu_items.first; umi; umi = umi->next) { - if (STREQ(ot->idname, umi->opname) && - (opcontext == umi->opcontext) && - (IDP_EqualsProperties(prop, umi->prop))) - { - if ((ELEM(umi->space_type, SPACE_TOPBAR) || (sl->spacetype == umi->space_type)) && - (STREQLEN(context, umi->context, OP_MAX_TYPENAME))) + for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) { + if (umi->type == USER_MENU_TYPE_OPERATOR) { + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; + if (STREQ(ot->idname, umi_op->opname) && + (opcontext == umi_op->opcontext) && + (IDP_EqualsProperties(prop, umi_op->prop))) { - return umi; + return umi_op; } } } return NULL; } +void ED_screen_user_menu_item_add_operator( + ListBase *lb, const char *ui_name, + wmOperatorType *ot, IDProperty *prop, short opcontext) +{ + bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)BKE_blender_user_menu_item_add(lb, USER_MENU_TYPE_OPERATOR); + umi_op->opcontext = opcontext; + if (!STREQ(ui_name, ot->name)) { + BLI_strncpy(umi_op->item.ui_name, ui_name, OP_MAX_TYPENAME); + } + BLI_strncpy(umi_op->opname, ot->idname, OP_MAX_TYPENAME); + umi_op->prop = prop ? IDP_CopyProperty(prop) : NULL; +} + +void ED_screen_user_menu_item_remove(ListBase *lb, bUserMenuItem *umi) +{ + BLI_remlink(lb, umi); + BKE_blender_user_menu_item_free(umi); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -117,14 +127,26 @@ 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); - for (bUserMenuItem *umi = U.user_menu_items.first; umi; umi = umi->next) { - if ((ELEM(umi->space_type, SPACE_TOPBAR) || (sl->spacetype == umi->space_type)) && - (STREQLEN(context, umi->context, OP_MAX_TYPENAME))) - { - IDProperty *prop = umi->prop ? IDP_CopyProperty(umi->prop) : NULL; - uiItemFullO( - menu->layout, umi->opname, umi->ui_name[0] ? umi->ui_name : NULL, - ICON_NONE, prop, umi->opcontext, 0, NULL); + 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, + }; + for (int um_index = 0; um_index < ARRAY_SIZE(um_array); um_index++) { + bUserMenu *um = um_array[um_index]; + if (um == NULL) { + continue; + } + for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) { + 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->opname, umi->ui_name[0] ? umi->ui_name : NULL, + ICON_NONE, prop, umi_op->opcontext, 0, NULL); + } + else if (umi->type == USER_MENU_TYPE_SEP) { + uiItemS(menu->layout); + } } } } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1230efbc247..c24895e3640 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -430,16 +430,35 @@ typedef struct bPathCompare { char flag, pad[7]; } bPathCompare; +typedef struct bUserMenu { + struct bUserMenu *next, *prev; + char space_type; + char _pad0[7]; + char context[64]; + /* bUserMenuItem */ + ListBase items; +} bUserMenu; + +/* May be part of bUserMenu or other list. */ typedef struct bUserMenuItem { struct bUserMenuItem *next, *prev; - char space_type; - char opcontext; - char _pad0[6]; char ui_name[64]; + char type; + char _pad0[7]; +} bUserMenuItem; + +typedef struct bUserMenuItem_Op { + bUserMenuItem item; char opname[64]; - char context[64]; struct IDProperty *prop; -} bUserMenuItem; + char opcontext; + char _pad0[7]; +} bUserMenuItem_Op; + +enum { + USER_MENU_TYPE_SEP = 1, + USER_MENU_TYPE_OPERATOR = 2, +}; typedef struct SolidLight { int flag, pad; @@ -522,7 +541,7 @@ typedef struct UserDef { struct ListBase user_keymaps; struct ListBase addons; struct ListBase autoexec_paths; - struct ListBase user_menu_items; /* bUserMenuItem */ + struct ListBase user_menus; /* bUserMenu */ char keyconfigstr[64]; -- cgit v1.2.3