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 Tönne <lukas.toenne@gmail.com>2021-07-06 20:36:11 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2021-07-06 20:36:11 +0300
commit586cf8b1905257bf0f7d9c20b5333271f9cab3e9 (patch)
tree5fa77626641c47f4274b9145a1f1702512fc92b6 /source/blender/editors/space_node/node_buttons.c
parent933eddc9a113b40849895922f2dc350305809ebd (diff)
Nodes: Adds button to groups to change type of sockets.
The menu lists all socket types that are valid for the node tree. Changing a socket type updates all instances of the group and keeps existing links to the socket. If changing the socket type leads to incorrect node connections the links are flagged as invalid (red) and ignored but not removed. This is so users don't lose information and can then fix resulting issues. For example: Changing a Color socket to a Shader socket can cause an invalid Shader-to-Color connection. Implementation details: The new `NODE_OT_tree_socket_change_type` operator uses the generic `rna_node_socket_type_itemf` function to list all eligible socket types. It uses the tree type's `valid_socket_type` callback to test for valid types. In addition it also checks the subtype, because multiple RNA types are registered for the same base type. The `valid_socket_type` callback has been modified slightly to accept full socket types instead of just the base type enum, so that custom (python) socket types can be used by this operator. The `nodeModifySocketType` function is now called when group nodes encounter a socket type mismatch, instead of replacing the socket entirely. This ensures that links are kept to/from group nodes as well as group input/output nodes. The `nodeModifySocketType` function now also takes a full `bNodeSocketType` instead of just the base and subtype enum (a shortcut `nodeModifySocketTypeStatic` exists for when only static types are used). Differential Revision: https://developer.blender.org/D10912
Diffstat (limited to 'source/blender/editors/space_node/node_buttons.c')
-rw-r--r--source/blender/editors/space_node/node_buttons.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index 336b0c46a81..a55cc21fb16 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -151,10 +151,37 @@ static void draw_socket_list(const bContext *C,
bNodeSocket *socket = node_tree_find_active_socket(ntree, in_out);
if (socket != NULL) {
- uiLayoutSetPropSep(layout, true);
- uiLayoutSetPropDecorate(layout, false);
PointerRNA socket_ptr;
RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, socket, &socket_ptr);
+
+ {
+ /* Mimicking property split */
+ uiLayoutSetPropSep(layout, false);
+ uiLayoutSetPropDecorate(layout, false);
+ uiLayout *layout_row = uiLayoutRow(layout, true);
+ uiLayout *layout_split = uiLayoutSplit(layout_row, 0.4f, true);
+
+ uiLayout *label_column = uiLayoutColumn(layout_split, true);
+ uiLayoutSetAlignment(label_column, UI_LAYOUT_ALIGN_RIGHT);
+ /* Menu to change the socket type. */
+ uiItemL(label_column, "Type", ICON_NONE);
+
+ uiLayout *property_row = uiLayoutRow(layout_split, true);
+
+ PointerRNA props_ptr;
+ uiItemMenuEnumFullO(property_row,
+ (bContext *)C,
+ "NODE_OT_tree_socket_change_type",
+ "socket_type",
+ nodeSocketTypeLabel(socket->typeinfo),
+ ICON_NONE,
+ &props_ptr);
+ RNA_enum_set(&props_ptr, "in_out", in_out);
+ }
+
+ uiLayoutSetPropSep(layout, true);
+ uiLayoutSetPropDecorate(layout, false);
+
uiItemR(layout, &socket_ptr, "name", 0, NULL, ICON_NONE);
/* Display descriptions only for Geometry Nodes, since it's only used in the modifier panel. */