[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27997] trunk/blender: Durian Feature Request for Graph Editor: Border Select (optionally) considers handles

Joshua Leung aligorith at gmail.com
Mon Apr 5 05:37:29 CEST 2010


Revision: 27997
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27997
Author:   aligorith
Date:     2010-04-05 05:37:28 +0200 (Mon, 05 Apr 2010)

Log Message:
-----------
Durian Feature Request for Graph Editor: Border Select (optionally) considers handles

Early when implementing the Graph Editor in 2.5, a key complaint that was levelled at the old 'IPO Editor' was that it was a constant annoyance that adjacent handles were getting selected in addition to the keyframes, when only the keyframes were intended. I solved this by making this default to only selecting keyframes and ignoring the handles, but this means that it isn't possible to batch move several handles at once. 

I've now improved this situation by adding an option to the border select operator (involved using Ctrl-B instead of B) which makes the handles get treated separately (as if they were separate verts, as in 2.4x). The default is still to only select keyframes, to have consistency with the DopeSheet...

Also performed some more renaming work in the code...

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_graph.py
    trunk/blender/source/blender/editors/animation/keyframes_edit.c
    trunk/blender/source/blender/editors/include/ED_keyframes_edit.h
    trunk/blender/source/blender/editors/space_graph/graph_ops.c
    trunk/blender/source/blender/editors/space_graph/graph_select.c

Modified: trunk/blender/release/scripts/ui/space_graph.py
===================================================================
--- trunk/blender/release/scripts/ui/space_graph.py	2010-04-05 00:06:06 UTC (rev 27996)
+++ trunk/blender/release/scripts/ui/space_graph.py	2010-04-05 03:37:28 UTC (rev 27997)
@@ -114,6 +114,7 @@
         layout.separator()
         layout.operator("graph.select_border")
         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
+        layout.operator("graph.select_border", text="Border (Include Handles)").include_handles = True
 
         layout.separator()
         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'

Modified: trunk/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_edit.c	2010-04-05 00:06:06 UTC (rev 27996)
+++ trunk/blender/source/blender/editors/animation/keyframes_edit.c	2010-04-05 03:37:28 UTC (rev 27997)
@@ -84,9 +84,11 @@
 /* This function is used to loop over BezTriples in the given F-Curve, applying a given 
  * operation on them, and optionally applies an F-Curve validation function afterwards.
  */
-short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb) 
+// TODO: make this function work on samples too...
+short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) 
 {
 	BezTriple *bezt;
+	short ok = 0;
 	int i;
 
 	/* sanity check */
@@ -97,23 +99,30 @@
 	if (ked) {
 		ked->fcu= fcu;
 		ked->curIndex= 0;
+		ked->curflags= ok;
 	}
 
 	/* if function to apply to bezier curves is set, then loop through executing it on beztriples */
-	if (bezt_cb) {
+	if (key_cb) {
 		/* if there's a validation func, include that check in the loop 
 		 * (this is should be more efficient than checking for it in every loop)
 		 */
-		if (bezt_ok) {
+		if (key_ok) {
 			for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
-				if (ked) ked->curIndex= i;
+				if (ked) {
+					/* advance the index, and reset the ok flags (to not influence the result) */
+					ked->curIndex= i;
+					ked->curflags= 0;
+				}
 				
 				/* Only operate on this BezTriple if it fullfills the criteria of the validation func */
-				if (bezt_ok(ked, bezt)) {
+				if ( (ok = key_ok(ked, bezt)) ) {
+					if (ked) ked->curflags= ok;
+					
 					/* Exit with return-code '1' if function returns positive
 					 * This is useful if finding if some BezTriple satisfies a condition.
 					 */
-					if (bezt_cb(ked, bezt)) return 1;
+					if (key_cb(ked, bezt)) return 1;
 				}
 			}
 		}
@@ -124,7 +133,7 @@
 				/* Exit with return-code '1' if function returns positive
 				* This is useful if finding if some BezTriple satisfies a condition.
 				*/
-				if (bezt_cb(ked, bezt)) return 1;
+				if (key_cb(ked, bezt)) return 1;
 			}
 		}
 	}
@@ -133,6 +142,7 @@
 	if (ked) {
 		ked->fcu= NULL;
 		ked->curIndex= 0;
+		ked->curflags= 0;
 	}
 
 	/* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
@@ -146,7 +156,7 @@
 /* -------------------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */
 
 /* This function is used to loop over the keyframe data in an Action Group */
-static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb)
+static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
 {
 	FCurve *fcu;
 	
@@ -156,7 +166,7 @@
 	
 	/* only iterate over the F-Curves that are in this group */
 	for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) {
-		if (ANIM_fcurve_keyframes_loop(ked, fcu, bezt_ok, bezt_cb, fcu_cb))
+		if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
 			return 1;
 	}
 	
@@ -164,7 +174,7 @@
 }
 
 /* This function is used to loop over the keyframe data in an Action */
-static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb)
+static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
 {
 	FCurve *fcu;
 	
@@ -174,7 +184,7 @@
 	
 	/* just loop through all F-Curves */
 	for (fcu= act->curves.first; fcu; fcu= fcu->next) {
-		if (ANIM_fcurve_keyframes_loop(ked, fcu, bezt_ok, bezt_cb, fcu_cb))
+		if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
 			return 1;
 	}
 	
@@ -182,7 +192,7 @@
 }
 
 /* This function is used to loop over the keyframe data of an AnimData block */
