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
This commit is contained in:
		@@ -17,10 +17,16 @@
 | 
			
		||||
#include "node_function_util.hh"
 | 
			
		||||
#include "node_util.h"
 | 
			
		||||
 | 
			
		||||
bool fn_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
 | 
			
		||||
static bool fn_node_poll_default(bNodeType *UNUSED(ntype),
 | 
			
		||||
                                 bNodeTree *ntree,
 | 
			
		||||
                                 const char **r_disabled_hint)
 | 
			
		||||
{
 | 
			
		||||
  /* Function nodes are only supported in simulation node trees so far. */
 | 
			
		||||
  return STREQ(ntree->idname, "GeometryNodeTree");
 | 
			
		||||
  if (!STREQ(ntree->idname, "GeometryNodeTree")) {
 | 
			
		||||
    *r_disabled_hint = "Not a geometry node tree";
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
 | 
			
		||||
 
 | 
			
		||||
@@ -38,4 +38,3 @@
 | 
			
		||||
 | 
			
		||||
void fn_node_type_base(
 | 
			
		||||
    struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
 | 
			
		||||
bool fn_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user