[Bf-blender-cvs] [170293475c3] master: Nodes: Tooltip for Group Input properties

Fabian Schempp noreply at git.blender.org
Tue Apr 13 22:12:13 CEST 2021


Commit: 170293475c36b4c462bdad372a03533d2b948bf1
Author: Fabian Schempp
Date:   Tue Apr 13 22:11:58 2021 +0200
Branches: master
https://developer.blender.org/rB170293475c36b4c462bdad372a03533d2b948bf1

Nodes: Tooltip for Group Input properties

With this patch, users can define custom tooltips for the exposed
properties of their Geometry Nodes Groups.
Currently this custom tooltips are only used in the modifier panel,
but its a long term goal to use it in the node editor.

Reviewer: Hans Goudey

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

===================================================================

M	source/blender/editors/space_node/node_buttons.c
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/modifiers/intern/MOD_nodes.cc

===================================================================

diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index eb89658857b..336b0c46a81 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -157,6 +157,11 @@ static void draw_socket_list(const bContext *C,
     RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, socket, &socket_ptr);
     uiItemR(layout, &socket_ptr, "name", 0, NULL, ICON_NONE);
 
+    /* Display descriptions only for Geometry Nodes, since it's only used in the modifier panel. */
+    if (ntree->type == NTREE_GEOMETRY) {
+      uiItemR(layout, &socket_ptr, "description", 0, NULL, ICON_NONE);
+    }
+
     if (socket->typeinfo->interface_draw) {
       socket->typeinfo->interface_draw((bContext *)C, layout, &socket_ptr);
     }
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 334d683deff..282d71f6a87 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -125,6 +125,7 @@ typedef struct bNodeSocket {
 
   /** Custom dynamic defined label, MAX_NAME. */
   char label[64];
+  char description[64];
 
   /** Cached data from execution. */
   void *cache;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 1016d31f11b..21460607e38 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9725,6 +9725,11 @@ static void rna_def_node_socket(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Identifier", "Unique identifier for mapping sockets");
 
+  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
+  RNA_def_property_string_sdna(prop, NULL, "description");
+  RNA_def_property_ui_text(prop, "Tooltip", "Socket tooltip");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_update");
+
   prop = RNA_def_property(srna, "is_output", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_funcs(prop, "rna_NodeSocket_is_output_get", NULL);
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -9869,6 +9874,11 @@ static void rna_def_node_socket_interface(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Identifier", "Unique identifier for mapping sockets");
 
+  prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
+  RNA_def_property_string_sdna(prop, NULL, "description");
+  RNA_def_property_ui_text(prop, "Tooltip", "Socket tooltip");
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
+
   prop = RNA_def_property(srna, "is_output", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_funcs(prop, "rna_NodeSocket_is_output_get", NULL);
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 4fc940b3244..216a1c43d3e 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -703,6 +703,14 @@ static IDProperty *socket_add_property(IDProperty *settings_prop_group,
     IDP_AddToGroup(ui_container, prop_ui_group);
   }
 
+  /* Set property description (tooltip). */
+  IDPropertyTemplate property_description_template;
+  property_description_template.string.str = socket.description;
+  property_description_template.string.len = BLI_strnlen(socket.description, MAX_NAME) + 1;
+  property_description_template.string.subtype = IDP_STRING_SUB_UTF8;
+  IDProperty *description = IDP_New(IDP_STRING, &property_description_template, "description");
+  IDP_AddToGroup(prop_ui_group, description);
+
   /* Create the properties for the socket's UI settings. */
   if (property_type.create_min_ui_prop != nullptr) {
     IDP_AddToGroup(prop_ui_group, property_type.create_min_ui_prop(socket, "min"));



More information about the Bf-blender-cvs mailing list