diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-06-09 16:28:49 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-06-09 16:28:49 +0400 |
commit | abdb8fd94d90a1b9fb262c94dac1ccb52cfee36f (patch) | |
tree | fb7d82ed5c30c25e2ce07945b1938872ad96f96f /source/blender | |
parent | ca5ff43b1f3efa555b1e52d190c5a97332e01e85 (diff) |
NLA SoC: Added simple delete-strips operator (XKEY/DELKEY)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 63 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_ops.c | 6 |
3 files changed, 73 insertions, 1 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 49d43f29c5f..ce62d36e667 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -68,7 +68,7 @@ #include "nla_intern.h" // own include /* *********************************************** */ -/* General Editing */ +/* 'Special' Editing */ /* ******************** Tweak-Mode Operators ***************************** */ /* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited @@ -211,5 +211,66 @@ void NLAEDIT_OT_tweakmode_exit (wmOperatorType *ot) } /* *********************************************** */ +/* NLA Editing Operations */ + +/* ******************** Delete Operator ***************************** */ +/* Deletes the selected NLA-Strips */ + +static int nlaedit_delete_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* get a list of the AnimData blocks being shown in the NLA */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each NLA-Track, delete all selected strips */ + // FIXME: need to double-check that we've got tracks + for (ale= anim_data.first; ale; ale= ale->next) { + NlaTrack *nlt= (NlaTrack *)ale->data; + NlaStrip *strip, *nstrip; + + for (strip= nlt->strips.first; strip; strip= nstrip) { + nstrip= strip->next; + + /* if selected, delete */ + if (strip->flag & NLASTRIP_FLAG_SELECT) + free_nlastrip(&nlt->strips, strip); + } + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* set notifier that things have changed */ + ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH); + WM_event_add_notifier(C, NC_SCENE, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLAEDIT_OT_delete (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Strips"; + ot->idname= "NLAEDIT_OT_delete"; + ot->description= "Delete selected strips."; + + /* api callbacks */ + ot->exec= nlaedit_delete_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 00de0498e4b..abbb7331e28 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -89,6 +89,11 @@ void NLAEDIT_OT_click_select(wmOperatorType *ot); void NLAEDIT_OT_tweakmode_enter(wmOperatorType *ot); void NLAEDIT_OT_tweakmode_exit(wmOperatorType *ot); +/* --- */ + +void NLAEDIT_OT_delete(wmOperatorType *ot); + + /* **************************************** */ /* nla_channels.c */ diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 6505b1deea3..3eb32d147f5 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -131,6 +131,8 @@ void nla_operatortypes(void) /* edit */ WM_operatortype_append(NLAEDIT_OT_tweakmode_enter); WM_operatortype_append(NLAEDIT_OT_tweakmode_exit); + + WM_operatortype_append(NLAEDIT_OT_delete); } /* ************************** registration - keymaps **********************************/ @@ -191,6 +193,10 @@ static void nla_keymap_main (wmWindowManager *wm, ListBase *keymap) */ WM_keymap_add_item(keymap, "NLAEDIT_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLAEDIT_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); + + /* delete */ + WM_keymap_add_item(keymap, "NLAEDIT_OT_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NLAEDIT_OT_delete", DELKEY, KM_PRESS, 0, 0); /* transform system */ transform_keymap_for_space(wm, keymap, SPACE_NLA); |