[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16850] trunk/blender/source/blender/src/ keyframing.c: Keyframing:

Joshua Leung aligorith at gmail.com
Tue Sep 30 14:30:58 CEST 2008


Revision: 16850
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16850
Author:   aligorith
Date:     2008-09-30 14:30:56 +0200 (Tue, 30 Sep 2008)

Log Message:
-----------
Keyframing:

- More cleanups, to move the return of success from insertkey to take into account results of 'only needed' keying option
- Added a 'better' test for size of area than the previous one (for use with the keyframing buttons in the TimeLine)
- Moved the checks for Action/IPO editors to commonkey_context_get() so that the keyframing buttons in TimeLine could also consider using these editor's keyframing methods too

Modified Paths:
--------------
    trunk/blender/source/blender/src/keyframing.c

Modified: trunk/blender/source/blender/src/keyframing.c
===================================================================
--- trunk/blender/source/blender/src/keyframing.c	2008-09-30 12:03:31 UTC (rev 16849)
+++ trunk/blender/source/blender/src/keyframing.c	2008-09-30 12:30:56 UTC (rev 16850)
@@ -786,7 +786,7 @@
 			insert_mode= new_key_needed(icu, cfra, curval);
 			
 			/* insert new keyframe at current frame */
-			if (insert_mode) 
+			if (insert_mode)
 				insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST));
 			
 			/* delete keyframe immediately before/after newly added */
@@ -798,14 +798,18 @@
 					delete_icu_key(icu, 1, 1);
 					break;
 			}
+			
+			/* only return success if keyframe added */
+			if (insert_mode)
+				return 1;
 		}
 		else {
 			/* just insert keyframe */
 			insert_vert_icu(icu, cfra, curval, (flag & INSERTKEY_FAST));
+			
+			/* return success */
+			return 1;
 		}
-		
-		/* return success */
-		return 1;
 	}
 	
 	/* return failure */
@@ -885,6 +889,11 @@
 /* ************************************************** */
 /* COMMON KEYFRAME MANAGEMENT (common_insertkey/deletekey) */
 
+/* mode for common_modifykey */
+enum {
+	COMMONKEY_MODE_INSERT = 0,
+	COMMONKEY_MODE_DELETE,
+} eCommonModifyKey_Modes;
 
 /* ------------- KeyingSet Defines ------------ */
 /* Note: these must all be named with the defks_* prefix, otherwise the template macro will not work! */
@@ -1493,7 +1502,7 @@
 
 
 /* get keyingsets for appropriate context */
-static void commonkey_context_get (ScrArea *sa, ListBase *sources, bKeyingContext **ksc)
+static void commonkey_context_get (ScrArea *sa, short mode, ListBase *sources, bKeyingContext **ksc)
 {
 	/* check view type */
 	switch (sa->spacetype) {
@@ -1511,10 +1520,21 @@
 		}
 			break;
 			
+		/* spaces with their own methods */
+		case SPACE_IPO:
+			if (mode == COMMONKEY_MODE_INSERT)
+				insertkey_editipo();
+			return;
+		case SPACE_ACTION:
+			if (mode == COMMONKEY_MODE_INSERT)
+				insertkey_action();
+			return;
+			
 		/* timeline view - keyframe buttons */
 		case SPACE_TIME:
 		{
 			ScrArea *sab;
+			int bigarea= 0;
 			
 			/* try to find largest 3d-view available 
 			 * (mostly of the time, this is what when user will want this,
@@ -1526,12 +1546,21 @@
 				return;
 			}
 			
-			/* otherwise, try to find the biggest area
-			 * WARNING: must check if that area is another timeline, as that would cause infinite loop
-			 */
-			sab= closest_bigger_area();
-			if ((sab) && (sab->spacetype != SPACE_TIME)) 
-				commonkey_context_get(sab, sources, ksc);
+			/* if not found, sab is now NULL, so perform own biggest area test */
+			for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+				int area= sa->winx * sa->winy;
+				
+				if (sa->spacetype != SPACE_TIME) {
+					if ( (!sab) || (area > bigarea) ) {
+						sab= sa;
+						bigarea= area;
+					}
+				}
+			}
+			
+			/* use whichever largest area was found (it shouldn't be a time window) */
+			if (sab)
+				commonkey_context_get(sab, mode, sources, ksc);
 		}
 			break;
 	}
@@ -1670,12 +1699,6 @@
 
 /* ---------------- Keyframe Management API -------------------- */
 
-/* mode for common_modifykey */
-enum {
-	COMMONKEY_MODE_INSERT = 0,
-	COMMONKEY_MODE_DELETE,
-} eCommonModifyKey_Modes;
-
 /* Display a menu for handling the insertion of keyframes based on the active view */
 // TODO: add back an option for repeating last keytype
 void common_modifykey (short mode)
@@ -1691,26 +1714,10 @@
 	if (ELEM(mode, COMMONKEY_MODE_INSERT, COMMONKEY_MODE_DELETE)==0)
 		return;
 	
-	/* delegate to other functions or get keyingsets to use */
-	switch (curarea->spacetype) {
-			/* spaces with their own methods */
-		case SPACE_IPO:
-			if (mode == COMMONKEY_MODE_INSERT)
-				insertkey_editipo();
-			return;
-		case SPACE_ACTION:
-			if (mode == COMMONKEY_MODE_INSERT)
-				insertkey_action();
-			return;
-			
-			/* TODO: based on UI elements? will that even be handled here??? */
-			
-			/* default - check per view */
-		default:
-			/* get the keyingsets and the data to add keyframes to */
-			commonkey_context_get(curarea, &dsources, &ksc);
-			break;
-	}	
+	/* delegate to other functions or get keyingsets to use 
+	 *	- if the current area doesn't have its own handling, there will be data returned...
+	 */
+	commonkey_context_get(curarea, mode, &dsources, &ksc);
 	
 	/* check that there is data to operate on */
 	if (ELEM(NULL, dsources.first, ksc)) {





More information about the Bf-blender-cvs mailing list