Option to copy the data path of an RNA button
authorCampbell Barton <ideasman42@gmail.com>
Wed, 7 Oct 2009 13:22:56 +0000 (13:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 7 Oct 2009 13:22:56 +0000 (13:22 +0000)
source/blender/editors/animation/anim_intern.h
source/blender/editors/animation/anim_ops.c
source/blender/editors/animation/drivers.c
source/blender/editors/interface/interface_anim.c

index 853aeb6c8f3dec4407338f899dbf980c522e17f4..0101e3d0ef719d0898768ea718a1843df7283a69 100644 (file)
@@ -79,4 +79,6 @@ void ANIM_OT_remove_driver_button(struct wmOperatorType *ot);
 void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
 void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
 
+void ANIM_OT_copy_clipboard_button(struct wmOperatorType *ot);
+
 #endif // ANIM_INTERN_H
index 4317204f347ad43bcaa7da72bf7d5ba1a63bf585..83b2e2688c97459ac1847dae25d84120fe0b55ff 100644 (file)
@@ -404,6 +404,8 @@ void ED_operatortypes_anim(void)
        WM_operatortype_append(ANIM_OT_copy_driver_button);
        WM_operatortype_append(ANIM_OT_paste_driver_button);
        
+       WM_operatortype_append(ANIM_OT_copy_clipboard_button);
+
        
        WM_operatortype_append(ANIM_OT_add_keyingset_button);
        WM_operatortype_append(ANIM_OT_remove_keyingset_button);
index 363a5a80f00c7475629e0881dd866d6b1fbdf97e..7a4575486236bf3127b8e210b0062f7a78a5b8ee 100644 (file)
@@ -564,4 +564,48 @@ void ANIM_OT_paste_driver_button (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+
+/* Paste Driver Button Operator ------------------------ */
+
+static int copy_clipboard_button_exec(bContext *C, wmOperator *op)
+{
+       PointerRNA ptr;
+       PropertyRNA *prop= NULL;
+       char *path;
+       short success= 0;
+       int index;
+
+       /* try to create driver using property retrieved from UI */
+       memset(&ptr, 0, sizeof(PointerRNA));
+       uiAnimContextProperty(C, &ptr, &prop, &index);
+
+       if (ptr.data && prop) { // && RNA_property_animateable(ptr.data, prop)
+               path= RNA_path_from_ID_to_property(&ptr, prop);
+
+               if (path) {
+                       WM_clipboard_text_set(path, FALSE);
+                       MEM_freeN(path);
+               }
+       }
+
+       /* since we're just copying, we don't really need to do anything else...*/
+       return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+}
+
+void ANIM_OT_copy_clipboard_button(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Copy Data Path";
+       ot->idname= "ANIM_OT_copy_clipboard_button";
+       ot->description= "Copy the rna data path to the clipboard.";
+
+       /* callbacks */
+       ot->exec= copy_clipboard_button_exec;
+       //op->poll= ??? // TODO: need to have some driver to be able to do this...
+
+       /* flags */
+       ot->flag= 0;
+}
+
+
 /* ************************************************** */
index 8037a609a2f09c042800a1dd2fb1320b1e14f7b6..facda32a41ef39942d99ca271b7cf537529db9cb 100644 (file)
@@ -310,6 +310,9 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
                        }
                }
 
+               uiItemS(layout);
+               uiItemBooleanO(layout, "Copy Data Path", 0, "ANIM_OT_copy_clipboard_button", "all", 1);
+
                uiPupMenuEnd(C, pup);
        }
 }