change rna function action.fcurves.add() so options an enum flag rather then booleans.

(rna flags were not available when this was originally written)
 action.fcurves.add(frame, val, 1,1,1) --> .add(frame, val, {'REPLACE', 'NEEDED', 'FAST'})
This commit is contained in:
Campbell Barton 2011-01-11 04:52:17 +00:00
parent 1b9c56c423
commit 94f1e8df79

@ -546,17 +546,9 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
*max= MAXFRAMEF;
}
static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int do_replace, int do_needed, int do_fast)
static BezTriple *rna_FKeyframe_points_add(FCurve *fcu, float frame, float value, int flag)
{
int index;
int flag= 0;
if(do_replace) flag |= INSERTKEY_REPLACE;
if(do_needed) flag |= INSERTKEY_NEEDED;
if(do_fast) flag |= INSERTKEY_FAST;
index= insert_vert_fcurve(fcu, frame, value, flag);
int index= insert_vert_fcurve(fcu, frame, value, flag);
return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
}
@ -1323,6 +1315,12 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
FunctionRNA *func;
PropertyRNA *parm;
static EnumPropertyItem keyframe_flag_items[] = {
{INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
{INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
{INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
{0, NULL, 0, NULL, NULL}};
RNA_def_property_srna(cprop, "FCurveKeyframePoints");
srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
RNA_def_struct_sdna(srna, "FCurve");
@ -1334,10 +1332,9 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);
/* optional */
RNA_def_boolean(func, "replace", 0, "Replace", "Don't add any new keyframes, but just replace existing ones");
RNA_def_boolean(func, "needed", 0, "Needed", "Only adds keyframes that are needed");
RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time");
parm= RNA_def_enum(func, "options", keyframe_flag_items, 0, "", "Keyframe options.");
RNA_def_property_flag(parm, PROP_ENUM_FLAG);
parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
RNA_def_function_return(func, parm);