Keying Sets: Insert/Delete Keyframe Operator Buttons

* Insert/Delete keyframe buttons in the TimeLine work again. These now use two new operators which only insert keyframes for the active Keying Set. 
* Renamed the old insert/delete keyframe operators. These now have the "*_old" postfix on their names. What happens with these temp operators is yet to be seen.
* Added insert/delete keyframe buttons beside the operator buttons for Keying Sets in the Outliner->Datablocks view
This commit is contained in:
Joshua Leung
2009-02-13 09:46:08 +00:00
parent c8f04eba48
commit 8817fb93c4
6 changed files with 151 additions and 19 deletions

View File

@@ -380,6 +380,8 @@ void ED_operatortypes_anim(void)
// XXX this is used all over... maybe for screen instead?
WM_operatortype_append(ANIM_OT_insert_keyframe);
WM_operatortype_append(ANIM_OT_delete_keyframe);
WM_operatortype_append(ANIM_OT_insert_keyframe_old);
WM_operatortype_append(ANIM_OT_delete_keyframe_old);
}
void ED_keymap_anim(wmWindowManager *wm)

View File

@@ -2006,7 +2006,7 @@ void common_modifykey (bContext *C, short mode)
static int commonkey_modifykey (ListBase *dsources, KeyingSet *ks, short mode, float cfra)
{
KS_Path *ksp;
int kflag, success= 0;
int kflag=0, success= 0;
char *groupname= NULL;
/* get flags to use */
@@ -2087,6 +2087,121 @@ static int commonkey_modifykey (ListBase *dsources, KeyingSet *ks, short mode, f
/* Insert Key Operator ------------------------ */
/* NOTE:
* This is one of the 'simpler new-style' Insert Keyframe operators which relies on Keying Sets.
* For now, these are absolute Keying Sets only, so there is very little context info involved.
*
* -- Joshua Leung, Feb 2009
*/
static int insert_key_exec (bContext *C, wmOperator *op)
{
ListBase dsources = {NULL, NULL};
Scene *scene= CTX_data_scene(C);
KeyingSet *ks= NULL;
float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
short success;
/* try to get KeyingSet */
if (scene->active_keyingset > 0)
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
/* report failure */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
return OPERATOR_CANCELLED;
}
/* try to insert keyframes for the channels specified by KeyingSet */
success= commonkey_modifykey(&dsources, ks, COMMONKEY_MODE_INSERT, cfra);
printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
/* report failure? */
if (success == 0)
BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
/* send updates */
ED_anim_dag_flush_update(C);
/* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, ND_KEYS, NULL);
return OPERATOR_FINISHED;
}
void ANIM_OT_insert_keyframe (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Insert Keyframe";
ot->idname= "ANIM_OT_insert_keyframe";
/* callbacks */
ot->exec= insert_key_exec;
ot->poll= ED_operator_areaactive;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* Delete Key Operator ------------------------ */
/* NOTE:
* This is one of the 'simpler new-style' Insert Keyframe operators which relies on Keying Sets.
* For now, these are absolute Keying Sets only, so there is very little context info involved.
*
* -- Joshua Leung, Feb 2009
*/
static int delete_key_exec (bContext *C, wmOperator *op)
{
ListBase dsources = {NULL, NULL};
Scene *scene= CTX_data_scene(C);
KeyingSet *ks= NULL;
float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
short success;
/* try to get KeyingSet */
if (scene->active_keyingset > 0)
ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
/* report failure */
if (ks == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
return OPERATOR_CANCELLED;
}
/* try to insert keyframes for the channels specified by KeyingSet */
success= commonkey_modifykey(&dsources, ks, COMMONKEY_MODE_DELETE, cfra);
printf("KeyingSet '%s' - Successfully removed %d Keyframes \n", ks->name, success);
/* report failure? */
if (success == 0)
BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
/* send updates */
ED_anim_dag_flush_update(C);
/* for now, only send ND_KEYS for KeyingSets */
WM_event_add_notifier(C, ND_KEYS, NULL);
return OPERATOR_FINISHED;
}
void ANIM_OT_delete_keyframe (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Keyframe";
ot->idname= "ANIM_OT_delete_keyframe";
/* callbacks */
ot->exec= delete_key_exec;
ot->poll= ED_operator_areaactive;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* Insert Key Operator ------------------------ */
/* XXX WARNING:
* This is currently just a basic operator, which work in 3d-view context on objects/bones only
* and will insert keyframes for a few settings only. This is until it becomes clear how
@@ -2109,7 +2224,7 @@ EnumPropertyItem prop_insertkey_types[] = {
{0, NULL, NULL, NULL}
};
static int insert_key_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int insert_key_old_invoke (bContext *C, wmOperator *op, wmEvent *event)
{
Object *ob= CTX_data_active_object(C);
uiMenuItem *head;
@@ -2142,7 +2257,7 @@ static int insert_key_invoke (bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
}
static int insert_key_exec (bContext *C, wmOperator *op)
static int insert_key_old_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
short mode= RNA_enum_get(op->ptr, "type");
@@ -2271,17 +2386,17 @@ static int insert_key_exec (bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void ANIM_OT_insert_keyframe (wmOperatorType *ot)
void ANIM_OT_insert_keyframe_old (wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Insert Keyframe";
ot->idname= "ANIM_OT_insert_keyframe";
ot->idname= "ANIM_OT_insert_keyframe_old";
/* callbacks */
ot->invoke= insert_key_invoke;
ot->exec= insert_key_exec;
ot->invoke= insert_key_old_invoke;
ot->exec= insert_key_old_exec;
ot->poll= ED_operator_areaactive;
/* flags */
@@ -2300,7 +2415,7 @@ void ANIM_OT_insert_keyframe (wmOperatorType *ot)
* -- Joshua Leung, Jan 2009
*/
static int delete_key_exec (bContext *C, wmOperator *op)
static int delete_key_old_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
@@ -2339,15 +2454,15 @@ static int delete_key_exec (bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void ANIM_OT_delete_keyframe (wmOperatorType *ot)
void ANIM_OT_delete_keyframe_old (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete Keyframe";
ot->idname= "ANIM_OT_delete_keyframe";
ot->idname= "ANIM_OT_delete_keyframe_old";
/* callbacks */
ot->invoke= WM_operator_confirm; // XXX we will need our own one eventually, to cope with the dynamic menus...
ot->exec= delete_key_exec;
ot->exec= delete_key_old_exec;
ot->poll= ED_operator_areaactive;

View File

@@ -70,12 +70,19 @@ short deletekey(struct ID *id, const char group[], const char rna_path[], int ar
char *ANIM_build_keyingsets_menu(struct ListBase *list, short for_edit);
/* Main Keyframe Management operators:
* These handle keyframes management from various spaces. They will handle the menus
* required for each space.
* These handle keyframes management from various spaces. They only make use of
* Keying Sets.
*/
void ANIM_OT_insert_keyframe(struct wmOperatorType *ot);
void ANIM_OT_delete_keyframe(struct wmOperatorType *ot);
/* Main Keyframe Management operators (legacy style):
* These handle keyframes management from various spaces. They will handle the menus
* required for each space.
*/
void ANIM_OT_insert_keyframe_old(struct wmOperatorType *ot);
void ANIM_OT_delete_keyframe_old(struct wmOperatorType *ot);
/* ************ Auto-Keyframing ********************** */
/* Notes:
* - All the defines for this (User-Pref settings and Per-Scene settings)

View File

@@ -133,8 +133,8 @@ void ED_keymap_object(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "OBJECT_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe_old", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_old", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_group_create", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_group_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);

View File

@@ -291,6 +291,16 @@ void outliner_header_buttons(const bContext *C, ARegion *ar)
uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_add_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, xco,yco,XIC,YIC, "Add selected properties to active Keying Set (K)");
xco += XIC;
uiBlockEndAlign(block);
xco += 10;
/* operator buttons to insert/delete keyframes for the active set */
uiBlockBeginAlign(block);
uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
xco+= XIC;
uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
xco+= XIC;
uiBlockEndAlign(block);
}
xco += XIC*2;

View File

@@ -550,11 +550,9 @@ void time_header_buttons(const bContext *C, ARegion *ar)
MEM_freeN(menustr);
xco+= (6*XIC);
uiDefIconBut(block, BUT, B_TL_DELETEKEY, ICON_KEY_DEHLT,
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Delete Keyframe for the context of the largest area (ALTKEY-IKEY)");
uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
xco+= XIC+4;
uiDefIconBut(block, BUT, B_TL_INSERTKEY, ICON_KEY_HLT,
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Insert Keyframe for the context of the largest area (IKEY)");
uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
xco+= XIC+4;
xco+= 16;