[Bf-blender-cvs] [becc36cce52] master: Geometry Nodes: Sort attribute search items when menu opens
Hans Goudey
noreply at git.blender.org
Fri Mar 5 21:45:16 CET 2021
Commit: becc36cce5248417fe4f626dedb50804c0e0eb1d
Author: Hans Goudey
Date: Fri Mar 5 14:45:09 2021 -0600
Branches: master
https://developer.blender.org/rBbecc36cce5248417fe4f626dedb50804c0e0eb1d
Geometry Nodes: Sort attribute search items when menu opens
Because the search didn't run when the menu first opens, the attributes
appeared in a different order than after you typed anything into the
search field. This commit instead runs the search when the menu
is first opened, but it only sorts items without filtering.
===================================================================
M source/blender/editors/space_node/node_geometry_attribute_search.cc
===================================================================
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 982c57eb3ec..b03346577a8 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -75,15 +75,9 @@ static void attribute_search_update_fn(
UI_search_item_add(items, str, (void *)str, ICON_X, 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;
- }
+ /* 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) {
@@ -91,7 +85,7 @@ static void attribute_search_update_fn(
}
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];
More information about the Bf-blender-cvs
mailing list