41#include "RNA_prototypes.hh"
51 const char rna_path[],
52 const int array_index,
59 if (
ELEM(
nullptr,
id, rna_path)) {
92 const int array_index,
141 const char dst_path[],
144 const char src_path[],
166 driver->
type = driver_type;
205 if (
ELEM(src_ptr->
type, &RNA_Object, &RNA_PoseBone) &&
206 (
STREQ(prop_name,
"location") ||
STREQ(prop_name,
"scale") ||
220 if (src_ptr->
type == &RNA_PoseBone) {
225 if (
STREQ(prop_name,
"location")) {
226 if (src_index == 2) {
229 else if (src_index == 1) {
236 else if (
STREQ(prop_name,
"scale")) {
237 if (src_index == 2) {
240 else if (src_index == 1) {
251 if (src_index == 2) {
254 else if (src_index == 1) {
281 return (fcu !=
nullptr);
286 const char dst_path[],
289 const char src_path[],
308 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
324 switch (mapping_type) {
331 int len = std::min(dst_len, src_len);
333 for (
int i = 0;
i <
len;
i++) {
355 for (
int i = 0;
i <
len;
i++) {
413 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
420 if (array_index == -1) {
425 array_index_max = array_index;
429 if (array_index == array_index_max) {
430 array_index_max += 1;
434 for (; array_index < array_index_max; array_index++) {
461 const size_t expression_maxncpy =
sizeof(driver->
expression);
474 expression, expression_maxncpy,
"%s%s", dvar_prefix, (val) ?
"True" :
"False");
484 BLI_snprintf(expression, expression_maxncpy,
"%s%d", dvar_prefix, val);
494 BLI_snprintf(expression, expression_maxncpy,
"%s%.3f", dvar_prefix, fval);
498 BLI_strncpy(expression,
"var", expression_maxncpy);
515 done_tot += (fcu !=
nullptr);
529 if (array_index >= 0) {
542 bool any_driver_removed =
false;
547 fcu_iter = fcu->
next;
552 any_driver_removed =
true;
554 return any_driver_removed;
591 "Could not find driver to copy, as RNA path is invalid for the given ID (ID = %s, "
640 "Could not paste driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
675 return (fcu !=
nullptr);
732 ListBase tmp_list = {
nullptr,
nullptr};
799 target->
id = target_id;
807 for (
int i = 0; var->
name[
i];
i++) {
808 if (!(
i > 0 ? isalnum(var->
name[
i]) : isalpha(var->
name[
i]))) {
833 "Drive all components of this property using the target picked"},
837 "Single from Target",
838 "Drive this component of this property using the target picked"},
844 "Create drivers for each pair of corresponding elements"},
849 "Manually Create Later",
850 "Create drivers for all properties without assigning any targets yet"},
854 "Manually Create Later (Single)",
855 "Create driver for this property only and without assigning any targets yet"},
856 {0,
nullptr, 0,
nullptr,
nullptr},
883 while (
input->identifier) {
908 bool driven, special;
913 if (!(
ptr.owner_id &&
ptr.data && prop)) {
922 C, &
ptr, prop, index,
nullptr,
nullptr, &driven, &special);
923 return (fcu ==
nullptr || fcu->
driver);
1002 ot->name =
"Add Driver Menu";
1003 ot->idname =
"ANIM_OT_driver_button_add_menu";
1004 ot->description =
"Add driver(s) for the property(s) represented by the highlighted button";
1020 "Method used to match target and driven properties");
1039 bool changed =
false;
1066 ot->name =
"Add Driver";
1067 ot->idname =
"ANIM_OT_driver_button_add";
1068 ot->description =
"Add driver for the property under the cursor";
1085 bool changed =
false;
1095 if (
ptr.owner_id &&
ptr.data && prop) {
1115 ot->name =
"Remove Driver";
1116 ot->idname =
"ANIM_OT_driver_button_remove";
1118 "Remove the driver(s) for the connected property(s) represented by the highlighted button";
1128 RNA_def_boolean(
ot->srna,
"all",
true,
"All",
"Delete drivers for all elements of the array");
1141 if (
ptr.owner_id &&
ptr.data && prop) {
1151 ot->name =
"Edit Driver";
1152 ot->idname =
"ANIM_OT_driver_button_edit";
1154 "Edit the drivers for the connected property represented by the highlighted button";
1170 bool changed =
false;
1191 ot->name =
"Copy Driver";
1192 ot->idname =
"ANIM_OT_copy_driver_button";
1193 ot->description =
"Copy the driver for the highlighted button";
1209 bool changed =
false;
1236 ot->name =
"Paste Driver";
1237 ot->idname =
"ANIM_OT_paste_driver_button";
1238 ot->description =
"Paste the driver in the internal clipboard to the highlighted button";
Functions to modify FCurves.
AnimData * BKE_animdata_ensure_id(ID *id)
AnimData * BKE_animdata_from_id(const ID *id)
Main * CTX_data_main(const bContext *C)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
FCurve * BKE_fcurve_create()
void copy_fmodifiers(ListBase *dst, const ListBase *src)
void BKE_fcurve_handles_recalc(FCurve *fcu)
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
FCurve * BKE_fcurve_find_by_rna_context_ui(bContext *C, const PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_animdata, bAction **r_action, bool *r_driven, bool *r_special)
FCurve * BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[])
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
void BKE_fcurve_free(FCurve *fcu)
struct DriverVar * driver_add_new_variable(struct ChannelDriver *driver)
struct ChannelDriver * fcurve_copy_driver(const struct ChannelDriver *driver)
void BKE_driver_invalidate_expression(struct ChannelDriver *driver, bool expr_changed, bool varname_changed)
void driver_variables_copy(struct ListBase *dst_vars, const struct ListBase *src_vars)
void driver_free_variable_ex(struct ChannelDriver *driver, struct DriverVar *dvar)
void driver_free_variable(struct ListBase *variables, struct DriverVar *dvar)
void driver_change_variable_type(struct DriverVar *dvar, int type)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(1)
char * STRNCPY(char(&dst)[N], const char *src)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define UNUSED_FUNCTION(x)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ DVAR_TYPE_TRANSFORM_CHAN
@ FMODIFIER_TYPE_GENERATOR
@ FCURVE_EXTRAPOLATE_LINEAR
@ CREATEDRIVER_WITH_FMODIFIER
@ CREATEDRIVER_WITH_DEFAULT_DVAR
@ CREATEDRIVER_MAPPING_NONE_ALL
@ CREATEDRIVER_MAPPING_1_N
@ CREATEDRIVER_MAPPING_NONE
@ CREATEDRIVER_MAPPING_N_N
@ CREATEDRIVER_MAPPING_1_1
eDriverFCurveCreationMode
@ DRIVER_FCURVE_LOOKUP_ONLY
@ DRIVER_FCURVE_KEYFRAMES
@ DRIVER_FCURVE_GENERATOR
Read Guarded memory(de)allocation.
void UI_context_update_anim_flag(const bContext *C)
wmOperatorStatus UI_popover_panel_invoke(bContext *C, const char *idname, bool keep_open, ReportList *reports)
uiBut * UI_context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
bool ANIM_driver_vars_can_paste()
bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short)
Main Driver Management API calls.
void ANIM_copy_as_driver(ID *target_id, const char *target_path, const char *var_name)
static wmOperatorStatus add_driver_button_menu_exec(bContext *C, wmOperator *op)
void ANIM_OT_driver_button_remove(wmOperatorType *ot)
void ANIM_OT_driver_button_add(wmOperatorType *ot)
void ANIM_OT_driver_button_edit(wmOperatorType *ot)
bool ANIM_driver_can_paste()
static bool add_driver_button_poll(bContext *C)
FCurve * alloc_driver_fcurve(const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
static wmOperatorStatus add_driver_button_none(bContext *C, wmOperator *op, short mapping_type)
static int add_driver_with_target(ReportList *, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, PointerRNA *dst_ptr, PropertyRNA *dst_prop, PointerRNA *src_ptr, PropertyRNA *src_prop, short flag, int driver_type)
static wmOperatorStatus add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu)
static wmOperatorStatus add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus copy_driver_button_exec(bContext *C, wmOperator *op)
int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
Main Driver Management API calls.
int ANIM_add_driver_with_target(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)
Main Driver Management API calls.
bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace)
FCurve * verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
static wmOperatorStatus paste_driver_button_exec(bContext *C, wmOperator *op)
void ANIM_OT_paste_driver_button(wmOperatorType *ot)
void ANIM_drivers_copybuf_free()
void ANIM_OT_copy_driver_button(wmOperatorType *ot)
const EnumPropertyItem prop_driver_create_mapping_types[]
static ListBase driver_vars_copybuf
void ANIM_driver_vars_copybuf_free()
static void UNUSED_FUNCTION ANIM_OT_driver_button_add_menu(wmOperatorType *ot)
bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short)
Main Driver Management API calls.
static const EnumPropertyItem * driver_mapping_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static wmOperatorStatus edit_driver_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus remove_driver_button_exec(bContext *C, wmOperator *op)
bool ANIM_remove_driver(ID *id, const char rna_path[], int array_index)
Main Driver Management API calls.
static FCurve * channeldriver_copypaste_buf
bool all(VecOp< bool, D >) RET
void * MEM_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_array_check(PropertyRNA *prop)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PropertyUnit RNA_property_unit(PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
bool RNA_property_driver_editable(const PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const char * RNA_property_identifier(const PropertyRNA *prop)
PointerRNA RNA_id_pointer_create(ID *id)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
struct ReportList * reports
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
wmOperatorStatus WM_menu_invoke_ex(bContext *C, wmOperator *op, wmOperatorCallContext opcontext)