|
Blender V5.0
|
#include <cstdio>#include <cstring>#include <variant>#include "MEM_guardedalloc.h"#include "DNA_action_types.h"#include "DNA_node_types.h"#include "BLI_listbase.h"#include "BLI_map.hh"#include "BLI_math_matrix.h"#include "BLI_resource_scope.hh"#include "BLI_set.hh"#include "BLI_stack.hh"#include "BLI_string.h"#include "BLI_string_utf8.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_layout.hh"#include "UI_string_search.hh"#include "interface_intern.hh"#include "wm_event_system.hh"#include <fmt/format.h>Go to the source code of this file.
Classes | |
| struct | MenuSearch_Context |
| struct | MenuSearch_Parent |
| struct | MenuSearch_Item |
| struct | MenuSearch_Item::OperatorData |
| struct | MenuSearch_Item::PropertyData |
| struct | MenuSearch_Data |
| struct | MenuStackEntry |
| class | ResourceScope |
Macros | |
| #define | SPACE_MENU_MAP(space_type, menu_id) |
| #define | SPACE_MENU_NOP(space_type) |
Functions | |
Menu Search Template Implementation | |
| static bool | menu_item_sort_by_drawstr_full (const MenuSearch_Item &menu_item_a, const MenuSearch_Item &menu_item_b) |
| static bool | menu_items_from_ui_create_item_from_button (MenuSearch_Data *data, blender::ResourceScope &scope, 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 134 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 362 of file interface_template_search_menu.cc.
References blender::ResourceScope::allocator(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::begin(), C, blender::ResourceScope::construct(), blender::LinearAllocator< Allocator >::copy_string(), CTX_IFACE_, data, MenuSearch_Item::data, MenuSearch_Item::drawstr, MenuSearch_Item::drawwstr_full, blender::Vector< T, InlineBufferCapacity, Allocator >::end(), G, G_DEBUG_WM, blender::wm::InvokeDefault, menu_item_sort_by_drawstr_full(), OP_MAX_TYPENAME, OPTYPE_INTERNAL, ot, SNPRINTF_UTF8, UI_MENU_ARROW_SEP, MenuSearch_Item::wm_context, WM_operator_poll(), WM_operator_py_idname(), and WM_operatortypes_registered_get().
Referenced by menu_items_from_ui_create().
|
static |
Create MenuSearch_Data by inspecting the current context, this uses two methods:
Definition at line 409 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(), blender::ResourceScope::allocator(), Vector< T, InlineBufferCapacity, Allocator >::append(), MenuSearch_Context::area, bScreen::areabase, ARRAY_SIZE, Vector< T, InlineBufferCapacity, Allocator >::begin(), BKE_area_find_region_type(), BLI_assert, BLI_remlink(), BLI_SCOPED_DEFER, BLI_str_endswith(), blender::ui::block_layout(), uiBlock::buttons, C, blender::StringRefNull::c_str(), blender::ResourceScope::construct(), MenuStackEntry::context, uiLayout::context_copy(), ContextDependent, blender::LinearAllocator< Allocator >::copy_string(), CTX_IFACE_, CTX_store_get(), CTX_store_set(), CTX_wm_area_set(), CTX_wm_region_set(), data, MenuSearch_Item::drawstr, MenuSearch_Parent::drawstr, MenuSearch_Item::drawwstr_full, blender::ui::Emboss, bContextStore::entries, ListBase::first, MenuType::flag, i, bScreen::id, MenuType::idname, Vector< T, InlineBufferCapacity, Allocator >::index_range(), blender::wm::InvokeRegionWin, blender::Stack< T, InlineBufferCapacity, Allocator >::is_empty(), Label, MenuType::label, LISTBASE_FOREACH, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_default(), MEM_freeN(), blender::ui::Menu, menu_item_sort_by_drawstr_full(), menu_items_from_all_operators(), menu_items_from_ui_create_item_from_button(), MenuSearch_Item::menu_parent, menu_types_add_from_keymap_items(), MenuSearch_Item::mt, MenuStackEntry::mt, EnumPropertyItem::name, uiBlock::name, uiLayout::operator_context_set(), MenuSearch_Parent::parent, blender::Stack< T, InlineBufferCapacity, Allocator >::pop(), 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_discrete(), RNA_property_enum_get(), RNA_property_enum_items(), RNA_property_translation_context(), RNA_struct_find_property(), ARegion::runtime, SC_MODE_TRACKING, MenuStackEntry::self_as_parent, Sepr, 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::spacedata, ScrArea::spacetype, STREQ, MenuSearch_Parent::temp_child, MenuType::translation_context, U, UI_block_begin(), UI_block_end(), UI_block_flag_enable(), UI_block_free(), UI_BLOCK_SHOW_SHORTCUT_ALWAYS, UI_BUT_HAS_SEP_CHAR, UI_but_menutype_get(), UI_but_paneltype_get(), UI_MENU_ARROW_SEP, UI_MENU_PADDING, UI_menutype_draw(), UI_SEP_CHAR, UI_style_get_dpi(), UNLIKELY, USER_DEVELOPER_UI, blender::ui::Vertical, ScrArea::winx, ScrArea::winy, MenuSearch_Item::wm_context, WM_keymap_item_to_string(), WM_menutype_find(), WM_menutype_poll(), WM_menutypes_registered_get(), and WM_window_get_active_screen().
Referenced by UI_but_func_menu_search().
|
static |
Definition at line 140 of file interface_template_search_menu.cc.
References blender::ResourceScope::allocator(), uiBut::block, blender::ResourceScope::construct(), uiBut::context, blender::LinearAllocator< Allocator >::copy_string(), data, MenuSearch_Item::data, MenuSearch_Item::drawstr, uiBut::drawstr, blender::StringRef::drop_prefix(), ELEM, uiBlock::evil_C, uiBut::flag, uiBut::hardmax, MenuSearch_Item::icon, MenuType::idname, MenuSearch_Item::menu_parent, MenuSearch_Item::mt, EnumPropertyItem::name, uiBut::opcontext, uiBut::opptr, uiBut::optype, printf, PROP_BOOLEAN, PROP_ENUM, 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, 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 252 of file interface_template_search_menu.cc.
References uiBut::context, MenuSearch_Item::data, MenuSearch_Item::drawstr, uiBut::drawstr, uiBut::hardmax, MenuSearch_Item::icon, uiBut::icon, uiBut::opcontext, uiBut::opptr, uiBut::optype, PROP_ENUM, RNA_property_type(), uiBut::rnaindex, uiBut::rnapoin, uiBut::rnaprop, and UI_SEP_CHAR.
Referenced by ui_search_menu_create_context_menu(), and ui_search_menu_create_tooltip().
|
static |
Definition at line 924 of file interface_template_search_menu.cc.
Referenced by UI_but_func_menu_search().
|
static |
Definition at line 929 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::data, MenuSearch_Item::drawstr, PROP_BOOLEAN, PROP_ENUM, ptr, MenuSearch_Context::region, 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, 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 988 of file interface_template_search_menu.cc.
References blender::string_search::StringSearch< T >::add(), data, MenuSearch_Item::drawwstr_full, MenuSearch_Item::icon, blender::string_search::StringSearch< T >::query(), MenuSearch_Item::state, str, UI_search_item_add(), and MenuSearch_Item::weight.
Referenced by UI_but_func_menu_search().
|
static |
Populate menu_stack with menus from inspecting active key-maps for this context.
Definition at line 300 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, C, CTX_wm_manager(), wmWindow::eventstate, ScrArea::handlers, 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(), ARegion::runtime, 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().
| void UI_but_func_menu_search | ( | uiBut * | but, |
| const char * | single_menu_idname ) |
Definition at line 1119 of file interface_template_search_menu.cc.
References 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, ScrArea::spacetype, 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 1021 of file interface_template_search_menu.cc.
References 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 1065 of file interface_template_search_menu.cc.
References 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().
| void uiTemplateMenuSearch | ( | uiLayout * | layout | ) |
Definition at line 1145 of file interface_template_search_menu.cc.
References uiLayout::block(), blender::ui::block_layout_set_current(), UI_but_func_menu_search(), UI_UNIT_X, UI_UNIT_Y, and uiDefSearchBut().