Blender  V3.3
Classes | Macros
interface_template_search_menu.cc File Reference
#include <cstdio>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_texture_types.h"
#include "BLI_alloca.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math_matrix.h"
#include "BLI_memarena.h"
#include "BLI_string.h"
#include "BLI_string_search.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
#include "ED_screen.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "interface_intern.h"
#include "wm_event_system.h"

Go to the source code of this file.

Classes

struct  MenuSearch_Context
 
struct  MenuSearch_Parent
 
struct  MenuSearch_Item
 
struct  MenuSearch_Data
 

Macros

#define SPACE_MENU_MAP(space_type, menu_id)
 
#define SPACE_MENU_NOP(space_type)
 

Functions

Menu Search Template Implementation
static int menu_item_sort_by_drawstr_full (const void *menu_item_a_v, const void *menu_item_b_v)
 
static const char * strdup_memarena (MemArena *memarena, const char *str)
 
static const char * strdup_memarena_from_dynstr (MemArena *memarena, DynStr *dyn_str)
 
static bool menu_items_from_ui_create_item_from_button (MenuSearch_Data *data, MemArena *memarena, struct MenuType *mt, const char *drawstr_submenu, uiBut *but, MenuSearch_Context *wm_context)
 
static bool menu_items_to_ui_button (MenuSearch_Item *item, uiBut *but)
 
static void menu_types_add_from_keymap_items (bContext *C, wmWindow *win, ScrArea *area, ARegion *region, LinkNode **menuid_stack_p, GHash *menu_to_kmi, GSet *menu_tagged)
 
static void menu_items_from_all_operators (bContext *C, MenuSearch_Data *data)
 
static MenuSearch_Datamenu_items_from_ui_create (bContext *C, wmWindow *win, ScrArea *area_init, ARegion *region_init, bool include_all_areas)
 
static void menu_search_arg_free_fn (void *data_v)
 
static void menu_search_exec_fn (bContext *C, void *UNUSED(arg1), void *arg2)
 
static void menu_search_update_fn (const bContext *UNUSED(C), void *arg, const char *str, uiSearchItems *items, const bool UNUSED(is_first))
 
Context Menu

This uses a fake button to create a context menu, if this ever causes hard to solve bugs we may need to create a separate context menu just for the search, however this is fairly involved.

static bool ui_search_menu_create_context_menu (struct bContext *C, void *arg, void *active, const struct wmEvent *event)
 
Tooltip
static struct ARegionui_search_menu_create_tooltip (struct bContext *C, struct ARegion *region, const rcti *UNUSED(item_rect), void *arg, void *active)
 
Menu Search Template Public API
void UI_but_func_menu_search (uiBut *but)
 
void uiTemplateMenuSearch (uiLayout *layout)
 

Detailed Description

Search available menu items via the user interface & key-maps. Accessed via the WM_OT_search_menu operator.

Definition in file interface_template_search_menu.cc.

Macro Definition Documentation

◆ SPACE_MENU_MAP

#define SPACE_MENU_MAP (   space_type,
  menu_id 
)
Value:
case space_type: \
idname_array[idname_array_len++] = menu_id; \
break

◆ SPACE_MENU_NOP

#define SPACE_MENU_NOP (   space_type)
Value:
case space_type: \
break

Function Documentation

◆ menu_item_sort_by_drawstr_full()

static int menu_item_sort_by_drawstr_full ( const void menu_item_a_v,
const void menu_item_b_v 
)
static

◆ menu_items_from_all_operators()

static void menu_items_from_all_operators ( bContext C,
MenuSearch_Data data 
)
static

◆ menu_items_from_ui_create()

static MenuSearch_Data* menu_items_from_ui_create ( bContext C,
wmWindow win,
ScrArea area_init,
ARegion region_init,
bool  include_all_areas 
)
static

Create MenuSearch_Data by inspecting the current context, this uses two methods:

  • Look up predefined editor-menus.
  • Look up key-map items which call menus.

Map (MenuType to MenuSearch_Parent)

Map (MenuType -> wmKeyMapItem).

Definition at line 426 of file interface_template_search_menu.cc.

