[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25023] trunk/blender/source/blender/ editors: Durian Requests for Graph Editor Visibility Toggles (2):

Joshua Leung aligorith at gmail.com
Mon Nov 30 12:10:03 CET 2009


Revision: 25023
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25023
Author:   aligorith
Date:     2009-11-30 12:10:03 +0100 (Mon, 30 Nov 2009)

Log Message:
-----------
Durian Requests for Graph Editor Visibility Toggles (2):

Improved the hotkeys for toggling the visibility of channels in the keys area for the Graph Editor. 

* VKEY - this is now used for making only the selected channels visible, hiding everything else
* Shift-VKEY - the old toggling behaviour

In addition to this, I've made these toggling operators flush the visibility flags up/down the hierarchy, just like clicking on the channels manually do. There are still a few minor oddities to iron out, but it should be better than before.

Also, fixed a bug with these toggling operators introduced during my earlier commit to make filtering work ok. It's always tricky getting these layers of checks just right, so hopefully nothing breaks now again...

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/anim_channels_edit.c
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/include/ED_anim_api.h

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-11-30 10:21:42 UTC (rev 25022)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-11-30 11:10:03 UTC (rev 25023)
@@ -2340,13 +2340,10 @@
 static void achannel_setting_visible_widget_cb(bContext *C, void *ale_npoin, void *dummy_poin)
 {
 	bAnimListElem *ale_setting= (bAnimListElem *)ale_npoin;
-	int prevLevel=0, matchLevel=0;
-	short vizOn = 0;
-	
 	bAnimContext ac;
 	ListBase anim_data = {NULL, NULL};
-	bAnimListElem *ale, *match=NULL;
 	int filter;
+	short vizOn = 0;
 	
 	/* send notifiers before doing anything else... */
 	WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
@@ -2374,92 +2371,9 @@
 	filter= ANIMFILTER_CHANNELS;
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 	
-	/* find the channel that got changed */
-	for (ale= anim_data.first; ale; ale= ale->next) {
-		/* compare data, and type as main way of identifying the channel */
-		if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
-			/* we also have to check the ID, this is assigned to, since a block may have multiple users */
-			// TODO: is the owner-data more revealing?
-			if (ale->id == ale_setting->id) {
-				match= ale;
-				break;
-			}
-		}
-	}
-	if (match == NULL) {
-		printf("ERROR: no channel matching the one changed was found \n");
-		BLI_freelistN(&anim_data);
-		return;
-	}
-	else {
-		bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale_setting);
-		
-		/* get the level of the channel that was affected
-		 * 	 - we define the level as simply being the offset for the start of the channel
-		 */
-		matchLevel= (acf->get_offset)? acf->get_offset(&ac, ale_setting) : 0;
-	}
+	/* call API method to flush the setting */
+	ANIM_visibility_flush_anim_channels(&ac, &anim_data, ale_setting, vizOn);
 	
-	/* flush up? 
-	 *	- only flush up if the current state is now enabled 
-	 *	  (otherwise, it's too much work to force the parents to be inactive too)
-	 */
-	if (vizOn) {
-		/* go backwards in the list, until the highest-ranking element (by indention has been covered) */
-		for (ale= match->prev; ale; ale= ale->prev) {
-			bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
-			int level;
-			
-			/* get the level of the current channel traversed 
-			 * 	 - we define the level as simply being the offset for the start of the channel
-			 */
-			level= (acf->get_offset)? acf->get_offset(&ac, ale) : 0;
-			
-			/* if the level is 'less than' (i.e. more important) the previous channel, 
-			 * flush the new status...
-			 */
-			if (level < matchLevel)
-				ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn);
-			/* however, if the level is 'greater than' (i.e. less important than the previous channel,
-			 * stop searching, since we've already reached the bottom of another hierarchy
-			 */
-			else if (level > matchLevel)
-				break;
-			
-			/* store this level as the 'old' level now */
-			prevLevel= level;
-		}
-	}
-	
-	/* flush down (always) */
-	{
-		/* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
-		for (ale= match->next; ale; ale= ale->next) {
-			bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
-			int level;
-			
-			/* get the level of the current channel traversed 
-			 * 	 - we define the level as simply being the offset for the start of the channel
-			 */
-			level= (acf->get_offset)? acf->get_offset(&ac, ale) : 0;
-			
-			/* if the level is 'greater than' (i.e. less important) the channel that was changed, 
-			 * flush the new status...
-			 */
-			if (level > matchLevel)
-				ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn);
-			/* however, if the level is 'less than or equal to' the channel that was changed,
-			 * (i.e. the current channel is as important if not more important than the changed channel)
-			 * then we should stop, since we've found the last one of the children we should flush
-			 */
-			else
-				break;
-			
-			/* store this level as the 'old' level now */
-			prevLevel= level;
-		}
-	}
-	
 	/* free temp data */
 	BLI_freelistN(&anim_data);
 }

Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2009-11-30 10:21:42 UTC (rev 25022)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2009-11-30 11:10:03 UTC (rev 25023)
@@ -352,6 +352,106 @@
 	BLI_freelistN(&anim_data);
 }
 
