42#include "RNA_prototypes.hh"
52 const char rna_path[],
53 const int array_index,
60 if (
ELEM(
nullptr,
id, rna_path)) {
93 const int array_index,
132 const char dst_path[],
135 const char src_path[],
154 driver->
type = driver_type;
193 if (
ELEM(src_ptr->
type, &RNA_Object, &RNA_PoseBone) &&
194 (
STREQ(prop_name,
"location") ||
STREQ(prop_name,
"scale") ||
208 if (src_ptr->
type == &RNA_PoseBone) {
213 if (
STREQ(prop_name,
"location")) {
214 if (src_index == 2) {
217 else if (src_index == 1) {
224 else if (
STREQ(prop_name,
"scale")) {
225 if (src_index == 2) {
228 else if (src_index == 1) {
239 if (src_index == 2) {
242 else if (src_index == 1) {
269 return (fcu !=
nullptr);
274 const char dst_path[],
277 const char src_path[],
296 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
312 switch (mapping_type) {
319 int len = std::min(dst_len, src_len);
321 for (
int i = 0;
i <
len;
i++) {
342 for (
int i = 0;
i <
len;
i++) {
384 ReportList *reports,
ID *
id,
const char rna_path[],
int array_index,
short flag,
int type)
398 "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
405 if (array_index == -1) {
410 array_index_max = array_index;
414 if (array_index == array_index_max) {
415 array_index_max += 1;
419 for (; array_index < array_index_max; array_index++) {
444 const size_t expression_maxncpy =
sizeof(driver->
expression);
457 expression, expression_maxncpy,
"%s%s", dvar_prefix, (val) ?
"True" :
"False");
498 done_tot += (fcu !=
nullptr);
512 if (array_index >= 0) {
525 bool any_driver_removed =
false;
530 fcu_iter = fcu->
next;
535 any_driver_removed =
true;
537 return any_driver_removed;
563 ReportList *reports,
ID *
id,
const char rna_path[],
int array_index,
short )
574 "Could not find driver to copy, as RNA path is invalid for the given ID (ID = %s, "
611 ReportList *reports,
ID *
id,
const char rna_path[],
int array_index,
short )
623 "Could not paste driver, as RNA path is invalid for the given ID (ID = %s, path = %s)",
658 return (fcu !=
nullptr);
715 ListBase tmp_list = {
nullptr,
nullptr};
782 target->
id = target_id;
790 for (
int i = 0; var->
name[
i];
i++) {
791 if (!(
i > 0 ? isalnum(var->
name[
i]) : isalpha(var->
name[
i]))) {
816 "Drive all components of this property using the target picked"},
820 "Single from Target",
821 "Drive this component of this property using the target picked"},
827 "Create drivers for each pair of corresponding elements"},
832 "Manually Create Later",
833 "Create drivers for all properties without assigning any targets yet"},
837 "Manually Create Later (Single)",
838 "Create driver for this property only and without assigning any targets yet"},
839 {0,
nullptr, 0,
nullptr,
nullptr},
866 while (
input->identifier) {
891 bool driven, special;
896 if (!(
ptr.owner_id &&
ptr.data && prop)) {
905 C, &
ptr, prop, index,
nullptr,
nullptr, &driven, &special);
906 return (fcu ==
nullptr || fcu->
driver);
985 ot->name =
"Add Driver Menu";
986 ot->idname =
"ANIM_OT_driver_button_add_menu";
987 ot->description =
"Add driver(s) for the property(s) represented by the highlighted button";
1003 "Method used to match target and driven properties");
1022 bool changed =
false;
1049 ot->name =
"Add Driver";
1050 ot->idname =
"ANIM_OT_driver_button_add";
1051 ot->description =
"Add driver for the property under the cursor";
1068 bool changed =
false;
1078 if (
ptr.owner_id &&
ptr.data && prop) {
1098 ot->name =
"Remove Driver";
1099 ot->idname =
"ANIM_OT_driver_button_remove";
1101 "Remove the driver(s) for the connected property(s) represented by the highlighted button";
1111 RNA_def_boolean(
ot->srna,
"all",
true,
"All",
"Delete drivers for all elements of the array");
1124 if (
ptr.owner_id &&
ptr.data && prop) {
1134 ot->name =
"Edit Driver";
1135 ot->idname =
"ANIM_OT_driver_button_edit";
1137 "Edit the drivers for the connected property represented by the highlighted button";
1153 bool changed =
false;
1174 ot->name =
"Copy Driver";
1175 ot->idname =
"ANIM_OT_copy_driver_button";
1176 ot->description =
"Copy the driver for the highlighted button";
1192 bool changed =
false;
1219 ot->name =
"Paste Driver";
1220 ot->idname =
"ANIM_OT_paste_driver_button";
1221 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)
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)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
#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
@ FCURVE_EXTRAPOLATE_LINEAR
@ 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
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()
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, int driver_type)
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 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)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
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, blender::wm::OpCallContext 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, blender::wm::OpCallContext opcontext)