[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25309] trunk/blender: Timeline Drawing Tweaks:

Joshua Leung aligorith at gmail.com
Fri Dec 11 12:18:56 CET 2009


Revision: 25309
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25309
Author:   aligorith
Date:     2009-12-11 12:18:55 +0100 (Fri, 11 Dec 2009)

Log Message:
-----------
Timeline Drawing Tweaks:

* Made the TimeLine current frame indicator get drawn using the standard frame-indicator code. Also, it is now possible to show the frame indicator box beside the line as in the other animation editors, although this is disabled in the timeline due to the closeness of the frame number field.

* Removed some old (unnecessary) code
-> "Continue Physics" option in TimeLine, which is now obsolete with the current physics options. Feel free to restore if this is not the case.
-> Already commented out hacks to create "speed ipo" for curves. There are easy alternatives that are better integrated.
-> Unused init/exit callbacks for scrubbing time, since those were only used to set an obsolete flag for timeline drawing that is now used for the indicator.

* Switched long-keyframe optimisation code to use constants instead of some magic numbers + fancy trickery...

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_time.py
    trunk/blender/source/blender/editors/animation/anim_ops.c
    trunk/blender/source/blender/editors/animation/keyframes_draw.c
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/space_time/space_time.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/ui/space_time.py	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/release/scripts/ui/space_time.py	2009-12-11 11:18:55 UTC (rev 25309)
@@ -95,6 +95,7 @@
 
         layout.separator()
 
+        layout.prop(st, "show_cframe_indicator")
         layout.prop(st, "only_selected")
 
 
@@ -142,10 +143,6 @@
 
         layout.separator()
 
-        layout.prop(st, "continue_physics")
-
-        layout.separator()
-
         layout.prop(scene, "sync_audio", text="Realtime Playback", icon='SPEAKER')
         layout.prop(scene, "mute_audio")
         layout.prop(scene, "scrub_audio")

Modified: trunk/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_ops.c	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/editors/animation/anim_ops.c	2009-12-11 11:18:55 UTC (rev 25309)
@@ -74,25 +74,6 @@
 	return ((curarea) && (curarea->spacetype != SPACE_IPO));
 }
 
-/* Set any flags that are necessary to indicate modal time-changing operation */
-static int change_frame_init(bContext *C, wmOperator *op)
-{
-	ScrArea *curarea= CTX_wm_area(C);
-	
-	if (curarea == NULL)
-		return 0;
-	
-	if (curarea->spacetype == SPACE_TIME) {
-		SpaceTime *stime= CTX_wm_space_time(C);
-		
-		/* timeline displays frame number only when dragging indicator */
-		// XXX make this more in line with other anim editors?
-		stime->flag |= TIME_CFRA_NUM;
-	}
-	
-	return 1;
-}
-
 /* Set the new frame number */
 static void change_frame_apply(bContext *C, wmOperator *op)
 {
@@ -106,33 +87,12 @@
 	WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
 }
 
-/* Clear any temp flags */
-static void change_frame_exit(bContext *C, wmOperator *op)
-{
-	ScrArea *curarea= CTX_wm_area(C);
-	
-	if (curarea == NULL)
-		return;
-	
-	if (curarea->spacetype == SPACE_TIME) {
-		SpaceTime *stime= CTX_wm_space_time(C);
-		
-		/* timeline displays frame number only when dragging indicator */
-		// XXX make this more in line with other anim editors?
-		stime->flag &= ~TIME_CFRA_NUM;
-	}
-}
-
 /* ---- */
 
 /* Non-modal callback for running operator without user input */
 static int change_frame_exec(bContext *C, wmOperator *op)
 {
-	if (!change_frame_init(C, op))
-		return OPERATOR_CANCELLED;
-	
 	change_frame_apply(C, op);
-	change_frame_exit(C, op);
 
 	return OPERATOR_FINISHED;
 }
@@ -166,7 +126,6 @@
 	 */
 	RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
 	
-	change_frame_init(C, op);
 	change_frame_apply(C, op);
 	
 	/* add temp handler */
@@ -175,20 +134,12 @@
 	return OPERATOR_RUNNING_MODAL;
 }
 
