Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_ops.c
| Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | if (ptr.id.data && ptr.data && prop) { | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int copy_data_path_button_exec(bContext *C, wmOperator *op) | static int copy_data_path_button_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | |||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| char *path; | char *path; | ||||
| int index; | int index; | ||||
| ID *id; | |||||
| const bool full_path = RNA_boolean_get(op->ptr, "full_path"); | const bool full_path = RNA_boolean_get(op->ptr, "full_path"); | ||||
| /* 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 != NULL) { | if (ptr.id.data != NULL) { | ||||
| if (full_path) { | if (full_path) { | ||||
| if (prop) { | if (prop) { | ||||
| path = RNA_path_full_property_py_ex(&ptr, prop, index, true); | path = RNA_path_full_property_py_ex(bmain, &ptr, prop, index, true); | ||||
| } | } | ||||
| else { | else { | ||||
| path = RNA_path_full_struct_py(&ptr); | path = RNA_path_full_struct_py(bmain, &ptr); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, 0, -1, &id); | |||||
| if (!path) { | |||||
| path = RNA_path_from_ID_to_property(&ptr, prop); | path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| } | } | ||||
| } | |||||
| if (path) { | if (path) { | ||||
| WM_clipboard_text_set(path, false); | WM_clipboard_text_set(path, false); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 45 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) { | ||||
| ID *id; | |||||
| int dim = RNA_property_array_dimension(&ptr, prop, NULL); | int dim = RNA_property_array_dimension(&ptr, prop, NULL); | ||||
| char *path = RNA_path_from_ID_to_property_index(&ptr, prop, dim, index); | char *path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, dim, index, &id); | ||||
| if (path) { | if (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 | |||||