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 cf98518055, also see 99e5024e97 and the previous commit.
This commit is contained in:
2022-11-01 17:39:26 +01:00
parent 78a7d5cfcc
commit 518d7dbebb

View File

@@ -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;
}