diff options
author | Julian Eisel <julian@blender.org> | 2022-11-01 19:36:36 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-11-01 19:43:38 +0300 |
commit | 78a7d5cfccdc09293acd97e789d60bfd806910c5 (patch) | |
tree | 028e3c94f1cbaf1fbb73ec102e48c674982a8e61 /source/blender/editors/interface/interface_layout.c | |
parent | bcc2656299ad72b224c5f2644518759561c31045 (diff) |
UI: Support C defined menu types to listen to notifiers
Needed to dynamically load assets as menu items, see cf985180551d and
99e5024e97f1. The next commit will add the listener for the node add menu.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 496f72c089a..a456cef7be6 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5814,6 +5814,14 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout) printf("%s: opening menu \"%s\"\n", __func__, mt->idname); } + if (mt->listener) { + /* Forward the menu type listener to the block we're drawing in. */ + uiBlock *block = uiLayoutGetBlock(layout); + uiBlockDynamicListener *listener = MEM_mallocN(sizeof(*listener), "uiBlockDynamicListener"); + listener->listener_func = mt->listener; + BLI_addtail(&block->dynamic_listeners, listener); + } + if (layout->context) { CTX_store_set(C, layout->context); } |