[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32915] trunk/blender: Animation Editors: Channel Reordering

Joshua Leung aligorith at gmail.com
Sun Nov 7 13:09:15 CET 2010


Revision: 32915
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32915
Author:   aligorith
Date:     2010-11-07 13:09:15 +0100 (Sun, 07 Nov 2010)

Log Message:
-----------
Animation Editors: Channel Reordering

This commit restores the ability to reorder channels in the animation editors (DopeSheet/Action/etc., Graph/Drivers, NLA). The hotkeys for this are:
- Shift-PageUp = Move Up
- Shift-PageDown = Move Down

- Ctrl-Shift-PageUp = Move to Top of List
- Ctrl-Shift-PageDown = Move to Bottom of List

Do note that only animation data can get reordered using this. 
So, do not expect to be able to change the object order (that is actually taken from the order that Blender actually evaluates them per update/frame).

---

In the process, I've fixed a couple of other bugs:
* Removed 'optimisation step' check in anim_filter.c for dopesheet with no filtering options modified, since this meant that the ANIMFILTER_ANIMDATA data filter was not getting processed (and potentially there were other maintenance problems with that).

* Made NLA Editor's channel list not totally duplicate the basic Animation Channels keymap. Instead, the "NLA Channels" keymap now only defines the parts that are different, and this then gets specified before the standard one so that these different parts will override the standard ones.

* Attempted to fix BorderSelect on NLA Channels list. Still not totally working correctly yet though.

* Moved "Euler Discontinuity" menu entry from "Channels" to "Keys". It really belongs in the latter, since it affects the keyframe values, rather than some aspect of the channel (i.e. ordering of channels or how they're displayed)

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_dopesheet.py
    trunk/blender/release/scripts/ui/space_graph.py
    trunk/blender/release/scripts/ui/space_nla.py
    trunk/blender/source/blender/editors/animation/anim_channels_edit.c
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/space_nla/nla_ops.c
    trunk/blender/source/blender/editors/space_nla/space_nla.c
    trunk/blender/source/blender/makesdna/DNA_anim_types.h

Modified: trunk/blender/release/scripts/ui/space_dopesheet.py
===================================================================
--- trunk/blender/release/scripts/ui/space_dopesheet.py	2010-11-07 10:50:36 UTC (rev 32914)
+++ trunk/blender/release/scripts/ui/space_dopesheet.py	2010-11-07 12:09:15 UTC (rev 32915)
@@ -199,6 +199,8 @@
         layout.operator("anim.channels_expand")
         layout.operator("anim.channels_collapse")
 
+        layout.separator()
+        layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
 
 class DOPESHEET_MT_key(bpy.types.Menu):
     bl_label = "Key"

Modified: trunk/blender/release/scripts/ui/space_graph.py
===================================================================
--- trunk/blender/release/scripts/ui/space_graph.py	2010-11-07 10:50:36 UTC (rev 32914)
+++ trunk/blender/release/scripts/ui/space_graph.py	2010-11-07 12:09:15 UTC (rev 32915)
@@ -158,7 +158,7 @@
         layout.operator("anim.channels_collapse")
 
         layout.separator()
-        layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
+        layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
 
 
 class GRAPH_MT_key(bpy.types.Menu):
@@ -195,7 +195,10 @@
         layout.operator("graph.copy")
         layout.operator("graph.paste")
 
+        layout.separator()
+        layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
 
+
 class GRAPH_MT_key_transform(bpy.types.Menu):
     bl_label = "Transform"
 

Modified: trunk/blender/release/scripts/ui/space_nla.py
===================================================================
--- trunk/blender/release/scripts/ui/space_nla.py	2010-11-07 10:50:36 UTC (rev 32914)
+++ trunk/blender/release/scripts/ui/space_nla.py	2010-11-07 12:09:15 UTC (rev 32915)
@@ -122,7 +122,11 @@
         layout.operator("nla.move_up")
         layout.operator("nla.move_down")
 
+        # TODO: this really belongs more in a "channel" (or better, "track") menu
         layout.separator()
+        layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
+
+        layout.separator()
         # TODO: names of these tools for 'tweakmode' need changing?
         if scene.is_nla_tweakmode:
             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")

Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-11-07 10:50:36 UTC (rev 32914)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-11-07 12:09:15 UTC (rev 32915)
@@ -25,6 +25,10 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> 
+
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
@@ -542,94 +546,29 @@
 }
 
 /* ****************** Rearrange Channels Operator ******************* */
-/* This operator only works for Action Editor mode for now, as having it elsewhere makes things difficult */
 
