NLA SoC: Toggle muting operator - HKEY
This operator provides a quick way of toggling the muted-status of several strips at the same time.
This commit is contained in:
@@ -857,6 +857,66 @@ void NLA_OT_split (wmOperatorType *ot)
|
||||
/* *********************************************** */
|
||||
/* NLA Editing Operations (Modifying) */
|
||||
|
||||
/* ******************** Toggle Muting Operator ************************** */
|
||||
/* Toggles whether strips are muted or not */
|
||||
|
||||
static int nlaedit_toggle_mute_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 editable tracks being shown in the NLA */
|
||||
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* go over all selected strips */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
NlaTrack *nlt= (NlaTrack *)ale->data;
|
||||
NlaStrip *strip;
|
||||
|
||||
/* for every selected strip, toggle muting */
|
||||
for (strip= nlt->strips.first; strip; strip= strip->next) {
|
||||
if (strip->flag & NLASTRIP_FLAG_SELECT) {
|
||||
/* just flip the mute flag for now */
|
||||
// TODO: have a pre-pass to check if mute all or unmute all?
|
||||
strip->flag ^= NLASTRIP_FLAG_MUTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 NLA_OT_mute_toggle (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Toggle Muting";
|
||||
ot->idname= "NLA_OT_mute_toggle";
|
||||
ot->description= "Mute or un-muted selected strips.";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= nlaedit_toggle_mute_exec;
|
||||
ot->poll= nlaop_poll_tweakmode_off;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************** Move Strips Up Operator ************************** */
|
||||
/* Tries to move the selected strips into the track above if possible. */
|
||||
|
||||
|
||||
@@ -168,6 +168,10 @@ static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemO(layout, NULL, 0, "NLA_OT_mute_toggle");
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemO(layout, NULL, 0, "NLA_OT_apply_scale");
|
||||
uiItemO(layout, NULL, 0, "NLA_OT_clear_scale");
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ void NLA_OT_duplicate(wmOperatorType *ot);
|
||||
void NLA_OT_delete(wmOperatorType *ot);
|
||||
void NLA_OT_split(wmOperatorType *ot);
|
||||
|
||||
void NLA_OT_mute_toggle(wmOperatorType *ot);
|
||||
|
||||
void NLA_OT_move_up(wmOperatorType *ot);
|
||||
void NLA_OT_move_down(wmOperatorType *ot);
|
||||
|
||||
|
||||
@@ -153,6 +153,8 @@ void nla_operatortypes(void)
|
||||
WM_operatortype_append(NLA_OT_delete);
|
||||
WM_operatortype_append(NLA_OT_split);
|
||||
|
||||
WM_operatortype_append(NLA_OT_mute_toggle);
|
||||
|
||||
WM_operatortype_append(NLA_OT_move_up);
|
||||
WM_operatortype_append(NLA_OT_move_down);
|
||||
|
||||
@@ -256,6 +258,9 @@ static void nla_keymap_main (wmWindowManager *wm, ListBase *keymap)
|
||||
/* split */
|
||||
WM_keymap_add_item(keymap, "NLA_OT_split", YKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* toggles */
|
||||
WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* move up */
|
||||
WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0);
|
||||
/* move down */
|
||||
|
||||
Reference in New Issue
Block a user