-/* In case modal operator is cancelled */
-static int change_frame_cancel(bContext *C, wmOperator *op)
-{
-	change_frame_exit(C, op);
-	return OPERATOR_CANCELLED;
-}
-
 /* Modal event handling of frame changing */
 static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
 	/* execute the events */
 	switch (event->type) {
 		case ESCKEY:
-			change_frame_exit(C, op);
 			return OPERATOR_FINISHED;
 		
 		case MOUSEMOVE:
@@ -201,10 +152,8 @@
 			/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
 			 * the modal op) doesn't work for some reason
 			 */
-			if (event->val==KM_RELEASE) {
-				change_frame_exit(C, op);
+			if (event->val==KM_RELEASE)
 				return OPERATOR_FINISHED;
-			}
 			break;
 	}
 
@@ -221,7 +170,6 @@
 	/* api callbacks */
 	ot->exec= change_frame_exec;
 	ot->invoke= change_frame_invoke;
-	ot->cancel= change_frame_cancel;
 	ot->modal= change_frame_modal;
 	ot->poll= change_frame_poll;
 	

Modified: trunk/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_draw.c	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/editors/animation/keyframes_draw.c	2009-12-11 11:18:55 UTC (rev 25309)
@@ -170,6 +170,9 @@
 
 /* ActBeztColumns (Helpers for Long Keyframes) ------------------------------ */
 
+/* maximum size of default buffer for BezTriple columns */
+#define MAX_ABK_BUFSIZE 	4
+
 /* BezTriple Container Node */
 // NOTE: only used internally while building Long Keyframes for now, but may be useful externally?
 typedef struct ActBeztColumn {
@@ -187,7 +190,7 @@
 	short numBezts;						/* number of BezTriples on this frame */
 	float cfra;							/* frame that the BezTriples occur on */
 	
-	BezTriple *bezts[4];				/* buffer of pointers to BezTriples on the same frame */
+	BezTriple *bezts[MAX_ABK_BUFSIZE];	/* buffer of pointers to BezTriples on the same frame */
 	//BezTriple **bezts_extra;			/* secondary buffer of pointers if need be */
 } ActBeztColumn;
 
@@ -227,9 +230,8 @@
 	BezTriple *bezt= (BezTriple *)data;
 	
 	/* just add the BezTriple to the buffer if there's space, or allocate a new one */