-static short adt_keyframes_loop(KeyframeEditData *ked, AnimData *adt, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+static short adt_keyframes_loop(KeyframeEditData *ked, AnimData *adt, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
 {
 	/* sanity check */
 	if (adt == NULL)
@@ -194,13 +204,13 @@
 		
 		/* just loop through all F-Curves acting as Drivers */
 		for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
-			if (ANIM_fcurve_keyframes_loop(ked, fcu, bezt_ok, bezt_cb, fcu_cb))
+			if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
 				return 1;
 		}
 	}
 	else if (adt->action) {
 		/* call the function for actions */
-		if (act_keyframes_loop(ked, adt->action, bezt_ok, bezt_cb, fcu_cb))
+		if (act_keyframes_loop(ked, adt->action, key_ok, key_cb, fcu_cb))
 			return 1;
 	}
 	
@@ -208,7 +218,7 @@
 }
 
 /* This function is used to loop over the keyframe data in an Object */
-static short ob_keyframes_loop(KeyframeEditData *ked, Object *ob, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+static short ob_keyframes_loop(KeyframeEditData *ked, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
 {
 	Key *key= ob_get_key(ob);
 	
@@ -218,13 +228,13 @@
 	
 	/* firstly, Object's own AnimData */
 	if (ob->adt) {
-		if (adt_keyframes_loop(ked, ob->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+		if (adt_keyframes_loop(ked, ob->adt, key_ok, key_cb, fcu_cb, filterflag))
 			return 1;
 	}
 	
 	/* shapekeys */
 	if ((key && key->adt) && !(filterflag & ADS_FILTER_NOSHAPEKEYS)) {
-		if (adt_keyframes_loop(ked, key->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+		if (adt_keyframes_loop(ked, key->adt, key_ok, key_cb, fcu_cb, filterflag))
 			return 1;
 	}
 		
@@ -240,7 +250,7 @@
 				continue;
 			
 			/* add material's data */
-			if (adt_keyframes_loop(ked, ma->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+			if (adt_keyframes_loop(ked, ma->adt, key_ok, key_cb, fcu_cb, filterflag))
 				return 1;
 		}
 	}
@@ -252,7 +262,7 @@
 			Camera *ca= (Camera *)ob->data;
 			
 			if ((ca->adt) && !(filterflag & ADS_FILTER_NOCAM)) {
-				if (adt_keyframes_loop(ked, ca->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, ca->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -262,7 +272,7 @@
 			Lamp *la= (Lamp *)ob->data;
 			
 			if ((la->adt) && !(filterflag & ADS_FILTER_NOLAM)) {
-				if (adt_keyframes_loop(ked, la->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, la->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -274,7 +284,7 @@
 			Curve *cu= (Curve *)ob->data;
 			
 			if ((cu->adt) && !(filterflag & ADS_FILTER_NOCUR)) {
-				if (adt_keyframes_loop(ked, cu->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, cu->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -284,7 +294,7 @@
 			MetaBall *mb= (MetaBall *)ob->data;
 			
 			if ((mb->adt) && !(filterflag & ADS_FILTER_NOMBA)) {
-				if (adt_keyframes_loop(ked, mb->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, mb->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -294,7 +304,7 @@
 			bArmature *arm= (bArmature *)ob->data;
 			
 			if ((arm->adt) && !(filterflag & ADS_FILTER_NOARM)) {
-				if (adt_keyframes_loop(ked, arm->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, arm->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -304,7 +314,7 @@
 			Mesh *me= (Mesh *)ob->data;
 			
 			if ((me->adt) && !(filterflag & ADS_FILTER_NOMESH)) {
-				if (adt_keyframes_loop(ked, me->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+				if (adt_keyframes_loop(ked, me->adt, key_ok, key_cb, fcu_cb, filterflag))
 					return 1;
 			}
 		}
@@ -319,7 +329,7 @@
 			if (ELEM(NULL, psys->part, psys->part->adt))
 				continue;
 				
-			if (adt_keyframes_loop(ked, psys->part->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+			if (adt_keyframes_loop(ked, psys->part->adt, key_ok, key_cb, fcu_cb, filterflag))
 				return 1;
 		}
 	}
@@ -328,7 +338,7 @@
 }
 
 /* This function is used to loop over the keyframe data in a Scene */
-static short scene_keyframes_loop(KeyframeEditData *ked, Scene *sce, KeyframeEditFunc bezt_ok, KeyframeEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+static short scene_keyframes_loop(KeyframeEditData *ked, Scene *sce, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
 {
 	World *wo= (sce) ? sce->world : NULL;
 	bNodeTree *ntree= (sce) ? sce->nodetree : NULL;
@@ -339,19 +349,19 @@
 	
 	/* Scene's own animation */
 	if (sce->adt) {
-		if (adt_keyframes_loop(ked, sce->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+		if (adt_keyframes_loop(ked, sce->adt, key_ok, key_cb, fcu_cb, filterflag))
 			return 1;
 	}
 	
 	/* World */
 	if (wo && wo->adt) {
-		if (adt_keyframes_loop(ked, wo->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+		if (adt_keyframes_loop(ked, wo->adt, key_ok, key_cb, fcu_cb, filterflag))
 			return 1;
 	}
 	
 	/* NodeTree */
 	if (ntree && ntree->adt) {
-		if (adt_keyframes_loop(ked, ntree->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+		if (adt_keyframes_loop(ked, ntree->adt, key_ok, key_cb, fcu_cb, filterflag))
 			return 1;
 	}
 	
@@ -360,7 +370,7 @@
 }
 
 /* This function is used to loop over the keyframe data in a DopeSheet summary */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list