[Bf-blender-cvs] [c9fc11a3146] blender2.8: AnimEditors: Draw start/end frame ranges on all timelines by default

Joshua Leung noreply at git.blender.org
Fri Apr 20 19:06:43 CEST 2018


Commit: c9fc11a314662dd0ed1b9fb9de4d057b2cf2f1b3
Author: Joshua Leung
Date:   Thu Apr 19 18:03:15 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc9fc11a314662dd0ed1b9fb9de4d057b2cf2f1b3

AnimEditors: Draw start/end frame ranges on all timelines by default

This uses the global scene range, with styling matching the sequencer's start/end
frame drawing.

(The graph editor's "drivers" mode is exempt, as that doesn't really display time
in a linear way, so the start/end frames don't apply)

===================================================================

M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_nla/space_nla.c

===================================================================

diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 9a07eaf896c..d903d8d9235 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -184,6 +184,48 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 	}
 }
 
+/* *************************************************** */
+/* SCENE FRAME RANGE */
+
+/* Draw frame range guides (for scene frame range) in background */
+// TODO: Should we still show these when preview range is enabled?
+void ANIM_draw_framerange(Scene *scene, View2D *v2d)
+{	
+	/* draw darkened area outside of active timeline frame range */
+	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+	glEnable(GL_BLEND);
+
+	Gwn_VertFormat *format = immVertexFormat();
+	unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
+
+	if (SFRA < EFRA) {
+		immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+		immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+	}
+	else {
+		immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+	}
+
+	glDisable(GL_BLEND);
+
+	/* thin lines where the actual frames are */
+	immUniformThemeColorShade(TH_BACK, -60);
+
+	immBegin(GWN_PRIM_LINES, 4);
+
+	immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
+	immVertex2f(pos, (float)SFRA, v2d->cur.ymax);
+
+	immVertex2f(pos, (float)EFRA, v2d->cur.ymin);
+	immVertex2f(pos, (float)EFRA, v2d->cur.ymax);
+
+	immEnd();
+	immUnbindProgram();
+}
+
 /* *************************************************** */
 /* NLA-MAPPING UTILITIES (required for drawing and also editing keyframes)  */
 
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index edcdb868ea4..888e9e04636 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -551,6 +551,12 @@ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
 /* main call to draw preview range curtains */
 void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d, int end_frame_width);
 
+
+/* -------------- Frame Range Drawing --------------- */
+
+/* main call to draw normal frame range indicators */
+void ANIM_draw_framerange(struct Scene *scene, struct View2D *v2d);
+
 /* ************************************************* */
 /* F-MODIFIER TOOLS */
 
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 29c53815b3a..6ec6f0561c2 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -39,6 +39,7 @@ struct SpaceAction;
 struct ScrArea;
 struct ARegion;
 struct ARegionType;
+struct View2D;
 struct wmOperatorType;
 
 /* internal exports only */
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index b171b2e9b8a..6b95f9c41c4 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -34,6 +34,7 @@
 
 #include "DNA_action_types.h"
 #include "DNA_group_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
 #include "MEM_guardedalloc.h"
@@ -212,6 +213,8 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
 {
 	/* draw entirely, view changes should be handled here */
 	SpaceAction *saction = CTX_wm_space_action(C);
+	Scene *scene = CTX_data_scene(C);
+	Object *obact = CTX_data_active_object(C);
 	bAnimContext ac;
 	View2D *v2d = &ar->v2d;
 	View2DGrid *grid;
@@ -231,7 +234,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
 	UI_view2d_grid_free(grid);
 	
 	ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+	
+	/* start and end frame */
+	ANIM_draw_framerange(scene, v2d);
+	
 	/* data */
 	if (ANIM_animdata_get_context(C, &ac)) {
 		draw_channel_strips(&ac, saction, ar);
@@ -250,11 +256,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
 	
 	/* caches */
 	if (saction->mode == SACTCONT_TIMELINE) {
-		timeline_draw_cache(saction, ac.obact, ac.scene);
+		timeline_draw_cache(saction, obact, scene);
 	}
 	
 	/* preview range */
-	// XXX: we should always draw the range
 	UI_view2d_view_ortho(v2d);
 	ANIM_draw_previewrange(C, v2d, 0);
 
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index a424084f6b1..1a09487acee 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -226,6 +226,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
 {
 	/* draw entirely, view changes should be handled here */
 	SpaceIpo *sipo = CTX_wm_space_graph(C);
+	Scene *scene = CTX_data_scene(C);
 	bAnimContext ac;
 	View2D *v2d = &ar->v2d;
 	View2DGrid *grid;
@@ -246,7 +247,12 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
 	UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
 	
 	ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+	
+	/* start and end frame (in F-Curve mode only) */
+	if (sipo->mode != SIPO_MODE_DRIVERS) {
+		ANIM_draw_framerange(scene, v2d);
+	}
+	
 	/* draw data */
 	if (ANIM_animdata_get_context(C, &ac)) {
 		/* draw ghost curves */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 08ac7c8973e..4e189682153 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -268,6 +268,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
 {
 	/* draw entirely, view changes should be handled here */
 	SpaceNla *snla = CTX_wm_space_nla(C);
+	Scene *scene = CTX_data_scene(C);
 	bAnimContext ac;
 	View2D *v2d = &ar->v2d;
 	View2DGrid *grid;
@@ -287,7 +288,10 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
 	UI_view2d_grid_free(grid);
 	
 	ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
+	
+	/* start and end frame */
+	ANIM_draw_framerange(scene, v2d);
+	
 	/* data */
 	if (ANIM_animdata_get_context(C, &ac)) {
 		/* strips and backdrops */



More information about the Bf-blender-cvs mailing list