Code Cleanup: Simplified insert_keyframe_button and delete_keyframe_button
As a followup for the previous commit, do the same thing for the insert/delete keyframe button operators as is done for the clear keyframes op. There really isn't much need/reason for conducting the looping there, as those functions natively handle this themselves already.
This commit is contained in:
parent
7369c4f4d5
commit
04b23af02d
|
@ -1696,7 +1696,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
|||
char *path;
|
||||
float cfra = (float)CFRA;
|
||||
short success = 0;
|
||||
int a, index, length;
|
||||
int index;
|
||||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
short flag = 0;
|
||||
|
||||
|
@ -1715,7 +1715,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
|||
NlaStrip *strip = (NlaStrip *)ptr.data;
|
||||
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag);
|
||||
|
||||
success += insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0);
|
||||
success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0);
|
||||
}
|
||||
else {
|
||||
/* standard properties */
|
||||
|
@ -1723,16 +1723,11 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (path) {
|
||||
if (all) {
|
||||
length = RNA_property_array_length(&ptr, prop);
|
||||
|
||||
if (length) index = 0;
|
||||
else length = 1;
|
||||
/* -1 indicates operating on the entire array (or the property itself otherwise) */
|
||||
index = -1;
|
||||
}
|
||||
else
|
||||
length = 1;
|
||||
|
||||
for (a = 0; a < length; a++)
|
||||
success += insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, flag);
|
||||
success = insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, flag);
|
||||
|
||||
MEM_freeN(path);
|
||||
}
|
||||
|
@ -1795,7 +1790,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
|||
char *path;
|
||||
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
|
||||
short success = 0;
|
||||
int a, index, length;
|
||||
int index;
|
||||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
|
||||
/* try to insert keyframe using property retrieved from UI */
|
||||
|
@ -1806,17 +1801,11 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (path) {
|
||||
if (all) {
|
||||
length = RNA_property_array_length(&ptr, prop);
|
||||
|
||||
if (length) index = 0;
|
||||
else length = 1;
|
||||
/* -1 indicates operating on the entire array (or the property itself otherwise) */
|
||||
index = -1;
|
||||
}
|
||||
else
|
||||
length = 1;
|
||||
|
||||
for (a = 0; a < length; a++)
|
||||
success += delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, 0);
|
||||
|
||||
success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
|
||||
MEM_freeN(path);
|
||||
}
|
||||
else if (G.debug & G_DEBUG)
|
||||
|
|
Loading…
Reference in New Issue