73 #define MENU_SEP "\xe2\x96\xb6"
161 const uint str_size = strlen(
str) + 1;
163 memcpy(str_dst,
str, str_size);
185 const char *drawstr_override =
NULL;
189 const bool drawstr_is_empty = (drawstr_sep == but->
drawstr) || (but->
drawstr[0] ==
'\0');
192 if (drawstr_is_empty) {
208 if (drawstr_is_empty) {
210 const int value_enum = (int)but->
hardmax;
214 drawstr_override = enum_item.name;
218 drawstr_override =
"Unknown";
229 printf(
"Button '%s' in menu '%s' is a menu item with unsupported RNA type %d\n",
250 if (drawstr_override !=
NULL) {
251 const char *drawstr_suffix = drawstr_sep ? drawstr_sep :
"";
252 char *drawstr_alloc =
BLI_string_joinN(
"(", drawstr_override,
")", drawstr_suffix);
280 bool changed =
false;
281 switch (item->
type) {
338 for (
int handler_index = 0; handler_index <
ARRAY_SIZE(handlers); handler_index++) {
339 if (handlers[handler_index] ==
NULL) {
351 if (handler_base->poll ==
NULL || handler_base->poll(region, win->
eventstate)) {
359 if (
STR_ELEM(kmi->idname,
"WM_OT_call_menu",
"WM_OT_call_menu_pie")) {
462 const char *idname_array[] = {
464 "TOPBAR_MT_file_open_recent",
466 for (
int i = 0; i <
ARRAY_SIZE(idname_array); i++) {
490 const char *idname_array[] = {
492 "OUTLINER_MT_context_menu",
494 for (
int i = 0; i <
ARRAY_SIZE(idname_array); i++) {
506 int space_type_ui_items_len = 0;
507 bool space_type_ui_items_free =
false;
510 const char *global_menu_prefix =
NULL;
512 if (include_all_areas) {
530 &space_type_ui_items,
531 &space_type_ui_items_len,
532 &space_type_ui_items_free);
534 wm_contexts =
BLI_memarena_calloc(memarena,
sizeof(*wm_contexts) * space_type_ui_items_len);
535 for (
int i = 0; i < space_type_ui_items_len; i++) {
556 if (value_best > value_test) {
579 if (include_all_areas) {
609 const char *idname_array[2] = {
NULL};
610 int idname_array_len = 0;
614 idname_array[idname_array_len++] =
"TOPBAR_MT_editor_menus";
617 #define SPACE_MENU_MAP(space_type, menu_id) \
619 idname_array[idname_array_len++] = menu_id; \
621 #define SPACE_MENU_NOP(space_type) \
639 "TIME_MT_editor_menus" :
640 "DOPESHEET_MT_editor_menus");
647 "CLIP_MT_tracking_editor_menus" :
648 "CLIP_MT_masking_editor_menus");
656 for (
int i = 0; i < idname_array_len; i++) {
666 #undef SPACE_MENU_MAP
667 #undef SPACE_MENU_NOP
669 bool has_keymap_menu_items =
false;
671 while (menu_stack !=
NULL) {
697 but_test = but_test->
prev;
700 if (but_test ==
NULL) {
702 menu_display_name_map, mt, (
void *)
strdup_memarena(memarena, but->drawstr));
706 data, memarena, mt,
NULL, but, wm_context)) {
717 sizeof(*menu_parent));
726 bool drawstr_is_empty =
false;
727 if (drawstr_sep !=
NULL) {
730 const char *
drawstr = but->drawstr;
731 int drawstr_len = drawstr_sep - but->drawstr;
736 drawstr_is_empty =
true;
745 const char *
drawstr = but->drawstr;
749 drawstr_is_empty =
true;
757 if (drawstr_is_empty) {
758 printf(
"Warning: '%s' menu has empty 'bl_label'.\n", mt_from_but->
idname);
762 else if (but->menu_create_func !=
NULL) {
766 const char *drawstr_submenu = but->drawstr;
777 but->menu_create_func(
C, sub_layout, but->poin);
783 data, memarena, mt, drawstr_submenu, sub_but, wm_context);
799 if ((menu_stack ==
NULL) && (has_keymap_menu_items ==
false)) {
800 has_keymap_menu_items =
true;
802 C, win,
area, region, &menu_stack, menu_to_kmi, menu_tagged);
823 if (include_all_areas) {
826 (item->wm_context !=
NULL) ?
827 space_type_ui_items[item->wm_context->space_type_ui_index].
name :
831 if (item->menu_parent !=
NULL) {
834 while (menu_parent && menu_parent->
parent) {
836 menu_parent = menu_parent->
parent;
838 while (menu_parent) {
862 if (item->drawstr_submenu !=
NULL) {
886 data->memarena = memarena;
888 if (include_all_areas) {
892 if (space_type_ui_items_free) {
919 switch (item->type) {
920 case MENU_SEARCH_TYPE_OP: {
921 if (item->op.opptr !=
NULL) {
926 case MENU_SEARCH_TYPE_RNA: {
955 switch (item->
type) {
967 bool changed =
false;
1003 const bool UNUSED(is_first))
1016 for (
int i = 0; i < filtered_amount; i++) {
1044 bool has_menu =
false;
1046 memset(&
data->context_menu_data, 0x0,
sizeof(
data->context_menu_data));
1047 uiBut *but = &
data->context_menu_data.but;
1089 memset(&
data->context_menu_data, 0x0,
sizeof(
data->context_menu_data));
1090 uiBut *but = &
data->context_menu_data.but;
1100 tip_init[0] =
event->
x;
1101 tip_init[1] =
event->y - (
UI_UNIT_Y / 2);
1145 C, win,
area, region, include_all_areas);
1165 static char search[256] =
"";
1171 block, search, 0, ICON_VIEWZOOM,
sizeof(search), 0, 0,
UI_UNIT_X * 6,
UI_UNIT_Y, 0, 0,
"");
struct ScrArea * CTX_wm_area(const bContext *C)
void CTX_store_set(bContext *C, bContextStore *store)
void CTX_wm_region_set(bContext *C, struct ARegion *region)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
struct wmWindow * CTX_wm_window(const bContext *C)
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
A dynamically sized string ADT.
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
int BLI_dynstr_get_len(DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_clear(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
DynStr * BLI_dynstr_new_memarena(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_get_cstring_ex(DynStr *__restrict ds, char *__restrict rets) ATTR_NONNULL()
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
void BLI_ghashIterator_step(GHashIterator *ghi)
BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
GSet * BLI_gset_ptr_new(const char *info)
bool BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool BLI_gset_add(GSet *gs, void *key)
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void void void * BLI_linklist_pop(LinkNode **listp) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_linklist_prepend(LinkNode **listp, void *ptr) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
void void BLI_listbase_sort(struct ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void unit_m4(float m[4][4])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
void * BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL()
void BLI_string_search_free(StringSearch *search)
void BLI_string_search_add(StringSearch *search, const char *str, void *user_data)
StringSearch * BLI_string_search_new(void)
int BLI_string_search_query(StringSearch *search, const char *query, void ***r_data)
#define BLI_string_joinN(...)
#define CTX_IFACE_(context, msgid)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
uiBlock * uiLayoutGetBlock(uiLayout *layout)
const struct uiStyle * UI_style_get_dpi(void)
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
struct ARegion * UI_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but, bool is_label)
void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout)
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid, int state, const uint8_t name_prefix_offset)
void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn)
void UI_but_func_search_set(uiBut *but, uiButSearchCreateFn search_create_fn, uiButSearchUpdateFn search_update_fn, void *arg, const bool free_arg, uiButSearchArgFreeFn search_arg_free_fn, uiButHandleFunc search_exec_fn, void *active)
void UI_block_end(const struct bContext *C, uiBlock *block)
void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn)
@ UI_BLOCK_SHOW_SHORTCUT_ALWAYS
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const struct uiStyle *style)
struct MenuType * UI_but_menutype_get(uiBut *but)
void UI_block_free(const struct bContext *C, uiBlock *block)
void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
uiBut * uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip)
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
void UI_block_flag_enable(uiBlock *block, int flag)
@ WM_OP_INVOKE_REGION_WIN
void ui_window_to_block_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
struct ARegion * ui_searchbox_create_menu(struct bContext *C, struct ARegion *butregion, uiButSearch *search_but)
int ui_but_icon(const uiBut *but)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool active
all scheduled work for the GPU.
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, bool value)
bool RNA_property_array_check(PropertyRNA *prop)
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_property_translation_context(const PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
bool RNA_property_enum_item_from_value_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, EnumPropertyItem *r_item)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
const char * RNA_property_ui_name(const PropertyRNA *prop)
struct bContextStore * context
struct PointerRNA * opptr
struct wmOperatorType * optype
char drawstr[UI_MAX_DRAW_STR]
char strdata[UI_MAX_NAME_STR]
struct PropertyRNA * rnaprop
struct PointerRNA rnapoin
const char * translation_context
struct wmEvent * eventstate
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
wmKeyMap * WM_event_get_keymap_from_handler(wmWindowManager *wm, wmEventHandler_Keymap *handler)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties)
int WM_keymap_item_to_string(const wmKeyMapItem *kmi, const bool compact, char *result, const int result_len)
bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
void WM_operatortype_iter(GHashIterator *ghi)
const char * WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties)
void WM_operator_py_idname(char *to, const char *from)
void WM_operator_properties_free(PointerRNA *ptr)
bScreen * WM_window_get_active_screen(const wmWindow *win)