UI/Nodes: Adding node groups via drag & drop (e.g. from Asset Browser)

Adds `NODE_OT_add_group` operator to add a node group from a given name, and
uses that to register a node editor drop-box.
When dropping a node-group asset, the ID will be appended. This is what we do
for other ID assets too.

Should the node group insertion fail (e.g. the group is not compatible with the
current tree, as checked by the poll), the appended data-block is removed.

Differential Revision: https://developer.blender.org/D10405

Reviewed by: Jacques Lucke
This commit is contained in:
2021-02-15 19:35:24 +01:00
parent 45852532d5
commit 604e61d81d
5 changed files with 133 additions and 5 deletions

View File

@@ -107,7 +107,7 @@ static const char *group_ntree_idname(bContext *C)
return snode->tree_idname;
}
static const char *group_node_idname(bContext *C)
const char *node_group_idname(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
@@ -147,7 +147,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
static int node_group_edit_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
const char *node_idname = node_group_idname(C);
const bool exit = RNA_boolean_get(op->ptr, "exit");
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -400,7 +400,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
const char *node_idname = node_group_idname(C);
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
@@ -1013,7 +1013,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
const char *ntree_idname = group_ntree_idname(C);
const char *node_idname = group_node_idname(C);
const char *node_idname = node_group_idname(C);
Main *bmain = CTX_data_main(C);
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
@@ -1070,7 +1070,7 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
const char *node_idname = group_node_idname(C);
const char *node_idname = node_group_idname(C);
Main *bmain = CTX_data_main(C);
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));