diff options
author | Julian Eisel <julian@blender.org> | 2021-04-12 19:43:23 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-04-12 19:48:22 +0300 |
commit | 2bd9f9d976560c55a15ed297032f7d73c2f101cc (patch) | |
tree | d109e1131272c799f16825ce1818aac1e79fe1fc /source/blender/editors/space_node/node_group.c | |
parent | cbd193261969c9b4e1f14297d5888bad2946600e (diff) |
UI/Nodes: Improve feedback when adding node fails (e.g. on drag & drop)
This is especially useful when trying to add a node group instance, e.g. via
drag & drop from the Outliner or Asset Browser.
Previously this would just silently fail, with no information why. This is a
source of confusion, e.g. earlier, it took me a moment to realize I was
dragging a node group into itself, which failed of course.
Blender should always try to help the user with useful error messages.
Adds error messages like: "Nesting a node group inside of itself is not
allowed", "Not a compositor node tree", etc.
Adds a disabled hint return argument to node and node tree polling functions.
On error the hint is reported, or could even be shown in advance (e.g. if
checked via an operator poll option).
Differential Revision: https://developer.blender.org/D10422
Reviewed by: Jacques Lucke
Diffstat (limited to 'source/blender/editors/space_node/node_group.c')
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index e1de4bfc21e..335e2f93ff3 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -679,8 +679,19 @@ static bool node_group_make_test_selected(bNodeTree *ntree, /* check poll functions for selected nodes */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node_group_make_use_node(node, gnode)) { - if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, ngroup)) { - BKE_reportf(reports, RPT_WARNING, "Can not add node '%s' in a group", node->name); + const char *disabled_hint = NULL; + if (node->typeinfo->poll_instance && + !node->typeinfo->poll_instance(node, ngroup, &disabled_hint)) { + if (disabled_hint) { + BKE_reportf(reports, + RPT_WARNING, + "Can not add node '%s' in a group:\n %s", + node->name, + disabled_hint); + } + else { + BKE_reportf(reports, RPT_WARNING, "Can not add node '%s' in a group", node->name); + } ok = false; break; } |