Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/include/UI_interface.h7
-rw-r--r--source/blender/editors/interface/interface.c11
-rw-r--r--source/blender/editors/interface/interface_handlers.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h9
-rw-r--r--source/blender/editors/interface/interface_region_search.c17
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c3
-rw-r--r--source/blender/editors/interface/interface_template_search_operator.c3
-rw-r--r--source/blender/editors/interface/interface_templates.c8
-rw-r--r--source/blender/editors/interface/interface_utils.c5
-rw-r--r--source/blender/editors/space_node/node_select.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c3
11 files changed, 55 insertions, 20 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 81641239c6a..09e1a269ae1 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -499,10 +499,14 @@ typedef int (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
typedef struct ARegion *(*uiButSearchCreateFn)(struct bContext *C,
struct ARegion *butregion,
struct uiButSearch *search_but);
+/* `is_first` is typically used to ignore search filtering when the menu is first opened in order
+ * to display the full list of options. The value will be false after the button's text is edited
+ * (for every call except the first). */
typedef void (*uiButSearchUpdateFn)(const struct bContext *C,
void *arg,
const char *str,
- uiSearchItems *items);
+ uiSearchItems *items,
+ const bool is_first);
typedef void (*uiButSearchArgFreeFn)(void *arg);
typedef bool (*uiButSearchContextMenuFn)(struct bContext *C,
void *arg,
@@ -1602,6 +1606,7 @@ void UI_but_func_search_set(uiBut *but,
void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn);
void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn);
void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string);
+void UI_but_func_search_set_all_strings_valid(uiBut *but, const bool value);
/* height in pixels, it's using hardcoded values still */
int UI_searchbox_size_y(void);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 6e25ec9d275..ed2984e1a86 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -6661,11 +6661,20 @@ void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn)
but_search->item_tooltip_fn = tooltip_fn;
}
+void UI_but_func_search_set_all_strings_valid(uiBut *but, const bool value)
+{
+ uiButSearch *but_search = (uiButSearch *)but;
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+
+ but_search->all_strings_valid = value;
+}
+
/* Callbacks for operator search button. */
static void operator_enum_search_update_fn(const struct bContext *C,
void *but,
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
wmOperatorType *ot = ((uiBut *)but)->optype;
PropertyRNA *prop = ot->prop;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 5de330d7136..40202250d9f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3408,8 +3408,12 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
if (data->searchbox) {
if (data->cancel == false) {
+ BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+ uiButSearch *but_search = (uiButSearch *)but;
+
if ((ui_searchbox_apply(but, data->searchbox) == false) &&
- (ui_searchbox_find_index(data->searchbox, but->editstr) == -1)) {
+ (ui_searchbox_find_index(data->searchbox, but->editstr) == -1) &&
+ !but_search->all_strings_valid) {
data->cancel = true;
/* ensure menu (popup) too is closed! */
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 7e931eae749..9d0184ce487 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -320,6 +320,12 @@ typedef struct uiButSearch {
struct PointerRNA rnasearchpoin;
struct PropertyRNA *rnasearchprop;
+
+ /**
+ * The search box only provides suggestions, it does not force
+ * the string to match one of the search items when applying.
+ */
+ bool all_strings_valid;
} uiButSearch;
/** Derived struct for #UI_BTYPE_DECORATOR */
@@ -1197,7 +1203,8 @@ typedef struct uiRNACollectionSearch {
void ui_rna_collection_search_update_fn(const struct bContext *C,
void *arg,
const char *str,
- uiSearchItems *items);
+ uiSearchItems *items,
+ const bool is_first);
/* interface_ops.c */
bool ui_jump_to_target_button_poll(struct bContext *C);
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index 2c07f5c3c03..9297da5307a 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -468,7 +468,8 @@ static void ui_searchbox_update_fn(bContext *C,
wmWindow *win = CTX_wm_window(C);
WM_tooltip_clear(C, win);
}
- search_but->items_update_fn(C, search_but->arg, str, items);
+ const bool is_first_search = !search_but->but.changed;
+ search_but->items_update_fn(C, search_but->arg, str, items, is_first_search);
}
/* region is the search box itself */
@@ -1052,14 +1053,16 @@ void ui_but_search_refresh(uiButSearch *search_but)
ui_searchbox_update_fn(but->block->evil_C, search_but, but->drawstr, items);
- /* Only red-alert when we are sure of it, this can miss cases when >10 matches. */
- if (items->totitem == 0) {
- UI_but_flag_enable(but, UI_BUT_REDALERT);
- }
- else if (items->more == 0) {
- if (UI_search_items_find_index(items, but->drawstr) == -1) {
+ if (!search_but->all_strings_valid) {
+ /* Only red-alert when we are sure of it, this can miss cases when >10 matches. */
+ if (items->totitem == 0) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
+ else if (items->more == 0) {
+ if (UI_search_items_find_index(items, but->drawstr) == -1) {
+ UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
+ }
}
for (x1 = 0; x1 < items->maxitem; x1++) {
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c
index 25cf2e12377..e1f8f63dcbf 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -990,7 +990,8 @@ 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)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
struct MenuSearch_Data *data = arg;
diff --git a/source/blender/editors/interface/interface_template_search_operator.c b/source/blender/editors/interface/interface_template_search_operator.c
index ff0f9a2e5cd..2c83f184ff0 100644
--- a/source/blender/editors/interface/interface_template_search_operator.c
+++ b/source/blender/editors/interface/interface_template_search_operator.c
@@ -59,7 +59,8 @@ static void operator_search_exec_fn(bContext *C, void *UNUSED(arg1), void *arg2)
static void operator_search_update_fn(const bContext *C,
void *UNUSED(arg),
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
GHashIterator iter;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 67446ca681f..eadbe618899 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -393,7 +393,8 @@ static bool id_search_add(const bContext *C, TemplateID *template_ui, uiSearchIt
static void id_search_cb(const bContext *C,
void *arg_template,
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
@@ -464,7 +465,8 @@ static void id_search_cb_tagged(const bContext *C,
static void id_search_cb_objects_from_scene(const bContext *C,
void *arg_template,
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
@@ -518,7 +520,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *region, void *arg_litem)
static TemplateID template_ui;
PointerRNA active_item_ptr;
void (*id_search_update_fn)(
- const bContext *, void *, const char *, uiSearchItems *) = id_search_cb;
+ const bContext *, void *, const char *, uiSearchItems *, const bool) = id_search_cb;
/* arg_litem is malloced, can be freed by parent button */
template_ui = *((TemplateID *)arg_litem);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 5311bb57da9..877800c1ba2 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -405,7 +405,8 @@ static bool add_collection_search_item(CollItemSearch *cis,
void ui_rna_collection_search_update_fn(const struct bContext *C,
void *arg,
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool is_first)
{
uiRNACollectionSearch *data = arg;
const int flag = RNA_property_flag(data->target_prop);
@@ -415,7 +416,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
* match the RNA name exactly. So only for pointer properties, the name can be modified to add
* further UI hints. */
const bool requires_exact_data_name = !is_ptr_target;
- const bool skip_filter = data->search_but && !data->search_but->changed;
+ const bool skip_filter = is_first;
char name_buf[UI_MAX_DRAW_STR];
char *name;
bool has_id_icon = false;
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 58d22c2864f..704b7350bb9 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -1178,7 +1178,8 @@ static void node_find_create_label(const bNode *node, char *str, int maxlen)
static void node_find_update_fn(const struct bContext *C,
void *UNUSED(arg),
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
SpaceNode *snode = CTX_wm_space_node(C);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 8726fd768d4..b735064cfef 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -554,7 +554,8 @@ static void merged_element_search_fn_recursive(
static void merged_element_search_update_fn(const bContext *UNUSED(C),
void *data,
const char *str,
- uiSearchItems *items)
+ uiSearchItems *items,
+ const bool UNUSED(is_first))
{
MergedSearchData *search_data = (MergedSearchData *)data;
TreeElement *parent = search_data->parent_element;