-	if (abk->numBezts >= sizeof(abk->bezts)/sizeof(BezTriple)) {
+	if (abk->numBezts >= MAX_ABK_BUFSIZE) {
 		// TODO: need to allocate new array to cater...
-		// FIXME: urgent... is a problem when working with duplicate keyframes
 		//bezts_extra= MEM_callocN(...);
 		if(G.f & G_DEBUG)
 			printf("FIXME: nupdate_abk_bezt() missing case for too many overlapping BezTriples \n");

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2009-12-11 11:18:55 UTC (rev 25309)
@@ -5285,42 +5285,3 @@
 {
 	undo_editmode_push(C, name, get_data, free_undoCurve, undoCurve_to_editCurve, editCurve_to_undoCurve, NULL);
 }
-
-/***************** XXX old cruft ********************/
-
-void default_curve_ipo(Scene *scene, Curve *cu)
-{
-#if 0 // XXX old animation system
-	IpoCurve *icu;
-	BezTriple *bezt;
-	
-	if(cu->ipo) return;
-	
-	cu->ipo= add_ipo(scene, "CurveIpo", ID_CU);
-	
-	icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
-			
-	icu->blocktype= ID_CU;
-	icu->adrcode= CU_SPEED;
-	icu->flag= IPO_VISIBLE|IPO_SELECT|IPO_AUTO_HORIZ;
-	set_icu_vars(icu);
-	
-	BLI_addtail( &(cu->ipo->curve), icu);
-	
-	icu->bezt= bezt= MEM_callocN(2*sizeof(BezTriple), "defaultipo");
-	icu->totvert= 2;
-	
-	bezt->hide= IPO_BEZ;
-	bezt->f1=bezt->f2= bezt->f3= SELECT;
-	bezt->h1= bezt->h2= HD_AUTO;
-	bezt++;
-	bezt->vec[1][0]= 100.0;
-	bezt->vec[1][1]= 1.0;
-	bezt->hide= IPO_BEZ;
-	bezt->f1=bezt->f2= bezt->f3= SELECT;
-	bezt->h1= bezt->h2= HD_AUTO;
-	
-	calchandles_ipocurve(icu);
-#endif // XXX old animation system
-}
-

Modified: trunk/blender/source/blender/editors/space_time/space_time.c
===================================================================
--- trunk/blender/source/blender/editors/space_time/space_time.c	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/editors/space_time/space_time.c	2009-12-11 11:18:55 UTC (rev 25309)
@@ -45,6 +45,7 @@
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
+#include "ED_anim_api.h"
 #include "ED_keyframes_draw.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
@@ -66,27 +67,6 @@
 
 /* ************************ main time area region *********************** */
 
-/* draws a current frame indicator for the TimeLine */
-static void time_draw_cfra_time(const bContext *C, SpaceTime *stime, ARegion *ar)
-{
-	Scene *scene= CTX_data_scene(C);
-	float vec[2];
-	
-	vec[0]= scene->r.cfra*scene->r.framelen;
-
-	UI_ThemeColor(TH_CFRAME);	// no theme, should be global color once...
-	glLineWidth(3.0);
-
-	glBegin(GL_LINES);
-		vec[1]= ar->v2d.cur.ymin;
-		glVertex2fv(vec);
-		vec[1]= ar->v2d.cur.ymax;
-		glVertex2fv(vec);
-	glEnd();
-	
-	glLineWidth(1.0);
-}
-
 static void time_draw_sfra_efra(const bContext *C, SpaceTime *stime, ARegion *ar)
 {
 	View2D *v2d= UI_view2d_fromcontext(C);
@@ -218,8 +198,8 @@
 	View2D *v2d= &ar->v2d;
 	View2DGrid *grid;
 	View2DScrollers *scrollers;
+	int unit, flag=0;
 	float col[3];
-	int unit;
 	
 	/* clear and setup matrix */
 	UI_GetThemeColor3fv(TH_BACK, col);
@@ -241,7 +221,9 @@
 	time_draw_keyframes(C, stime, ar);
 	
 	/* current frame */
-	time_draw_cfra_time(C, stime, ar);
+	if ((stime->flag & TIME_DRAWFRAMES)==0) 	flag |= DRAWCFRA_UNIT_SECONDS;
+	if (stime->flag & TIME_CFRA_NUM) 			flag |= DRAWCFRA_SHOW_NUMBOX;
+	ANIM_draw_cfra(C, v2d, flag);
 	
 	/* markers */
 	UI_view2d_view_orthoSpecial(C, v2d, 1);

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2009-12-11 11:18:55 UTC (rev 25309)
@@ -825,7 +825,7 @@
 /* time->flag */
 	/* show timing in frames instead of in seconds */
 #define TIME_DRAWFRAMES		1
-	/* temporary flag set when scrubbing time */
+	/* show time indicator box beside the frame number */
 #define TIME_CFRA_NUM		2
 	/* only keyframes from active/selected channels get shown */
 #define TIME_ONLYACTSEL		4

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-12-11 10:56:20 UTC (rev 25308)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-12-11 11:18:55 UTC (rev 25309)
@@ -1458,7 +1458,6 @@
 	RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data.");
 	
 	/* Define Anim Playback Areas */
-	
 	prop= RNA_def_property(srna, "play_top_left", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_REGION);
 	RNA_def_property_ui_text(prop, "Top-Left 3D Window", "");
@@ -1494,17 +1493,16 @@
 	RNA_def_property_ui_text(prop, "Node Windows", "");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_SpaceTime_redraw_update");
 	
-	/* Other options */
-	
-	prop= RNA_def_property(srna, "continue_physics", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "redraws", TIME_CONTINUE_PHYSICS);
-	RNA_def_property_ui_text(prop, "Continue Physics", "During playblack, continue physics simulations regardless of the frame number");	
-	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
-	
+	/* Other options */	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list