Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/drivers.c
| Show First 20 Lines • Show All 955 Lines • ▼ Show 20 Lines | static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_type) | ||||
| UI_context_active_but_prop_get(C, &ptr, &prop, &index); | UI_context_active_but_prop_get(C, &ptr, &prop, &index); | ||||
| if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) { | if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) { | ||||
| index = -1; | index = -1; | ||||
| } | } | ||||
| if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | ||||
| char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); | char *path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; | short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; | ||||
| if (path) { | if (path) { | ||||
| success += ANIM_add_driver( | success += ANIM_add_driver( | ||||
| op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON); | op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| int index; | int index; | ||||
| /* try to find driver using property retrieved from UI */ | /* try to find 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.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | ||||
| /* 1) Create a new "empty" driver for this property */ | /* 1) Create a new "empty" driver for this property */ | ||||
| char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); | char *path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; | short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; | ||||
| bool changed = false; | bool changed = false; | ||||
| if (path) { | if (path) { | ||||
| changed |= (ANIM_add_driver( | changed |= (ANIM_add_driver( | ||||
| op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON) != 0); | op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON) != 0); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static int remove_driver_button_exec(bContext *C, wmOperator *op) | ||||
| /* try to find driver using property retrieved from UI */ | /* try to find 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 (all) { | if (all) { | ||||
| index = -1; | index = -1; | ||||
| } | } | ||||
| if (ptr.owner_id && ptr.data && prop) { | if (ptr.owner_id && ptr.data && prop) { | ||||
| char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); | char *path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| if (path) { | if (path) { | ||||
| changed = ANIM_remove_driver(op->reports, ptr.owner_id, path, index, 0); | changed = ANIM_remove_driver(op->reports, ptr.owner_id, path, index, 0); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static int copy_driver_button_exec(bContext *C, wmOperator *op) | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| bool changed = false; | bool changed = false; | ||||
| 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.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | ||||
| char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); | char *path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| if (path) { | if (path) { | ||||
| /* only copy the driver for the button that this was involved for */ | /* only copy the driver for the button that this was involved for */ | ||||
| changed = ANIM_copy_driver(op->reports, ptr.owner_id, path, index, 0); | changed = ANIM_copy_driver(op->reports, ptr.owner_id, path, index, 0); | ||||
| UI_context_update_anim_flag(C); | UI_context_update_anim_flag(C); | ||||
| MEM_freeN(path); | MEM_freeN(path); | ||||
| Show All 27 Lines | static int paste_driver_button_exec(bContext *C, wmOperator *op) | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| bool changed = false; | bool changed = false; | ||||
| 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.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { | ||||
| char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); | char *path = RNA_path_from_ID_to_property(&ptr, prop); | ||||
| if (path) { | if (path) { | ||||
| /* only copy the driver for the button that this was involved for */ | /* only copy the driver for the button that this was involved for */ | ||||
| changed = ANIM_paste_driver(op->reports, ptr.owner_id, path, index, 0); | changed = ANIM_paste_driver(op->reports, ptr.owner_id, path, index, 0); | ||||
| UI_context_update_anim_flag(C); | UI_context_update_anim_flag(C); | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| Show All 29 Lines | |||||