References blender::compositor::area(), MenuSearch_Context::area, bScreen::areabase, ARRAY_SIZE, BKE_area_find_region_type(), BLI_assert, BLI_dynstr_append(), BLI_dynstr_appendf(), BLI_dynstr_clear(), BLI_dynstr_free(), BLI_dynstr_get_len(), BLI_dynstr_nappend(), BLI_dynstr_new_memarena(), BLI_ghash_free(), BLI_ghash_haskey(), BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_ptr_new(), BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getValue(), BLI_ghashIterator_step(), BLI_gset_add(), BLI_gset_free(), BLI_gset_ptr_new(), BLI_gset_remove(), BLI_linklist_pop(), BLI_linklist_prepend(), BLI_listbase_sort(), BLI_memarena_calloc(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_remlink(), BLI_str_endswith(), ARegion_Runtime::block_name_map, uiBlock::buttons, C, CTX_IFACE_, CTX_wm_area_set(), CTX_wm_region_set(), data, MenuSearch_Parent::drawstr, GHASH_ITER, bScreen::id, MenuType::idname, MenuType::label, LISTBASE_FOREACH, MEM_callocN, MEM_freeN, menu_item_sort_by_drawstr_full(), menu_items_from_all_operators(), menu_items_from_ui_create_item_from_button(), menu_types_add_from_keymap_items(), uiBlock::name, EnumPropertyItem::name, MenuSearch_Parent::parent, MenuSearch_Parent::parent_mt, uiBut::prev, ptr, MenuSearch_Context::region, RGN_TYPE_WINDOW, RNA_enum_from_value(), RNA_pointer_create(), RNA_property_enum_get(), RNA_property_enum_items(), RNA_property_translation_context(), RNA_struct_find_property(), ARegion::runtime, SACTCONT_TIMELINE, SC_MODE_TRACKING, SPACE_ACTION, SPACE_CLIP, SPACE_CONSOLE, SPACE_EMPTY, SPACE_FILE, SPACE_GRAPH, SPACE_IMAGE, SPACE_INFO, SPACE_MENU_MAP, SPACE_MENU_NOP, SPACE_NLA, SPACE_NODE, SPACE_OUTLINER, SPACE_PROPERTIES, SPACE_SCRIPT, SPACE_SEQ, SPACE_SPREADSHEET, SPACE_STATUSBAR, SPACE_TEXT, SPACE_TOPBAR, MenuSearch_Context::space_type_ui_index, SPACE_USERPREF, SPACE_VIEW3D, ScrArea::spacetype, strdup_memarena(), strdup_memarena_from_dynstr(), MenuSearch_Parent::temp_child, MenuType::translation_context, uiBut::type, UI_block_begin(), UI_block_end(), UI_block_flag_enable(), UI_block_free(), UI_block_layout(), UI_BLOCK_SHOW_SHORTCUT_ALWAYS, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BUT_HAS_SEP_CHAR, UI_but_menutype_get(), UI_EMBOSS, UI_LAYOUT_MENU, UI_LAYOUT_VERTICAL, UI_MENU_ARROW_SEP, UI_MENU_PADDING, UI_menutype_draw(), UI_SEP_CHAR, UI_style_get_dpi(), ARegion::uiblocks, uiLayoutSetOperatorContext(), UNLIKELY, USER_DEVELOPER_UI, ScrArea::winx, ScrArea::winy, WM_keymap_item_to_string(), WM_menutype_find(), WM_menutype_iter(), WM_menutype_poll(), WM_OP_INVOKE_REGION_WIN, and WM_window_get_active_screen().

Referenced by UI_but_func_menu_search().

◆ menu_items_from_ui_create_item_from_button()

static bool menu_items_from_ui_create_item_from_button ( MenuSearch_Data data,
MemArena memarena,
struct MenuType mt,
const char *  drawstr_submenu,
uiBut but,
MenuSearch_Context wm_context 
)
static

◆ menu_items_to_ui_button()

static bool menu_items_to_ui_button ( MenuSearch_Item item,
uiBut but 
)
static

◆ menu_search_arg_free_fn()

static void menu_search_arg_free_fn ( void data_v)
static

◆ menu_search_exec_fn()

static void menu_search_exec_fn ( bContext C,
void UNUSEDarg1,
void arg2 
)
static

◆ menu_search_update_fn()

static void menu_search_update_fn ( const bContext UNUSEDC,
void arg,
const char *  str,
uiSearchItems items,
const bool   UNUSEDis_first 
)
static

◆ menu_types_add_from_keymap_items()

static void menu_types_add_from_keymap_items ( bContext C,
wmWindow win,
ScrArea area,
ARegion region,
LinkNode **  menuid_stack_p,
GHash menu_to_kmi,
GSet menu_tagged 
)
static

◆ strdup_memarena()

static const char* strdup_memarena ( MemArena memarena,
const char *  str 
)
static

◆ strdup_memarena_from_dynstr()

static const char* strdup_memarena_from_dynstr ( MemArena memarena,
DynStr dyn_str 
)
static

◆ UI_but_func_menu_search()

void UI_but_func_menu_search ( uiBut but)

◆ ui_search_menu_create_context_menu()

static bool ui_search_menu_create_context_menu ( struct bContext C,
void arg,
void active,
const struct wmEvent event 
)
static

◆ ui_search_menu_create_tooltip()

static struct ARegion* ui_search_menu_create_tooltip ( struct bContext C,
struct ARegion region,
const rcti UNUSEDitem_rect,
void arg,
void active 
)
static

◆ uiTemplateMenuSearch()

void uiTemplateMenuSearch ( uiLayout layout)