[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21447] branches/soc-2009-aligorith/source /blender/editors/space_nla: NLA SoC: Toggle muting operator - HKEY

Joshua Leung aligorith at gmail.com
Thu Jul 9 03:32:16 CEST 2009


Revision: 21447
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21447
Author:   aligorith
Date:     2009-07-09 03:32:13 +0200 (Thu, 09 Jul 2009)

Log Message:
-----------
NLA SoC: Toggle muting operator - HKEY

This operator provides a quick way of toggling the muted-status of several strips at the same time. 

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-09 01:04:42 UTC (rev 21446)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-09 01:32:13 UTC (rev 21447)
@@ -857,6 +857,66 @@
 /* *********************************************** */
 /* 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. */
 

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c	2009-07-09 01:04:42 UTC (rev 21446)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c	2009-07-09 01:32:13 UTC (rev 21447)
@@ -168,6 +168,10 @@
 	
 	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");
 	

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-07-09 01:04:42 UTC (rev 21446)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-07-09 01:32:13 UTC (rev 21447)
@@ -98,6 +98,8 @@
 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);
 

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c	2009-07-09 01:04:42 UTC (rev 21446)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c	2009-07-09 01:32:13 UTC (rev 21447)
@@ -153,6 +153,8 @@
 	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 @@
 		/* 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 */





More information about the Bf-blender-cvs mailing list