Blender
V3.3
|
#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_Data * | menu_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 ARegion * | ui_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) |
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.
#define SPACE_MENU_MAP | ( | space_type, | |
menu_id | |||
) |
#define SPACE_MENU_NOP | ( | space_type | ) |
|
static |
Definition at line 136 of file interface_template_search_menu.cc.
References MenuSearch_Item::drawwstr_full.
Referenced by menu_items_from_all_operators(), and menu_items_from_ui_create().
|
static |
Display all operators (last). Developer-only convenience feature.
Definition at line 374 of file interface_template_search_menu.cc.
References BLI_addtail(), BLI_ghashIterator_done(), BLI_ghashIterator_getValue(), BLI_ghashIterator_step(), BLI_listbase_sort(), BLI_memarena_calloc(), BLI_movelisttolist(), C, CTX_IFACE_, data, MenuSearch_Item::drawstr, MenuSearch_Item::drawwstr_full, wmOperatorType::flag, G, G_DEBUG_WM, wmOperatorType::idname, menu_item_sort_by_drawstr_full(), wmOperatorType::name, MenuSearch_Item::op, OP_MAX_TYPENAME, OPTYPE_INTERNAL, ot, SNPRINTF, strdup_memarena(), wmOperatorType::translation_context, MenuSearch_Item::type, UI_MENU_ARROW_SEP, MenuSearch_Item::wm_context, WM_OP_INVOKE_DEFAULT, WM_operator_poll(), WM_operator_py_idname(), and WM_operatortype_iter().
Referenced by menu_items_from_ui_create().
|
static |
Create MenuSearch_Data by inspecting the current context, this uses two methods:
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().
|
static |
Definition at line 159 of file interface_template_search_menu.cc.
References BLI_addtail(), BLI_memarena_calloc(), uiBut::block, uiBut::context, data, uiBut::drawstr, MenuSearch_Item::drawstr, MenuSearch_Item::drawstr_submenu, ELEM, uiBlock::evil_C, uiBut::flag, uiBut::hardmax, MenuSearch_Item::icon, MenuType::idname, if(), MenuSearch_Item::mt, MenuSearch_Item::op, uiBut::opcontext, uiBut::opptr, uiBut::optype, PROP_BOOLEAN, PROP_ENUM, MenuSearch_Item::rna, RNA_property_enum_item_from_value_gettexted(), RNA_property_type(), RNA_property_ui_name(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, MenuSearch_Item::state, strdup_memarena(), MenuSearch_Item::type, UI_BUT_DISABLED, UI_BUT_HAS_SEP_CHAR, ui_but_icon(), UI_BUT_INACTIVE, UI_BUT_REDALERT, UI_SEP_CHAR, MenuSearch_Item::wm_context, and WM_operatortype_name().
Referenced by menu_items_from_ui_create().
|
static |
Populate a fake button from a menu item (use for context menu).
Definition at line 264 of file interface_template_search_menu.cc.
References uiBut::context, uiBut::drawstr, MenuSearch_Item::drawstr, uiBut::hardmax, uiBut::icon, MenuSearch_Item::icon, MenuSearch_Item::op, uiBut::opcontext, uiBut::opptr, uiBut::optype, PROP_ENUM, MenuSearch_Item::rna, RNA_property_type(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, MenuSearch_Item::state, uiBut::str, uiBut::strdata, STRNCPY, MenuSearch_Item::type, UI_BUT_HAS_SEP_CHAR, and UI_SEP_CHAR.
Referenced by ui_search_menu_create_context_menu(), and ui_search_menu_create_tooltip().
Definition at line 911 of file interface_template_search_menu.cc.
References BLI_memarena_free(), data, LISTBASE_FOREACH, MEM_freeN, and WM_operator_properties_free().
Referenced by UI_but_func_menu_search().
Definition at line 933 of file interface_template_search_menu.cc.
References MenuSearch_Context::area, C, CTX_store_set(), CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), MenuSearch_Item::drawstr, MenuSearch_Item::op, PROP_BOOLEAN, PROP_ENUM, ptr, MenuSearch_Context::region, MenuSearch_Item::rna, RNA_property_array_check(), RNA_property_boolean_get(), RNA_property_boolean_get_index(), RNA_property_boolean_set(), RNA_property_boolean_set_index(), RNA_property_enum_set(), RNA_property_type(), RNA_property_update(), MenuSearch_Item::state, MenuSearch_Item::type, UI_BUT_DISABLED, MenuSearch_Item::wm_context, and WM_operator_name_call_ptr_with_depends_on_cursor().
Referenced by UI_but_func_menu_search().
|
static |
Definition at line 996 of file interface_template_search_menu.cc.
References BLI_string_search_add(), BLI_string_search_free(), BLI_string_search_new(), BLI_string_search_query(), data, MenuSearch_Item::drawwstr_full, MenuSearch_Item::icon, LISTBASE_FOREACH, MEM_freeN, MenuSearch_Item::state, str, and UI_search_item_add().
Referenced by UI_but_func_menu_search().
|
static |
Populate menu_stack with menus from inspecting active key-maps for this context.
Definition at line 309 of file interface_template_search_menu.cc.
References blender::compositor::area(), ARRAY_SIZE, BLI_ghash_ensure_p(), BLI_gset_add(), BLI_linklist_prepend(), C, CTX_wm_manager(), wmWindow::eventstate, ARegion::handlers, wmWindow::handlers, wmKeyMap::items, wmEventHandler_KeymapResult::keymaps, wmEventHandler_KeymapResult::keymaps_len, KMI_INACTIVE, LISTBASE_FOREACH, MAX_NAME, RNA_string_get(), STR_ELEM, WM_event_get_keymaps_from_handler(), WM_HANDLER_DO_FREE, WM_HANDLER_TYPE_KEYMAP, WM_keymap_poll(), and WM_menutype_find().
Referenced by menu_items_from_ui_create().
|
static |
Definition at line 143 of file interface_template_search_menu.cc.
References BLI_memarena_alloc(), and str.
Referenced by menu_items_from_all_operators(), menu_items_from_ui_create(), and menu_items_from_ui_create_item_from_button().
Definition at line 151 of file interface_template_search_menu.cc.
References BLI_dynstr_get_cstring_ex(), BLI_dynstr_get_len(), and BLI_memarena_alloc().
Referenced by menu_items_from_ui_create().
Definition at line 1133 of file interface_template_search_menu.cc.
References blender::compositor::area(), uiBut::block, C, CTX_wm_area(), CTX_wm_region(), CTX_wm_window(), data, uiBlock::evil_C, menu_items_from_ui_create(), menu_search_arg_free_fn(), menu_search_exec_fn(), menu_search_update_fn(), SPACE_TOPBAR, UI_but_func_search_set(), UI_but_func_search_set_context_menu(), UI_but_func_search_set_sep_string(), UI_but_func_search_set_tooltip(), UI_MENU_ARROW_SEP, ui_search_menu_create_context_menu(), ui_search_menu_create_tooltip(), and ui_searchbox_create_menu().
Referenced by uiTemplateMenuSearch(), and wm_block_search_menu().
|
static |
Definition at line 1034 of file interface_template_search_menu.cc.
References blender::compositor::active, MenuSearch_Context::area, uiBut::block, C, CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), data, menu_items_to_ui_button(), MenuSearch_Context::region, ui_popup_context_menu_for_button(), and MenuSearch_Item::wm_context.
Referenced by UI_but_func_menu_search().
|
static |
Definition at line 1077 of file interface_template_search_menu.cc.
References blender::compositor::active, MenuSearch_Context::area, uiBlock::aspect, uiBut::block, C, CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), CTX_wm_window(), data, wmWindow::eventstate, menu_items_to_ui_button(), uiBut::rect, MenuSearch_Context::region, UI_tooltip_create_from_button(), UI_UNIT_Y, ui_window_to_block_fl(), unit_m4(), uiBlock::winmat, MenuSearch_Item::wm_context, rctf::xmax, rctf::xmin, wmEvent::xy, rctf::ymax, and rctf::ymin.
Referenced by UI_but_func_menu_search().
Definition at line 1157 of file interface_template_search_menu.cc.
References UI_block_layout_set_current(), UI_but_func_menu_search(), UI_UNIT_X, UI_UNIT_Y, uiDefSearchBut(), and uiLayoutGetBlock().