+/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting 
+ *	- anim_data: list of the all the anim channels that can be chosen
+ *		-> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
+ *	 	  then the channels under closed expanders get ignored...
+ *	- ale_setting: the anim channel (not in the anim_data list directly, though occuring there)
+ *		with the new state of the setting that we want flushed up/down the hierarchy 
+ *	- vizOn: whether the visibility setting has been enabled or disabled 
+ */
+void ANIM_visibility_flush_anim_channels (bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, short vizOn)
+{
+	bAnimListElem *ale, *match=NULL;
+	int prevLevel=0, matchLevel=0;
+	
+	/* find the channel that got changed */
+	for (ale= anim_data->first; ale; ale= ale->next) {
+		/* compare data, and type as main way of identifying the channel */
+		if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
+			/* we also have to check the ID, this is assigned to, since a block may have multiple users */
+			// TODO: is the owner-data more revealing?
+			if (ale->id == ale_setting->id) {
+				match= ale;
+				break;
+			}
+		}
+	}
+	if (match == NULL) {
+		printf("ERROR: no channel matching the one changed was found \n");
+		return;
+	}
+	else {
+		bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale_setting);
+		
+		/* get the level of the channel that was affected
+		 * 	 - we define the level as simply being the offset for the start of the channel
+		 */
+		matchLevel= (acf->get_offset)? acf->get_offset(ac, ale_setting) : 0;
+	}
+	
+	/* flush up? 
+	 *	- only flush up if the current state is now enabled 
+	 *	  (otherwise, it's too much work to force the parents to be inactive too)
+	 */
+	if (vizOn) {
+		/* go backwards in the list, until the highest-ranking element (by indention has been covered) */
+		for (ale= match->prev; ale; ale= ale->prev) {
+			bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
+			int level;
+			
+			/* get the level of the current channel traversed 
+			 * 	 - we define the level as simply being the offset for the start of the channel
+			 */
+			level= (acf->get_offset)? acf->get_offset(ac, ale) : 0;
+			
+			/* if the level is 'less than' (i.e. more important) the level we're matching
+			 * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, 
+			 * when toggling visibility of F-Curves, gets flushed), flush the new status...
+			 */
+			if (level < prevLevel)
+				ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn);
+			/* however, if the level is 'greater than' (i.e. less important than the previous channel,
+			 * stop searching, since we've already reached the bottom of another hierarchy
+			 */
+			else if (level > matchLevel)
+				break;
+			
+			/* store this level as the 'old' level now */
+			prevLevel= level;
+		}
+	}
+	
+	/* flush down (always) */
+	{
+		/* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
+		for (ale= match->next; ale; ale= ale->next) {
+			bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
+			int level;
+			
+			/* get the level of the current channel traversed 
+			 * 	 - we define the level as simply being the offset for the start of the channel
+			 */
+			level= (acf->get_offset)? acf->get_offset(ac, ale) : 0;
+			
+			/* if the level is 'greater than' (i.e. less important) the channel that was changed, 
+			 * flush the new status...
+			 */
+			if (level > matchLevel)
+				ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_VISIBLE, vizOn);
+			/* however, if the level is 'less than or equal to' the channel that was changed,
+			 * (i.e. the current channel is as important if not more important than the changed channel)
+			 * then we should stop, since we've found the last one of the children we should flush
+			 */
+			else
+				break;
+			
+			/* store this level as the 'old' level now */
+			prevLevel= level;
+		}
+	}
+}
+
 /* ************************************************************************** */
 /* OPERATORS */
 
@@ -895,12 +995,87 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/* ******************** Set Channel Visibility Operator *********************** */
+/* NOTE: this operator is only valid in the Graph Editor channels region */
+
+static int animchannels_visibility_set_exec(bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	ListBase anim_data = {NULL, NULL};
+	ListBase all_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+	
+	
+	/* hide all channels not selected */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_UNSEL);
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	for (ale= anim_data.first; ale; ale= ale->next)
+		ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
+	
+	BLI_freelistN(&anim_data);
+	
+	
+	/* get list of all channels that selection may need to be flushed to */
+	filter= ANIMFILTER_CHANNELS;
+	ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
+	
+	/* make all the selected channels visible */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL);
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		/* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */
+		// TODO: find out why this is the case, and fix that
+		if (ale->type == ANIMTYPE_OBJECT)
+			continue;
+		
+		/* enable the setting */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list