From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- source/blender/editors/animation/drivers.c | 318 ++++++++++++++--------------- 1 file changed, 159 insertions(+), 159 deletions(-) (limited to 'source/blender/editors/animation/drivers.c') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 7dae825c92f..be9875ef95a 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -29,7 +29,7 @@ * \ingroup edanimation */ - + #include #include @@ -65,7 +65,7 @@ /* ************************************************** */ /* Animation Data Validation */ -/* Get (or add relevant data to be able to do so) F-Curve from the driver stack, +/* Get (or add relevant data to be able to do so) F-Curve from the driver stack, * for the given Animation Data block. This assumes that all the destinations are valid. * * - add: 0 - don't add anything if not found, @@ -77,11 +77,11 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde { AnimData *adt; FCurve *fcu; - + /* sanity checks */ if (ELEM(NULL, id, rna_path)) return NULL; - + /* init animdata if none available yet */ adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) @@ -90,33 +90,33 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ return NULL; } - - /* try to find f-curve matching for this setting + + /* try to find f-curve matching for this setting * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ fcu = list_find_fcurve(&adt->drivers, rna_path, array_index); - + if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL; - + /* store path - make copy, and store that */ fcu->rna_path = BLI_strdup(rna_path); fcu->array_index = array_index; - + /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */ if (add > 0) { BezTriple *bezt; size_t i; - + /* add some new driver data */ fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); fcu->driver->flag |= DRIVER_FLAG_SHOWDEBUG; - + /* F-Modifier or Keyframes? */ // FIXME: replace these magic numbers with defines if (add == 2) { @@ -127,27 +127,27 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); } else { - /* add 2 keyframes so that user has something to work with + /* add 2 keyframes so that user has something to work with * - These are configured to 0,0 and 1,1 to give a 1-1 mapping * which can be easily tweaked from there. */ insert_vert_fcurve(fcu, 0.0f, 0.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); - + /* configure this curve to extrapolate */ for (i = 0, bezt = fcu->bezt; (i < fcu->totvert) && bezt; i++, bezt++) { bezt->h1 = bezt->h2 = HD_VECT; } - + fcu->extend = FCURVE_EXTRAPOLATE_LINEAR; calchandles_fcurve(fcu); } } - + /* just add F-Curve to end of driver list */ BLI_addtail(&adt->drivers, fcu); } - + /* return the F-Curve */ return fcu; } @@ -167,17 +167,17 @@ static int add_driver_with_target( FCurve *fcu; short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1; const char *prop_name = RNA_property_identifier(src_prop); - + /* Create F-Curve with Driver */ fcu = verify_driver_fcurve(dst_id, dst_path, dst_index, add_mode); - + if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + /* Set the type of the driver */ driver->type = driver_type; - + /* Set driver expression, so that the driver works out of the box * * The following checks define a bit of "autodetection magic" we use @@ -185,7 +185,7 @@ static int add_driver_with_target( * when faced with properties with different units. */ /* XXX: if we have N-1 mapping, should we include all those in the expression? */ - if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) && + if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) && (RNA_property_unit(src_prop) != PROP_UNIT_ROTATION)) { /* Rotation Destination: normal -> radians, so convert src to radians @@ -205,7 +205,7 @@ static int add_driver_with_target( /* Just a normal property without any unit problems */ BLI_strncpy(driver->expression, "var", sizeof(driver->expression)); } - + /* Create a driver variable for the target * - For transform properties, we want to automatically use "transform channel" instead * (The only issue is with quat rotations vs euler channels...) @@ -214,25 +214,25 @@ static int add_driver_with_target( * when both the source and destinations are in same places. */ dvar = driver_add_new_variable(driver); - - if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) && + + if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) && (STREQ(prop_name, "location") || STREQ(prop_name, "scale") || STRPREFIX(prop_name, "rotation_")) && (src_ptr->data != dst_ptr->data)) { /* Transform Channel */ DriverTarget *dtar; - + driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); dtar = &dvar->targets[0]; - + /* Bone or Object target? */ dtar->id = src_id; dtar->idtype = GS(src_id->name); - + if (src_ptr->type == &RNA_PoseBone) { RNA_string_get(src_ptr, "name", dtar->pchan_name); } - + /* Transform channel depends on type */ if (STREQ(prop_name, "location")) { if (src_index == 2) @@ -265,11 +265,11 @@ static int add_driver_with_target( else { /* Single RNA Property */ DriverTarget *dtar = &dvar->targets[0]; - + /* ID is as-is */ dtar->id = src_id; dtar->idtype = GS(src_id->name); - + /* Need to make a copy of the path (or build one with array index built in) */ if (RNA_property_array_check(src_prop)) { dtar->rna_path = BLI_sprintfN("%s[%d]", src_path, src_index); @@ -279,7 +279,7 @@ static int add_driver_with_target( } } } - + /* set the done status */ return (fcu != NULL); } @@ -296,35 +296,35 @@ static int add_driver_with_target( * - mapping_type: eCreateDriver_MappingTypes */ int ANIM_add_driver_with_target( - ReportList *reports, + ReportList *reports, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, short flag, int driver_type, short mapping_type) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - + PointerRNA id_ptr2, ptr2; PropertyRNA *prop2; int done_tot = 0; - + /* validate pointers first - exit if failure */ RNA_id_pointer_create(dst_id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, dst_path, &ptr, &prop) == false) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)", dst_id->name, dst_path); return 0; } - + RNA_id_pointer_create(src_id, &id_ptr2); - if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) || + if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) || (mapping_type == CREATEDRIVER_MAPPING_NONE)) { /* No target - So, fall back to default method for adding a "simple" driver normally */ return ANIM_add_driver(reports, dst_id, dst_path, dst_index, flag | CREATEDRIVER_WITH_DEFAULT_DVAR, driver_type); } - + /* handle curve-property mappings based on mapping_type */ switch (mapping_type) { case CREATEDRIVER_MAPPING_N_N: /* N-N - Try to match as much as possible, then use the first one */ @@ -332,35 +332,35 @@ int ANIM_add_driver_with_target( /* Use the shorter of the two (to avoid out of bounds access) */ int dst_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; int src_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr2, prop2) : 1; - + int len = MIN2(dst_len, src_len); int i; - + for (i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, i, &ptr, prop, &ptr2, prop2, flag, driver_type); } break; } - + case CREATEDRIVER_MAPPING_1_N: /* 1-N - Specified target index for all */ default: { int len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; int i; - + for (i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type); } break; } - + case CREATEDRIVER_MAPPING_1_1: /* 1-1 - Use the specified index (unless -1) */ { done_tot = add_driver_with_target(reports, dst_id, dst_path, dst_index, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type); break; } } - + /* done */ return done_tot; } @@ -371,22 +371,22 @@ int ANIM_add_driver_with_target( * Add a new driver for the specified property on the given ID block */ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type) -{ +{ PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; int array_index_max; int done_tot = 0; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)", id->name, rna_path); return 0; } - + /* key entire array convenience method */ if (array_index == -1) { array_index_max = RNA_property_array_length(&ptr, prop); @@ -394,25 +394,25 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra } else array_index_max = array_index; - + /* maximum index should be greater than the start index */ if (array_index == array_index_max) array_index_max += 1; - + /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1; - + /* create F-Curve with Driver */ fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode); - + if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; - + /* set the type of the driver */ driver->type = type; - - /* creating drivers for buttons will create the driver(s) with type + + /* creating drivers for buttons will create the driver(s) with type * "scripted expression" so that their values won't be lost immediately, * so here we copy those values over to the driver's expression */ @@ -422,28 +422,28 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra char *expression = driver->expression; int val, maxlen = sizeof(driver->expression); float fval; - + if (proptype == PROP_BOOLEAN) { if (!array) val = RNA_property_boolean_get(&ptr, prop); else val = RNA_property_boolean_get_index(&ptr, prop, array_index); - + BLI_strncpy(expression, (val) ? "True" : "False", maxlen); } else if (proptype == PROP_INT) { if (!array) val = RNA_property_int_get(&ptr, prop); else val = RNA_property_int_get_index(&ptr, prop, array_index); - + BLI_snprintf(expression, maxlen, "%d", val); } else if (proptype == PROP_FLOAT) { if (!array) fval = RNA_property_float_get(&ptr, prop); else fval = RNA_property_float_get_index(&ptr, prop, array_index); - + BLI_snprintf(expression, maxlen, "%.3f", fval); } } - - /* for easier setup of drivers from UI, a driver variable should be + + /* for easier setup of drivers from UI, a driver variable should be * added if flag is set (UI calls only) */ if (flag & CREATEDRIVER_WITH_DEFAULT_DVAR) { @@ -454,11 +454,11 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); } } - + /* set the done status */ done_tot += (fcu != NULL); } - + /* done */ return done_tot; } @@ -471,29 +471,29 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path AnimData *adt; FCurve *fcu; bool success = false; - + /* we don't check the validity of the path here yet, but it should be ok... */ adt = BKE_animdata_from_id(id); - + if (adt) { if (array_index == -1) { /* step through all drivers, removing all of those with the same base path */ FCurve *fcu_iter = adt->drivers.first; - + while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) { /* store the next fcurve for looping */ fcu_iter = fcu->next; - + /* remove F-Curve from driver stack, then free it */ BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); - + /* done successfully */ success = true; } } else { - /* find the matching driver and remove it only + /* find the matching driver and remove it only * Note: here is one of the places where we don't want new F-Curve + Driver added! * so 'add' var must be 0 */ @@ -501,7 +501,7 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path if (fcu) { BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); - + success = true; } } @@ -541,7 +541,7 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { @@ -550,13 +550,13 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar id->name, rna_path); return 0; } - + /* try to get F-Curve with Driver */ fcu = verify_driver_fcurve(id, rna_path, array_index, 0); - + /* clear copy/paste buffer first (for consistency with other copy/paste buffers) */ ANIM_drivers_copybuf_free(); - + /* copy this to the copy/paste buf if it exists */ if (fcu && fcu->driver) { /* make copies of some info such as the rna_path, then clear this info from the F-Curve temporarily @@ -564,17 +564,17 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar */ char *tmp_path = fcu->rna_path; fcu->rna_path = NULL; - + /* make a copy of the F-Curve with */ channeldriver_copypaste_buf = copy_fcurve(fcu); - + /* restore the path */ fcu->rna_path = tmp_path; - + /* copied... */ return 1; } - + /* done */ return 0; } @@ -584,11 +584,11 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar * with the driver + driver-curve data from the buffer */ bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) -{ +{ PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { @@ -597,35 +597,35 @@ bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int a id->name, rna_path); return 0; } - + /* if the buffer is empty, cannot paste... */ if (channeldriver_copypaste_buf == NULL) { BKE_report(reports, RPT_ERROR, "Paste driver: no driver to paste"); return 0; } - + /* create Driver F-Curve, but without data which will be copied across... */ fcu = verify_driver_fcurve(id, rna_path, array_index, -1); - + if (fcu) { - /* copy across the curve data from the buffer curve + /* copy across the curve data from the buffer curve * NOTE: this step needs care to not miss new settings */ /* keyframes/samples */ fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt); fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt); fcu->totvert = channeldriver_copypaste_buf->totvert; - + /* modifiers */ copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); - + /* extrapolation mode */ fcu->extend = channeldriver_copypaste_buf->extend; - + /* the 'juicy' stuff - the driver */ fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver); } - + /* done */ return (fcu != NULL); } @@ -642,14 +642,14 @@ void ANIM_driver_vars_copybuf_free(void) /* Free the driver variables kept in the buffer */ if (driver_vars_copybuf.first) { DriverVar *dvar, *dvarn; - + /* Free variables (and any data they use) */ for (dvar = driver_vars_copybuf.first; dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable(&driver_vars_copybuf, dvar); } } - + BLI_listbase_clear(&driver_vars_copybuf); } @@ -669,18 +669,18 @@ bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu) BKE_report(reports, RPT_ERROR, "No driver to copy variables from"); return false; } - + if (BLI_listbase_is_empty(&fcu->driver->variables)) { BKE_report(reports, RPT_ERROR, "Driver has no variables to copy"); return false; } - + /* clear buffer */ ANIM_driver_vars_copybuf_free(); - + /* copy over the variables */ driver_variables_copy(&driver_vars_copybuf, &fcu->driver->variables); - + return (BLI_listbase_is_empty(&driver_vars_copybuf) == false); } @@ -689,55 +689,55 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) { ChannelDriver *driver = (fcu) ? fcu->driver : NULL; ListBase tmp_list = {NULL, NULL}; - + /* sanity checks */ if (BLI_listbase_is_empty(&driver_vars_copybuf)) { BKE_report(reports, RPT_ERROR, "No driver variables in clipboard to paste"); return false; } - + if (ELEM(NULL, fcu, fcu->driver)) { BKE_report(reports, RPT_ERROR, "Cannot paste driver variables without a driver"); return false; } - + /* 1) Make a new copy of the variables in the buffer - these will get pasted later... */ driver_variables_copy(&tmp_list, &driver_vars_copybuf); - + /* 2) Prepare destination array */ if (replace) { DriverVar *dvar, *dvarn; - + /* Free all existing vars first - We aren't retaining anything */ for (dvar = driver->variables.first; dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable_ex(driver, dvar); } - + BLI_listbase_clear(&driver->variables); } - + /* 3) Add new vars */ if (driver->variables.last) { DriverVar *last = driver->variables.last; DriverVar *first = tmp_list.first; - + last->next = first; first->prev = last; - + driver->variables.last = tmp_list.last; } else { driver->variables.first = tmp_list.first; driver->variables.last = tmp_list.last; } - + #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif - + return true; } @@ -754,10 +754,10 @@ EnumPropertyItem prop_driver_create_mapping_types[] = { "Drive all components of this property using the target picked"}, {CREATEDRIVER_MAPPING_1_1, "DIRECT", 0, "Single from Target", "Drive this component of this property using the target picked"}, - + {CREATEDRIVER_MAPPING_N_N, "MATCH", ICON_COLOR, "Match Indices", "Create drivers for each pair of corresponding elements"}, - + {CREATEDRIVER_MAPPING_NONE_ALL, "NONE_ALL", ICON_HAND, "Manually Create Later", "Create drivers for all properties without assigning any targets yet"}, {CREATEDRIVER_MAPPING_NONE, "NONE_SINGLE", 0, "Manually Create Later (Single)", @@ -770,21 +770,21 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN { EnumPropertyItem *input = prop_driver_create_mapping_types; EnumPropertyItem *item = NULL; - + PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; int index; - + int totitem = 0; - + if (!C) /* needed for docs */ return prop_driver_create_mapping_types; - + UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { const bool is_array = RNA_property_array_check(prop); - + while (input->identifier) { if (ELEM(input->value, CREATEDRIVER_MAPPING_1_1, CREATEDRIVER_MAPPING_NONE) || (is_array)) { RNA_enum_item_add(&item, &totitem, input); @@ -796,9 +796,9 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN /* We need at least this one! */ RNA_enum_items_add_value(&item, &totitem, input, CREATEDRIVER_MAPPING_NONE); } - + RNA_enum_item_end(&item, &totitem); - + *r_free = true; return item; } @@ -811,7 +811,7 @@ static int add_driver_button_poll(bContext *C) PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; int index; - + /* this operator can only run if there's a property button active, and it can be animated */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); return (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)); @@ -824,28 +824,28 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ PropertyRNA *prop = NULL; int index; int success = 0; - + UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) index = -1; - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; - + if (path) { success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } } - + if (success) { /* send updates */ UI_context_update_anim_flag(C); DAG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX - + return OPERATOR_FINISHED; } else { @@ -863,10 +863,10 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) else { /* Create Driver using Eyedropper */ wmOperatorType *ot = WM_operatortype_find("UI_OT_eyedropper_driver", true); - + /* XXX: We assume that it's fine to use the same set of properties, since they're actually the same... */ WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr); - + return OPERATOR_FINISHED; } } @@ -875,7 +875,7 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { PropertyRNA *prop; - + if ((prop = RNA_struct_find_property(op->ptr, "mapping_type")) && RNA_property_is_set(op->ptr, prop)) { /* Mapping Type is Set - Directly go into creating drivers */ return add_driver_button_exec(C, op); @@ -894,18 +894,18 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) ot->name = "Add Driver"; ot->idname = "ANIM_OT_driver_button_add"; ot->description = "Add driver(s) for the property(s) represented by the highlighted button"; - + /* callbacks */ /* NOTE: No exec, as we need all these to use the current context info * (especially the eyedropper, which is interactive) */ ot->invoke = add_driver_button_invoke; - ot->exec = add_driver_button_exec; + ot->exec = add_driver_button_exec; ot->poll = add_driver_button_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "mapping_type", prop_driver_create_mapping_types, 0, "Mapping Type", "Method used to match target and driven properties"); @@ -921,30 +921,30 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op) short success = 0; int index; const bool all = RNA_boolean_get(op->ptr, "all"); - + /* try to find driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (all) index = -1; - + if (ptr.id.data && ptr.data && prop) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); MEM_freeN(path); } } - + if (success) { /* send updates */ UI_context_update_anim_flag(C); DAG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -954,11 +954,11 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) ot->name = "Remove Driver"; ot->idname = "ANIM_OT_driver_button_remove"; ot->description = "Remove the driver(s) for the property(s) connected represented by the highlighted button"; - + /* callbacks */ - ot->exec = remove_driver_button_exec; + ot->exec = remove_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -974,23 +974,23 @@ static int copy_driver_button_exec(bContext *C, wmOperator *op) PropertyRNA *prop = NULL; short success = 0; int index; - + /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { /* only copy the driver for the button that this was involved for */ success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); - + UI_context_update_anim_flag(C); - + MEM_freeN(path); } } - + /* since we're just copying, we don't really need to do anything else...*/ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1001,11 +1001,11 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) ot->name = "Copy Driver"; ot->idname = "ANIM_OT_copy_driver_button"; ot->description = "Copy the driver for the highlighted button"; - + /* callbacks */ - ot->exec = copy_driver_button_exec; + ot->exec = copy_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; } @@ -1018,28 +1018,28 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op) PropertyRNA *prop = NULL; short success = 0; int index; - + /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { /* only copy the driver for the button that this was involved for */ success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); - + UI_context_update_anim_flag(C); - + DAG_relations_tag_update(CTX_data_main(C)); DAG_id_tag_update(ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA); - + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX - + MEM_freeN(path); } } - + /* since we're just copying, we don't really need to do anything else...*/ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1050,11 +1050,11 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) ot->name = "Paste Driver"; ot->idname = "ANIM_OT_paste_driver_button"; ot->description = "Paste the driver in the copy/paste buffer for the highlighted button"; - + /* callbacks */ - ot->exec = paste_driver_button_exec; + ot->exec = paste_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; } -- cgit v1.2.3