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:
authorLukas Stockner <lukas.stockner@freenet.de>2022-04-11 03:02:12 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2022-04-12 00:40:48 +0300
commit484a9146479e05946d291e9886cdf3febca6d05d (patch)
tree977dfae2383938826d27cfcf6827031f9c50ff9a /source/blender/editors/space_node/node_templates.cc
parentb3525c3487ca893aac5bb8241ce154f491508224 (diff)
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while hovering over its value field shows "Default value", which is not helpful. This patch therefore implements socket tooltips following the proposal at https://blender.community/c/rightclickselect/2Qgbbc/. A lot of the basic functionality was already implemented for Geometry Nodes, where hovering over the socket itself shows introspection info. This patch extends this by: - Supporting dynamic tooltips on labels, which is important for good tooltip coverage in a socket's region of the node. - Adding a function to setting a dynamic tooltip for an entire uiLayout, which avoids needing to set it manually for a wide variety of socket types. - Hiding the property label field in a tooltip when dynamic tooltip is also provided. If really needed, this label can be restored through the dynamic tooltip, but in all current cases the label is actually pointless anyways since the dynamic tooltip gives more accurate and specific information. - Adding dynamic tooltips to a socket's UI layout row if it has a description configured, both in the Node Editor as well as in the Material Properties. Note that the patch does not add any actual tooltip content yet, just the infrastructure to show them. By default, sockets without a description still show the old "Default value" tooltip. For an example of how to add socket descriptions, check the Cylinder node in the Geometry Nodes. Differential Revision: https://developer.blender.org/D9967
Diffstat (limited to 'source/blender/editors/space_node/node_templates.cc')
-rw-r--r--source/blender/editors/space_node/node_templates.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc
index e92e0571157..58a313c328e 100644
--- a/source/blender/editors/space_node/node_templates.cc
+++ b/source/blender/editors/space_node/node_templates.cc
@@ -852,23 +852,19 @@ static void ui_node_draw_input(
}
}
else {
- row = uiLayoutRow(row, true);
+ uiLayout *sub = uiLayoutRow(row, true);
- uiTemplateNodeLink(row, C, ntree, node, input);
+ uiTemplateNodeLink(sub, C, ntree, node, input);
if (input->flag & SOCK_HIDE_VALUE) {
add_dummy_decorator = true;
}
/* input not linked, show value */
else {
- uiLayout *sub = row;
-
switch (input->type) {
case SOCK_VECTOR:
- if (input->type == SOCK_VECTOR) {
- uiItemS(row);
- sub = uiLayoutColumn(row, true);
- }
+ uiItemS(sub);
+ sub = uiLayoutColumn(sub, true);
ATTR_FALLTHROUGH;
case SOCK_FLOAT:
case SOCK_INT:
@@ -884,7 +880,7 @@ static void ui_node_draw_input(
if (node_tree->type == NTREE_GEOMETRY && snode != nullptr) {
/* Only add the attribute search in the node editor, in other places there is not
* enough context. */
- node_geometry_add_attribute_search_button(*C, *node, inputptr, *row);
+ node_geometry_add_attribute_search_button(*C, *node, inputptr, *sub);
}
else {
uiItemR(sub, &inputptr, "default_value", 0, "", ICON_NONE);
@@ -903,6 +899,8 @@ static void ui_node_draw_input(
uiItemDecoratorR(split_wrapper.decorate_column, nullptr, nullptr, 0);
}
+ node_socket_add_tooltip(ntree, node, input, row);
+
/* clear */
node->flag &= ~NODE_TEST;
}