Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_ops.c
| Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | if (path) { | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int copy_as_driver_button_exec(bContext *C, wmOperator *UNUSED(op)) | static int copy_as_driver_button_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| int index; | int index; | ||||
| /* try to create driver using property retrieved from UI */ | /* try to create driver using property retrieved from UI */ | ||||
| UI_context_active_but_prop_get(C, &ptr, &prop, &index); | UI_context_active_but_prop_get(C, &ptr, &prop, &index); | ||||
| if (ptr.id.data && ptr.data && prop) { | if (ptr.id.data && ptr.data && prop) { | ||||
| int dim = RNA_property_array_dimension(&ptr, prop, NULL); | ID *id; | ||||
| char *path = RNA_path_from_ID_to_property_index(&ptr, prop, dim, index); | char *path; | ||||
| if (path) { | if (ANIM_get_target_ID_and_path_to_property(bmain, &ptr, prop, index, &id, &path)) { | ||||
| ANIM_copy_as_driver(ptr.id.data, path, RNA_property_identifier(prop)); | ANIM_copy_as_driver(id, path, RNA_property_identifier(prop)); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| else { | |||||
| BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path"); | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| static void UI_OT_copy_as_driver_button(wmOperatorType *ot) | static void UI_OT_copy_as_driver_button(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 1,514 Lines • Show Last 20 Lines | |||||