Blender V4.3
interface_template_search_menu.cc File Reference
#include <cstdio>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_map.hh"
#include "BLI_math_matrix.h"
#include "BLI_memarena.h"
#include "BLI_set.hh"
#include "BLI_stack.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_screen.hh"
#include "ED_screen.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "UI_interface.hh"
#include "UI_string_search.hh"
#include "interface_intern.hh"
#include "wm_event_system.hh"

Go to the source code of this file.

Classes

struct  MenuSearch_Context
 
struct  MenuSearch_Parent
 
struct  MenuSearch_Item
 
struct  MenuSearch_Data
 
struct  MenuStackEntry
 

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, const DynStr *dyn_str)
 
static bool menu_items_from_ui_create_item_from_button (MenuSearch_Data *data, MemArena *memarena, MenuType *mt, uiBut *but, MenuSearch_Context *wm_context, MenuSearch_Parent *menu_parent)
 
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, blender::Stack< MenuStackEntry > &menu_stack, blender::Map< MenuType *, wmKeyMapItem * > &menu_to_kmi, blender::Set< MenuType * > &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, const char *single_menu_idname)
 
static void menu_search_arg_free_fn (void *data_v)
 
static void menu_search_exec_fn (bContext *C, void *, void *arg2)
 
static void menu_search_update_fn (const bContext *, void *arg, const char *str, uiSearchItems *items, const bool)
 
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 (bContext *C, void *arg, void *active, const wmEvent *event)
 
Tooltip
static ARegionui_search_menu_create_tooltip (bContext *C, ARegion *region, const rcti *, void *arg, void *active)
 
Menu Search Template Public API
void UI_but_func_menu_search (uiBut *but, const char *single_menu_idname)
 
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

Referenced by menu_items_from_ui_create().

◆ SPACE_MENU_NOP

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

Referenced by menu_items_from_ui_create().

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()

◆ 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,
const char * single_menu_idname )
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.

Definition at line 427 of file interface_template_search_menu.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), MenuSearch_Context::area, 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_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getValue(), BLI_ghashIterator_step(), BLI_listbase_sort(), BLI_memarena_calloc(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_remlink(), BLI_str_endswith(), uiBlock::buttons, MenuStackEntry::context, ContextDependent, CTX_IFACE_, CTX_wm_area_set(), CTX_wm_region_set(), data, MenuSearch_Parent::drawstr, MenuType::flag, MenuType::idname, blender::Stack< T, InlineBufferCapacity, Allocator >::is_empty(), MenuType::label, LISTBASE_FOREACH, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_default(), 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(), MenuStackEntry::mt, EnumPropertyItem::name, uiBlock::name, MenuSearch_Parent::parent, blender::Stack< T, InlineBufferCapacity, Allocator >::pop(), uiBut::prev, printf, ptr, blender::Stack< T, InlineBufferCapacity, Allocator >::push(), MenuSearch_Context::region, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::remove(), 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(), SACTCONT_TIMELINE, SC_MODE_TRACKING, MenuStackEntry::self_as_parent, 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(), STREQ, 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(), uiLayoutContextCopy(), 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()

◆ menu_items_to_ui_button()

◆ menu_search_arg_free_fn()

static void menu_search_arg_free_fn ( void * data_v)
static

◆ menu_search_exec_fn()

◆ menu_search_update_fn()

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

◆ menu_types_add_from_keymap_items()

◆ 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,
const DynStr * dyn_str )
static

◆ UI_but_func_menu_search()

◆ ui_search_menu_create_context_menu()

◆ ui_search_menu_create_tooltip()

◆ uiTemplateMenuSearch()