diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-10 19:49:41 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-04-10 19:49:41 +0400 |
commit | 4f06c1520238eb32ddf5ee20501c8293212f3a57 (patch) | |
tree | 60c7d8d27c90eeca05a3cc8a1b28416d23a199c2 /source/blender/editors/interface/interface_ops.c | |
parent | 530f19912425949f3e3c6bd230e6831ceab1d016 (diff) |
Fix properties editor, right click menu "Copy to Selected" not working for
object modifier/constraint/physics properties. Now uses RNA path rather than
only properties on the object itself.
Diffstat (limited to 'source/blender/editors/interface/interface_ops.c')
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index ebaef26082f..c3adadafe58 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -348,39 +348,53 @@ static void UI_OT_reset_default_button(wmOperatorType *ot) static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb) { - if (RNA_struct_is_a(ptr->type, &RNA_Object)) - *lb = CTX_data_collection_get(C, "selected_editable_objects"); - else if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) + if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) *lb = CTX_data_collection_get(C, "selected_editable_bones"); else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) *lb = CTX_data_collection_get(C, "selected_pose_bones"); else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) *lb = CTX_data_collection_get(C, "selected_editable_sequences"); - else - return 0; + else { + ID *id = ptr->id.data; + + if(id && GS(id->name) == ID_OB) + *lb = CTX_data_collection_get(C, "selected_editable_objects"); + else + return 0; + } return 1; } static int copy_to_selected_button_poll(bContext *C) { - PointerRNA ptr; - PropertyRNA *prop; + PointerRNA ptr, lptr, idptr; + PropertyRNA *prop, *lprop; int index, success = 0; uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.data && prop) { + char *path = RNA_path_from_ID_to_property(&ptr, prop); CollectionPointerLink *link; ListBase lb; - if (copy_to_selected_list(C, &ptr, &lb)) { - for (link = lb.first; link; link = link->next) - if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) - success = 1; + if (path && copy_to_selected_list(C, &ptr, &lb)) { + for (link = lb.first; link; link = link->next) { + if (link->ptr.data != ptr.data) { + RNA_id_pointer_create(link->ptr.id.data, &idptr); + + if (RNA_path_resolve(&idptr, path, &lptr, &lprop) && lprop == prop) { + if (RNA_property_editable(&lptr, prop)) + success = 1; + } + } + } BLI_freelistN(&lb); } + + MEM_freeN(path); } return success; @@ -388,8 +402,8 @@ static int copy_to_selected_button_poll(bContext *C) static int copy_to_selected_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr; - PropertyRNA *prop; + PointerRNA ptr, lptr, idptr; + PropertyRNA *prop, *lprop; int success = 0; int index, all = RNA_boolean_get(op->ptr, "all"); @@ -398,21 +412,29 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op) /* if there is a valid property that is editable... */ if (ptr.data && prop) { + char *path = RNA_path_from_ID_to_property(&ptr, prop); CollectionPointerLink *link; ListBase lb; - if (copy_to_selected_list(C, &ptr, &lb)) { + if (path && copy_to_selected_list(C, &ptr, &lb)) { for (link = lb.first; link; link = link->next) { - if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) { - if (RNA_property_copy(&link->ptr, &ptr, prop, (all) ? -1 : index)) { - RNA_property_update(C, &link->ptr, prop); - success = 1; + if (link->ptr.data != ptr.data) { + RNA_id_pointer_create(link->ptr.id.data, &idptr); + if (RNA_path_resolve(&idptr, path, &lptr, &lprop) && lprop == prop) { + if(RNA_property_editable(&lptr, lprop)) { + if (RNA_property_copy(&lptr, &ptr, prop, (all) ? -1 : index)) { + RNA_property_update(C, &lptr, prop); + success = 1; + } + } } } } BLI_freelistN(&lb); } + + MEM_freeN(path); } return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; |