From 518d7dbebbdce2d5a347c7e53eae216a56f44e2a Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 1 Nov 2022 17:39:26 +0100 Subject: [PATCH] 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. --- .../editors/space_node/add_menu_assets.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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; }