-#if 0 // XXX old animation system - needs to be updated for new system...
-
 /* constants for channel rearranging */
 /* WARNING: don't change exising ones without modifying rearrange func accordingly */
 enum {
-	REARRANGE_ACTCHAN_TOP= -2,
-	REARRANGE_ACTCHAN_UP= -1,
-	REARRANGE_ACTCHAN_DOWN= 1,
-	REARRANGE_ACTCHAN_BOTTOM= 2
+	REARRANGE_ANIMCHAN_TOP= -2,
+	REARRANGE_ANIMCHAN_UP= -1,
+	REARRANGE_ANIMCHAN_DOWN= 1,
+	REARRANGE_ANIMCHAN_BOTTOM= 2
 };
 
-/* make sure all action-channels belong to a group (and clear action's list) */
-static void split_groups_action_temp (bAction *act, bActionGroup *tgrp)
-{
-	bActionChannel *achan;
-	bActionGroup *agrp;
-	
-	/* Separate action-channels into lists per group */
-	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
-		if (agrp->channels.first) {
-			achan= agrp->channels.last;
-			act->chanbase.first= achan->next;
-			
-			achan= agrp->channels.first;
-			achan->prev= NULL;
-			
-			achan= agrp->channels.last;
-			achan->next= NULL;
-		}
-	}
-	
-	/* Initialise memory for temp-group */
-	memset(tgrp, 0, sizeof(bActionGroup));
-	tgrp->flag |= (AGRP_EXPANDED|AGRP_TEMP);
-	strcpy(tgrp->name, "#TempGroup");
-		
-	/* Move any action-channels not already moved, to the temp group */
-	if (act->chanbase.first) {
-		/* start of list */
-		achan= act->chanbase.first;
-		achan->prev= NULL;
-		tgrp->channels.first= achan;
-		act->chanbase.first= NULL;
-		
-		/* end of list */
-		achan= act->chanbase.last;
-		achan->next= NULL;
-		tgrp->channels.last= achan;
-		act->chanbase.last= NULL;
-	}
-	
-	/* Add temp-group to list */
-	BLI_addtail(&act->groups, tgrp);
-}
+/* defines for rearranging channels */
+EnumPropertyItem prop_animchannel_rearrange_types[] = {
+	{REARRANGE_ANIMCHAN_TOP, "TOP", 0, "To Top", ""},
+	{REARRANGE_ANIMCHAN_UP, "UP", 0, "Up", ""},
+	{REARRANGE_ANIMCHAN_DOWN, "DOWN", 0, "Down", ""},
+	{REARRANGE_ANIMCHAN_BOTTOM, "BOTTOM", 0, "To Bottom", ""},
+	{0, NULL, 0, NULL, NULL}
+};
 
-/* link lists of channels that groups have */
-static void join_groups_action_temp (bAction *act)
-{
-	bActionGroup *agrp;
-	bActionChannel *achan;
-	
-	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
-		ListBase tempGroup;
-		
-		/* add list of channels to action's channels */
-		tempGroup= agrp->channels;
-		addlisttolist(&act->chanbase, &agrp->channels);
-		agrp->channels= tempGroup;
-		
-		/* clear moved flag */
-		agrp->flag &= ~AGRP_MOVED;
-		
-		/* if temp-group... remove from list (but don't free as it's on the stack!) */
-		if (agrp->flag & AGRP_TEMP) {
-			BLI_remlink(&act->groups, agrp);
-			break;
-		}
-	}
-	
-	/* clear "moved" flag from all achans */
-	for (achan= act->chanbase.first; achan; achan= achan->next) 
-		achan->flag &= ~ACHAN_MOVED;
-}
+/* Rearrange Utilities --------------------------------------------- */
 
