[Bf-blender-cvs] [518d7dbebbd] master: UI/Nodes: Update node add menu as assets get loaded

Julian Eisel noreply at git.blender.org
Tue Nov 1 17:44:08 CET 2022


Commit: 518d7dbebbdce2d5a347c7e53eae216a56f44e2a
Author: Julian Eisel
Date:   Tue Nov 1 17:39:26 2022 +0100
Branches: master
https://developer.blender.org/rB518d7dbebbdce2d5a347c7e53eae216a56f44e2a

UI/Nodes: Update node add menu as assets get loaded

Adds a listener to the node add menu so that it refreshes as assets get
loaded asynchronously.

Followup to cf985180551d, also see 99e5024e97f1 and the previous commit.

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

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 4e305ac8af4..1ba1d67d854 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -17,6 +17,7 @@
 #include "RNA_prototypes.h"
 
 #include "ED_asset.h"
+#include "ED_screen.h"
 
 #include "node_intern.hh"
 
@@ -27,6 +28,20 @@ static bool node_add_menu_poll(const bContext *C, MenuType * /*mt*/)
   return CTX_wm_space_node(C);
 }
 
+static void node_add_menu_assets_listen_fn(const wmRegionListenerParams *params)
+{
+  const wmNotifier *wmn = params->notifier;
+  ARegion *region = params->region;
+
+  switch (wmn->category) {
+    case NC_ASSET:
+      if (wmn->data == ND_ASSET_LIST_READING) {
+        ED_region_tag_refresh_ui(region);
+      }
+      break;
+  }
+}
+
 struct LibraryAsset {
   AssetLibraryReference library_ref;
   AssetHandle handle;
@@ -261,6 +276,7 @@ MenuType add_catalog_assets_menu_type()
   BLI_strncpy(type.idname, "NODE_MT_node_add_catalog_assets", sizeof(type.idname));
   type.poll = node_add_menu_poll;
   type.draw = node_add_catalog_assets_draw;
+  type.listener = node_add_menu_assets_listen_fn;
   return type;
 }
 
@@ -270,6 +286,7 @@ MenuType add_root_catalogs_menu_type()
   BLI_strncpy(type.idname, "NODE_MT_node_add_root_catalogs", sizeof(type.idname));
   type.poll = node_add_menu_poll;
   type.draw = add_root_catalogs_draw;
+  type.listener = node_add_menu_assets_listen_fn;
   return type;
 }



More information about the Bf-blender-cvs mailing list