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:
Diffstat (limited to 'source/blender/editors/space_node/node_geometry_attribute_search.cc')
-rw-r--r--source/blender/editors/space_node/node_geometry_attribute_search.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index 41f04dad221..6d0cd254505 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -37,6 +37,7 @@
using blender::IndexRange;
using blender::Map;
+using blender::MultiValueMap;
using blender::Set;
using blender::StringRef;
@@ -62,30 +63,31 @@ static void attribute_search_update_fn(
return;
}
- const Set<std::string> &attribute_name_hints = ui_storage->attribute_name_hints;
+ const MultiValueMap<std::string, AvailableAttributeInfo> &attribute_hints =
+ ui_storage->attribute_hints;
- if (str[0] != '\0' && !attribute_name_hints.contains_as(StringRef(str))) {
+ if (str[0] != '\0' && attribute_hints.lookup_as(StringRef(str)).is_empty()) {
/* Any string may be valid, so add the current search string with the hints. */
UI_search_item_add(items, str, (void *)str, ICON_ADD, 0, 0);
}
- /* Skip the filter when the menu is first opened, so all of the items are visible. */
- if (is_first) {
- for (const std::string &attribute_name : attribute_name_hints) {
- /* Just use the pointer to the name string as the search data,
- * since it's not used anyway but we need a pointer. */
- UI_search_item_add(items, attribute_name.c_str(), (void *)&attribute_name, ICON_NONE, 0, 0);
- }
- return;
+ if (str[0] == '\0' && !is_first) {
+ /* Allow clearing the text field when the string is empty, but not on the first pass,
+ * or opening an attribute field for the first time would show this search item. */
+ UI_search_item_add(items, str, (void *)str, ICON_X, 0, 0);
}
+ /* Don't filter when the menu is first opened, but still run the search
+ * so the items are in the same order they will appear in while searching. */
+ const char *string = is_first ? "" : str;
+
StringSearch *search = BLI_string_search_new();
- for (const std::string &attribute_name : attribute_name_hints) {
+ for (const std::string &attribute_name : attribute_hints.keys()) {
BLI_string_search_add(search, attribute_name.c_str(), (void *)&attribute_name);
}
std::string **filtered_items;
- const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
+ const int filtered_amount = BLI_string_search_query(search, string, (void ***)&filtered_items);
for (const int i : IndexRange(filtered_amount)) {
std::string *item = filtered_items[i];