diff options
Diffstat (limited to 'source/blender/editors/interface/interface_region_search.cc')
-rw-r--r-- | source/blender/editors/interface/interface_region_search.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 81c0c29d09a..fb7810792e9 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -10,6 +10,7 @@ #include <cstdarg> #include <cstdlib> #include <cstring> +#include <iostream> #include "DNA_ID.h" #include "MEM_guardedalloc.h" @@ -41,7 +42,7 @@ #include "GPU_state.h" #include "interface_intern.h" -#include "interface_regions_intern.h" +#include "interface_regions_intern.hh" #define MENU_BORDER (int)(0.3f * U.widget_unit) @@ -86,6 +87,10 @@ struct uiSearchboxData { * Used so we can show leading text to menu items less prominently (not related to 'use_sep'). */ const char *sep_string; + + /* Owned by uiButSearch */ + void *search_arg; + uiButSearchListenFn search_listener; }; #define SEARCH_ITEMS 10 @@ -689,6 +694,14 @@ static void ui_searchbox_region_free_fn(ARegion *region) region->regiondata = nullptr; } +static void ui_searchbox_region_listen_fn(const wmRegionListenerParams *params) +{ + uiSearchboxData *data = static_cast<uiSearchboxData *>(params->region->regiondata); + if (data->search_listener) { + data->search_listener(params, data->search_arg); + } +} + static ARegion *ui_searchbox_create_generic_ex(bContext *C, ARegion *butregion, uiButSearch *search_but, @@ -707,21 +720,24 @@ static ARegion *ui_searchbox_create_generic_ex(bContext *C, memset(&type, 0, sizeof(ARegionType)); type.draw = ui_searchbox_region_draw_fn; type.free = ui_searchbox_region_free_fn; + type.listener = ui_searchbox_region_listen_fn; type.regionid = RGN_TYPE_TEMPORARY; region->type = &type; - /* create searchbox data */ + /* Create search-box data. */ uiSearchboxData *data = MEM_cnew<uiSearchboxData>(__func__); + data->search_arg = search_but->arg; + data->search_listener = search_but->listen_fn; - /* set font, get bb */ + /* Set font, get the bounding-box. */ data->fstyle = style->widget; /* copy struct */ ui_fontscale(&data->fstyle.points, aspect); UI_fontstyle_set(&data->fstyle); region->regiondata = data; - /* special case, hardcoded feature, not draw backdrop when called from menus, - * assume for design that popup already added it */ + /* Special case, hard-coded feature, not draw backdrop when called from menus, + * assume for design that popup already added it. */ if (but->block->flag & UI_BLOCK_SEARCH_MENU) { data->noback = true; } |