-
-static short rearrange_actchannel_is_ok (Link *channel, short type)
+/* checks if a channel should be considered for moving */
+static short rearrange_animchannel_is_ok (Link *channel, short type)
 {
 	if (type == ANIMTYPE_GROUP) {
 		bActionGroup *agrp= (bActionGroup *)channel;
@@ -637,17 +576,25 @@
 		if (SEL_AGRP(agrp) && !(agrp->flag & AGRP_MOVED))
 			return 1;
 	}
-	else if (type == ANIMTYPE_ACHAN) {
-		bActionChannel *achan= (bActionChannel *)channel;
+	else if (type == ANIMTYPE_FCURVE) {
+		FCurve *fcu= (FCurve *)channel;
 		
-		if (VISIBLE_ACHAN(achan) && SEL_ACHAN(achan) && !(achan->flag & ACHAN_MOVED))
+		// FIXME: F-Curve visibility is difficult... needs special filtering tests these days...
+		if (SEL_FCU(fcu) && !(fcu->flag & FCURVE_TAGGED))
 			return 1;
 	}
+	else if (type == ANIMTYPE_NLATRACK) {
+		NlaTrack *nlt = (NlaTrack *)channel;
+		
+		if (SEL_NLT(nlt) && !(nlt->flag & NLASTRIP_FLAG_EDIT_TOUCHED))
+			return 1;
+	}
 	
 	return 0;
 }
 
-static short rearrange_actchannel_after_ok (Link *channel, short type)
+/* checks if another channel can be placed after the given one */
+static short rearrange_animchannel_after_ok (Link *channel, short type)
 {
 	if (type == ANIMTYPE_GROUP) {
 		bActionGroup *agrp= (bActionGroup *)channel;
@@ -659,10 +606,11 @@
 	return 1;
 }
 
+/* Rearrange Methods --------------------------------------------- */
 
-static short rearrange_actchannel_top (ListBase *list, Link *channel, short type)
+static short rearrange_animchannel_top (ListBase *list, Link *channel, short type)
 {
-	if (rearrange_actchannel_is_ok(channel, type)) {
+	if (rearrange_animchannel_is_ok(channel, type)) {
 		/* take it out off the chain keep data */
 		BLI_remlink(list, channel);
 		
@@ -675,9 +623,9 @@
 	return 0;
 }
 
-static short rearrange_actchannel_up (ListBase *list, Link *channel, short type)
+static short rearrange_animchannel_up (ListBase *list, Link *channel, short type)
 {
-	if (rearrange_actchannel_is_ok(channel, type)) {
+	if (rearrange_animchannel_is_ok(channel, type)) {
 		Link *prev= channel->prev;
 		
 		if (prev) {
@@ -694,9 +642,9 @@
 	return 0;
 }
 
-static short rearrange_actchannel_down (ListBase *list, Link *channel, short type)
+static short rearrange_animchannel_down (ListBase *list, Link *channel, short type)
 {
-	if (rearrange_actchannel_is_ok(channel, type)) {
+	if (rearrange_animchannel_is_ok(channel, type)) {
 		Link *next = (channel->next) ? channel->next->next : NULL;
 		
 		if (next) {
@@ -708,7 +656,7 @@
 			
 			return 1;
 		}
-		else if (rearrange_actchannel_after_ok(list->last, type)) {
+		else if (rearrange_animchannel_after_ok(list->last, type)) {
 			/* take it out off the chain keep data */
 			BLI_remlink(list, channel);
 			
@@ -731,10 +679,10 @@
 	return 0;
 }
 
-static short rearrange_actchannel_bottom (ListBase *list, Link *channel, short type)
+static short rearrange_animchannel_bottom (ListBase *list, Link *channel, short type)
 {
-	if (rearrange_actchannel_is_ok(channel, type)) {
-		if (rearrange_actchannel_after_ok(list->last, type)) {
+	if (rearrange_animchannel_is_ok(channel, type)) {
+		if (rearrange_animchannel_after_ok(list->last, type)) {
 			/* take it out off the chain keep data */
 			BLI_remlink(list, channel);
 			
@@ -748,51 +696,238 @@
 	return 0;
 }
 
+/* Generic Stuff ---------------------------------------------------------- */
 
-/* Change the order of action-channels 
- *	mode: REARRANGE_ACTCHAN_*  
+/* typedef for channel rearranging function 
+ * < list: list that channels belong to
+ * < channel: channel to be moved
+ * < type: type of channel (eAnim_ChannelType)
+ * > return[0]: whether operation was a success
  */
-static void rearrange_action_channels (bAnimContext *ac, short mode)
+typedef short (*AnimChanRearrangeFp)(ListBase *list, Link *channel, short type);
+
+/* get rearranging function, given 'rearrange' mode */
+static AnimChanRearrangeFp rearrange_get_mode_func (short mode)
 {
-	bAction *act;
-	bActionChannel *achan, *chan;
-	bActionGroup *agrp, *grp;
-	bActionGroup tgrp;
+	switch (mode) {
+		case REARRANGE_ANIMCHAN_TOP:
+			return rearrange_animchannel_top;
+		case REARRANGE_ANIMCHAN_UP:
+			return rearrange_animchannel_up;
+		case REARRANGE_ANIMCHAN_DOWN:
+			return rearrange_animchannel_down;
+		case REARRANGE_ANIMCHAN_BOTTOM:
+			return rearrange_animchannel_bottom;
+		default:
+			return NULL;
+	}
+}
+
+/* ........ */
+
+/* These iteration helpers (ideally should be inlined, but probably not necessary) */
+
+static Link *rearrange_iter_first (ListBase *list, short mode)
+{
+	return (mode > 0) ? list->first : list->last;
+}
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list