[Bf-blender-cvs] [67f907a2c50] node-add-asset-menu: Avoid duplication of builtin menus with hack

Hans Goudey noreply at git.blender.org
Thu Oct 6 21:52:00 CEST 2022


Commit: 67f907a2c50b9150bc06ab24a0eab1606215bf63
Author: Hans Goudey
Date:   Thu Oct 6 14:51:51 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB67f907a2c50b9150bc06ab24a0eab1606215bf63

Avoid duplication of builtin menus with hack

===================================================================

M	source/blender/editors/space_node/add_menu_assets.cc

===================================================================

diff --git a/source/blender/editors/space_node/add_menu_assets.cc b/source/blender/editors/space_node/add_menu_assets.cc
index 8fd3bfcd1f6..c0d448f352a 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -187,7 +187,44 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
   uiLayout *layout = menu->layout;
   uiItemS(layout);
 
+  /* Avoid adding a separate root catalog when the assets have already been added to one of the
+   * builtin menus.
+   * TODO: The need to define the builtin menu labels here is completely non-ideal. We don't have
+   * any UI introspection that can do this though. This can be solved in the near future by
+   * removing the need to define the add menu completely, instead using a per-node-type path which
+   * can be merged with catalog tree.
+   */
+  static Set<std::string> all_builtin_menus = []() {
+    Set<std::string> menus;
+    menus.add_new("Attribute");
+    menus.add_new("Color");
+    menus.add_new("Curve");
+    menus.add_new("Curve Primitives");
+    menus.add_new("Curve Topology");
+    menus.add_new("Geometry");
+    menus.add_new("Input");
+    menus.add_new("Instances");
+    menus.add_new("Material");
+    menus.add_new("Mesh");
+    menus.add_new("Mesh Primitives");
+    menus.add_new("Mesh Topology");
+    menus.add_new("Output");
+    menus.add_new("Point");
+    menus.add_new("Text");
+    menus.add_new("Texture");
+    menus.add_new("Utilities");
+    menus.add_new("UV");
+    menus.add_new("Vector");
+    menus.add_new("Volume");
+    menus.add_new("Group");
+    menus.add_new("Layout");
+    return menus;
+  }();
+
   tree.catalogs.foreach_root_item([&](bke::AssetCatalogTreeItem &item) {
+    if (all_builtin_menus.contains(item.get_name())) {
+      return;
+    }
     const bke::AssetCatalogPath &path = tree.full_catalog_per_tree_item.lookup(&item);
     PointerRNA path_ptr{
         &screen.id, &RNA_AssetCatalogPath, const_cast<bke::AssetCatalogPath *>(&path)};



More information about the Bf-blender-cvs mailing list