diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-13 23:23:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-13 23:27:51 +0300 |
commit | da1038c768557c88d29ce74a98026ca4915ab2c3 (patch) | |
tree | e7de45c14c5b3fee4a18fd7b5e2bed334df0b7ad /source/blender/editors/interface/interface_ops.c | |
parent | fc31bae66fdf0daa14da2eb81ba537f2ff325a96 (diff) |
UI: Copy to selected nodes now filtered by type
Was needed because sockets are very generic type which would match on unrelated values.
Diffstat (limited to 'source/blender/editors/interface/interface_ops.c')
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index d13078f6cf2..643397b5a5c 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_global.h" +#include "BKE_node.h" #include "BKE_text.h" /* for UI_OT_reports_to_text */ #include "BKE_report.h" @@ -278,13 +279,48 @@ bool UI_context_copy_to_selected_list( else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) { *r_lb = CTX_data_collection_get(C, "selected_editable_sequences"); } - else if (RNA_struct_is_a(ptr->type, &RNA_Node)) { - *r_lb = CTX_data_collection_get(C, "selected_nodes"); - } - else if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) { - if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Node)) != NULL) { - *r_lb = CTX_data_collection_get(C, "selected_nodes"); + else if (RNA_struct_is_a(ptr->type, &RNA_Node) || + RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) + { + ListBase lb = {NULL, NULL}; + char *path = NULL; + bNode *node = NULL; + + /* Get the node we're editing */ + if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) { + bNodeTree *ntree = ptr->id.data; + bNodeSocket *sock = ptr->data; + if (nodeFindNode(ntree, sock, &node, NULL)) { + if ((path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Node)) != NULL) { + /* we're good! */ + } + else { + node = NULL; + } + } + } + else { + node = ptr->data; + } + + /* Now filter by type */ + if (node) { + CollectionPointerLink *link, *link_next; + lb = CTX_data_collection_get(C, "selected_nodes"); + + for (link = lb.first; link; link = link_next) { + bNode *node_data = link->ptr.data; + link_next = link->next; + + if (node_data->type != node->type) { + BLI_remlink(&lb, link); + MEM_freeN(link); + } + } } + + *r_lb = lb; + *r_path = path; } else if (ptr->id.data) { ID *id = ptr->id.data; |