Blender V5.0
rna_animation_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "DNA_scene_types.h"
15
16#include "rna_internal.hh" /* own include */
17
18#ifdef RNA_RUNTIME
19
20# include "BKE_animsys.h"
21# include "BKE_context.hh"
22# include "BKE_nla.hh"
23# include "BKE_report.hh"
24
25# include "ANIM_keyingsets.hh"
26# include "ED_keyframing.hh"
27
28static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList *reports)
29{
30 using namespace blender::animrig;
31 /* TODO: enable access to providing a list of overrides (dsources)? */
32 const ModifyKeyReturn error = validate_keyingset(C, nullptr, ks);
33
35 return;
36 }
37
38 switch (error) {
40 BKE_report(reports, RPT_ERROR, "Invalid context for keying set");
41 break;
42
45 reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info");
46 break;
47
48 default:
49 break;
50 }
51}
52
53static float rna_AnimData_nla_tweak_strip_time_to_scene(AnimData *adt, float frame, bool invert)
54{
56}
57
58void rna_id_animdata_fix_paths_rename_all(ID *id,
59 AnimData * /*adt*/,
60 Main *bmain,
61 const char *prefix,
62 const char *oldName,
63 const char *newName)
64{
65 BKE_animdata_fix_paths_rename_all_ex(bmain, id, prefix, oldName, newName, 0, 0, true);
66}
67
68#else
69
71{
72 FunctionRNA *func;
73 // PropertyRNA *parm;
74
75 /* validate relative Keying Set (used to ensure paths are ok for context) */
76 func = RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
78 func,
79 "Refresh Keying Set to ensure that it is valid for the current context "
80 "(call before each use of one)");
82}
83
85{
86 FunctionRNA *func;
87 PropertyRNA *parm;
88
89 /* Convert between action time and scene time when tweaking a NLA strip. */
90 func = RNA_def_function(
91 srna, "nla_tweak_strip_time_to_scene", "rna_AnimData_nla_tweak_strip_time_to_scene");
93 "Convert a time value from the local time of the tweaked strip "
94 "to scene time, exactly as done by built-in key editing tools. "
95 "Returns the input time unchanged if not tweaking.");
96 parm = RNA_def_float(
97 func, "frame", 0.0, MINAFRAME, MAXFRAME, "", "Input time", MINAFRAME, MAXFRAME);
99 RNA_def_boolean(func, "invert", false, "Invert", "Convert scene time to action time");
100 parm = RNA_def_float(
101 func, "result", 0.0, MINAFRAME, MAXFRAME, "", "Converted time", MINAFRAME, MAXFRAME);
102 RNA_def_function_return(func, parm);
103
104 func = RNA_def_function(srna, "fix_paths_rename_all", "rna_id_animdata_fix_paths_rename_all");
105 RNA_def_string(func, "prefix", nullptr, MAX_IDPROP_NAME, "Prefix", "Name prefix");
106 RNA_def_string(func, "old_name", nullptr, MAX_IDPROP_NAME, "Old Name", "Old name");
107 RNA_def_string(func, "new_name", nullptr, MAX_IDPROP_NAME, "New Name", "New name");
109 func,
110 "Rename the property paths in the animation system, since properties are animated via "
111 "string paths, it's needed to keep them valid after properties has been renamed");
113}
114
115#endif
Functionality to interact with keying sets.
void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
@ NLATIME_CONVERT_MAP
Definition BKE_nla.hh:552
@ NLATIME_CONVERT_UNMAP
Definition BKE_nla.hh:549
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, eNlaTime_ConvertModes mode)
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
#define MAX_IDPROP_NAME
Definition DNA_ID.h:186
#define MINAFRAME
#define MAXFRAME
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
PropertyFlag
Definition RNA_types.hh:300
#define C
Definition RandGen.cpp:29
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
Definition invert.h:11
static void error(const char *str)
ModifyKeyReturn validate_keyingset(bContext *C, blender::Vector< PointerRNA > *sources, KeyingSet *keyingset)
void RNA_api_keyingset(StructRNA *srna)
void RNA_api_animdata(StructRNA *srna)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition DNA_ID.h:414