Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-04-12 19:43:23 +0300
committerJulian Eisel <julian@blender.org>2021-04-12 19:48:22 +0300
commit2bd9f9d976560c55a15ed297032f7d73c2f101cc (patch)
treed109e1131272c799f16825ce1818aac1e79fe1fc /source/blender/nodes/texture
parentcbd193261969c9b4e1f14297d5888bad2946600e (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/nodes/texture')
-rw-r--r--source/blender/nodes/texture/node_texture_util.c10
-rw-r--r--source/blender/nodes/texture/node_texture_util.h4
2 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 2091a8bf10e..570b10d6e89 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -39,9 +39,15 @@
#include "node_texture_util.h"
-bool tex_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
+bool tex_node_poll_default(bNodeType *UNUSED(ntype),
+ bNodeTree *ntree,
+ const char **r_disabled_hint)
{
- return STREQ(ntree->idname, "TextureNodeTree");
+ if (!STREQ(ntree->idname, "TextureNodeTree")) {
+ *r_disabled_hint = "Not a texture node tree";
+ return false;
+ }
+ return true;
}
void tex_node_type_base(
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 74f27ef3974..8f63a1ad07d 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -106,7 +106,9 @@ typedef struct TexDelegate {
int type;
} TexDelegate;
-bool tex_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
+bool tex_node_poll_default(struct bNodeType *ntype,
+ struct bNodeTree *ntree,
+ const char **r_disabled_hint);
void tex_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);