UI: Copy to selected nodes now filtered by type

Was needed because sockets are very generic type which would match on unrelated values.
This commit is contained in:
Campbell Barton
2015-05-14 06:23:41 +10:00
parent fc31bae66f
commit da1038c768

View File

@@ -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;