|
Blender V4.3
|
#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_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 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 ARegion * | ui_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) |
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 ) |
Referenced by menu_items_from_ui_create().
| #define SPACE_MENU_NOP | ( | space_type | ) |
Referenced by menu_items_from_ui_create().
|
static |
Definition at line 133 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 379 of file interface_template_search_menu.cc.
References BLI_addtail(), BLI_listbase_sort(), BLI_memarena_calloc(), BLI_movelisttolist(), C, MenuSearch_Item::context, CTX_IFACE_, 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, MenuSearch_Item::opcontext, MenuSearch_Item::Operator, OPTYPE_INTERNAL, ot, SNPRINTF, strdup_memarena(), wmOperatorType::translation_context, MenuSearch_Item::type, UI_MENU_ARROW_SEP, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::values(), MenuSearch_Item::wm_context, WM_OP_INVOKE_DEFAULT, WM_operator_poll(), WM_operator_py_idname(), and WM_operatortype_map().
Referenced by menu_items_from_ui_create().
|
static |
Create MenuSearch_Data by inspecting the current context, this uses two methods:
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().
|
static |
Definition at line 156 of file interface_template_search_menu.cc.
References BLI_addtail(), BLI_memarena_calloc(), uiBut::block, MenuSearch_Item::context, uiBut::context, MenuSearch_Item::drawstr, uiBut::drawstr, blender::StringRef::drop_prefix(), ELEM, MenuSearch_Item::enum_value, uiBlock::evil_C, uiBut::flag, uiBut::hardmax, MenuSearch_Item::icon, MenuType::idname, MenuSearch_Item::index, int, MenuSearch_Item::menu_parent, MenuSearch_Item::mt, EnumPropertyItem::name, MenuSearch_Item::op, MenuSearch_Item::opcontext, uiBut::opcontext, MenuSearch_Item::Operator, MenuSearch_Item::opptr, uiBut::opptr, uiBut::optype, printf, MenuSearch_Item::prop, PROP_BOOLEAN, PROP_ENUM, MenuSearch_Item::ptr, MenuSearch_Item::RNA, MenuSearch_Item::rna, RNA_property_enum_item_from_value_gettexted(), RNA_property_type(), RNA_property_ui_name(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, uiBut::search_weight, 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::weight, 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 266 of file interface_template_search_menu.cc.
References MenuSearch_Item::context, uiBut::context, MenuSearch_Item::drawstr, uiBut::drawstr, MenuSearch_Item::enum_value, uiBut::hardmax, MenuSearch_Item::icon, uiBut::icon, MenuSearch_Item::index, MenuSearch_Item::op, MenuSearch_Item::opcontext, uiBut::opcontext, MenuSearch_Item::Operator, MenuSearch_Item::opptr, uiBut::opptr, uiBut::optype, MenuSearch_Item::prop, PROP_ENUM, MenuSearch_Item::ptr, MenuSearch_Item::RNA, MenuSearch_Item::rna, RNA_property_type(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, MenuSearch_Item::type, and UI_SEP_CHAR.
Referenced by ui_search_menu_create_context_menu(), and ui_search_menu_create_tooltip().
|
static |
Definition at line 911 of file interface_template_search_menu.cc.
References BLI_memarena_free(), LISTBASE_FOREACH, MenuSearch_Item::Operator, MenuSearch_Item::RNA, and WM_operator_properties_free().
Referenced by UI_but_func_menu_search().
|
static |
Definition at line 935 of file interface_template_search_menu.cc.
References MenuSearch_Context::area, MenuSearch_Item::context, CTX_store_set(), CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), MenuSearch_Item::drawstr, MenuSearch_Item::enum_value, MenuSearch_Item::index, MenuSearch_Item::op, MenuSearch_Item::opcontext, MenuSearch_Item::Operator, MenuSearch_Item::opptr, MenuSearch_Item::prop, PROP_BOOLEAN, PROP_ENUM, MenuSearch_Item::ptr, ptr, MenuSearch_Context::region, MenuSearch_Item::RNA, 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 998 of file interface_template_search_menu.cc.
References blender::string_search::StringSearch< T >::add(), LISTBASE_FOREACH, blender::string_search::StringSearch< T >::query(), 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 318 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(), ARRAY_SIZE, CTX_wm_manager(), wmWindow::eventstate, wmWindow::handlers, wmKeyMap::items, wmEventHandler_KeymapResult::keymaps, wmEventHandler_KeymapResult::keymaps_len, KMI_INACTIVE, LISTBASE_FOREACH, MAX_NAME, blender::Stack< T, InlineBufferCapacity, Allocator >::push(), 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 140 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().
|
static |
Definition at line 148 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().
| void UI_but_func_menu_search | ( | uiBut * | but, |
| const char * | single_menu_idname ) |
Definition at line 1129 of file interface_template_search_menu.cc.
References uiBut::block, CTX_wm_area(), CTX_wm_region(), CTX_wm_window(), 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 1031 of file interface_template_search_menu.cc.
References MenuSearch_Context::area, uiBut::block, CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), 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 1075 of file interface_template_search_menu.cc.
References MenuSearch_Context::area, uiBlock::aspect, uiBut::block, CTX_wm_area(), CTX_wm_area_set(), CTX_wm_region(), CTX_wm_region_set(), CTX_wm_window(), 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().
| void uiTemplateMenuSearch | ( | uiLayout * | layout | ) |
Definition at line 1155 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().