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
This commit is contained in:
parent
86915d04ee
commit
170293475c
Notes:
blender-bot
2023-02-14 08:33:26 +01:00
Referenced by issue #86399, Tooltip for Group Input properties
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in New Issue