Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_template_search_menu.c
| Show All 15 Lines | |||||
| /** \file | /** \file | ||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| * | * | ||||
| * Search available menu items via the user interface & key-maps. | * Search available menu items via the user interface & key-maps. | ||||
| * Accessed via the #WM_OT_search_menu operator. | * Accessed via the #WM_OT_search_menu operator. | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_action_types.h" | #include "DNA_action_types.h" | ||||
| #include "DNA_gpencil_modifier_types.h" | #include "DNA_gpencil_modifier_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| Show All 33 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Menu Search Template Implementation | /** \name Menu Search Template Implementation | ||||
| * \{ */ | * \{ */ | ||||
| /* Unicode arrow. */ | /* Unicode arrow. */ | ||||
| #define MENU_SEP "\xe2\x96\xb6" | #define MENU_SEP "\xe2\x96\xb6" | ||||
| static CLG_LogRef LOG = {"interface.menu_search"}; | |||||
| /** | /** | ||||
| * Use when #menu_items_from_ui_create is called with `include_all_areas`. | * Use when #menu_items_from_ui_create is called with `include_all_areas`. | ||||
| * so we can run the menu item in the area it was extracted from. | * so we can run the menu item in the area it was extracted from. | ||||
| */ | */ | ||||
| struct MenuSearch_Context { | struct MenuSearch_Context { | ||||
| /** | /** | ||||
| * Index into `Area.ui_type` #EnumPropertyItem or the top-bar when -1. | * Index into `Area.ui_type` #EnumPropertyItem or the top-bar when -1. | ||||
| * Needed to get the display-name to use as a prefix for each menu item. | * Needed to get the display-name to use as a prefix for each menu item. | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | if (drawstr_is_empty) { | ||||
| else { | else { | ||||
| drawstr_override = RNA_property_ui_name(but->rnaprop); | drawstr_override = RNA_property_ui_name(but->rnaprop); | ||||
| } | } | ||||
| } | } | ||||
| if (!ELEM(prop_type, PROP_BOOLEAN, PROP_ENUM)) { | if (!ELEM(prop_type, PROP_BOOLEAN, PROP_ENUM)) { | ||||
| /* Note that these buttons are not prevented, | /* Note that these buttons are not prevented, | ||||
| * but aren't typically used in menus. */ | * but aren't typically used in menus. */ | ||||
| printf("Button '%s' in menu '%s' is a menu item with unsupported RNA type %d\n", | CLOG_WARN(&LOG, "Button '%s' in menu '%s' is a menu item with unsupported RNA type %d", | ||||
| but->drawstr, | but->drawstr, | ||||
| mt->idname, | mt->idname, | ||||
| prop_type); | prop_type); | ||||
| } | } | ||||
| else { | else { | ||||
| item = BLI_memarena_calloc(memarena, sizeof(*item)); | item = BLI_memarena_calloc(memarena, sizeof(*item)); | ||||
| item->type = MENU_SEARCH_TYPE_RNA; | item->type = MENU_SEARCH_TYPE_RNA; | ||||
| ▲ Show 20 Lines • Show All 504 Lines • ▼ Show 20 Lines | while (menu_stack != NULL) { | ||||
| } | } | ||||
| } | } | ||||
| menu_parent->drawstr = strdup_memarena(memarena, drawstr); | menu_parent->drawstr = strdup_memarena(memarena, drawstr); | ||||
| } | } | ||||
| menu_parent->parent_mt = mt; | menu_parent->parent_mt = mt; | ||||
| BLI_ghash_insert(menu_parent_map, mt_from_but, menu_parent); | BLI_ghash_insert(menu_parent_map, mt_from_but, menu_parent); | ||||
| if (drawstr_is_empty) { | if (drawstr_is_empty) { | ||||
| printf("Warning: '%s' menu has empty 'bl_label'.\n", mt_from_but->idname); | CLOG_WARN(&LOG, "'%s' menu has empty 'bl_label'", mt_from_but->idname); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (but->menu_create_func != NULL) { | else if (but->menu_create_func != NULL) { | ||||
| /* A non 'MenuType' menu button. */ | /* A non 'MenuType' menu button. */ | ||||
| /* Only expand one level deep, this is mainly for expanding operator menus. */ | /* Only expand one level deep, this is mainly for expanding operator menus. */ | ||||
| const char *drawstr_submenu = but->drawstr; | const char *drawstr_submenu = but->drawstr; | ||||
| ▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines | |||||