[Bf-blender-cvs] [c35f563] master: Separate sequence extension drawing routine so it can be reused (as part of an option or for tools)

Antony Riakiotakis noreply at git.blender.org
Mon Nov 24 21:11:53 CET 2014


Commit: c35f563bb7faddcfa46caf17248a487b315dabeb
Author: Antony Riakiotakis
Date:   Mon Nov 24 21:11:05 2014 +0100
Branches: master
https://developer.blender.org/rBc35f563bb7faddcfa46caf17248a487b315dabeb

Separate sequence extension drawing routine so it can be reused (as part
of an option or for tools)

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

M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_intern.h

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

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1235ba8..80e3a02 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -597,6 +597,111 @@ void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, f
 	}
 }
 
+void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq)
+{
+	float x1, x2, y1, y2, pixely, a;
+	unsigned char col[3], blendcol[3];
+	View2D *v2d = &ar->v2d;
+	
+	x1 = seq->startdisp;
+	x2 = seq->enddisp;
+	
+	y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+	y2 = seq->machine + SEQ_STRIP_OFSTOP;
+	
+	pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+	
+	if (pixely <= 0) return;  /* can happen when the view is split/resized */
+	
+	blendcol[0] = blendcol[1] = blendcol[2] = 120;
+	
+	if (seq->startofs) {
+		glEnable(GL_BLEND);
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		
+		color3ubv_from_seq(scene, seq, col);
+		
+		if (seq->flag & SELECT) {
+			UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
+			glColor4ub(col[0], col[1], col[2], 170);
+		}
+		else {
+			UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
+			glColor4ub(col[0], col[1], col[2], 110);
+		}
+		
+		glRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
+		
+		if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
+		else glColor4ub(col[0], col[1], col[2], 160);
+		
+		fdrawbox((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);  //outline
+		
+		glDisable(GL_BLEND);
+	}
+	if (seq->endofs) {
+		glEnable(GL_BLEND);
+		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		
+		color3ubv_from_seq(scene, seq, col);
+		
+		if (seq->flag & SELECT) {
+			UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
+			glColor4ub(col[0], col[1], col[2], 170);
+		}
+		else {
+			UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
+			glColor4ub(col[0], col[1], col[2], 110);
+		}
+		
+		glRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
+		
+		if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
+		else glColor4ub(col[0], col[1], col[2], 160);
+		
+		fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
+		
+		glDisable(GL_BLEND);
+	}
+	if (seq->startstill) {
+		color3ubv_from_seq(scene, seq, col);
+		UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
+		glColor3ubv((GLubyte *)col);
+		
+		draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
+		
+		/* feint pinstripes, helps see exactly which is extended and which isn't,
+			 * especially when the extension is very small */
+		if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
+		else UI_GetColorPtrShade3ubv(col, col, -16);
+		
+		glColor3ubv((GLubyte *)col);
+		
+		for (a = y1; a < y2; a += pixely * 2.0f) {
+			fdrawline(x1,  a,  (float)(seq->start),  a);
+		}
+	}
+	if (seq->endstill) {
+		color3ubv_from_seq(scene, seq, col);
+		UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
+		glColor3ubv((GLubyte *)col);
+		
+		draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2);
+		
+		/* feint pinstripes, helps see exactly which is extended and which isn't,
+			 * especially when the extension is very small */
+		if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
+		else UI_GetColorPtrShade3ubv(col, col, -16);
+		
+		glColor3ubv((GLubyte *)col);
+		
+		for (a = y1; a < y2; a += pixely * 2.0f) {
+			fdrawline((float)(seq->start + seq->len),  a,  x2,  a);
+		}
+	}
+}
+
+
 /*
  * Draw a sequence strip, bounds check already made
  * ARegion is currently only used to get the windows width in pixels
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 2525b5d..8c8b7c5 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1282,9 +1282,6 @@ static void transseq_restore(TransSeq *ts, Sequence *seq)
 static void draw_slip_extensions(const bContext *C, ARegion *ar, void *data)
 {
 	Scene *scene = CTX_data_scene(C);
-	float x1, x2, y1, y2, pixely, a;
-	unsigned char col[3], blendcol[3];
-	View2D *v2d = &ar->v2d;
 	SlipData *td = data;
 	int i;
 
@@ -1292,103 +1289,7 @@ static void draw_slip_extensions(const bContext *C, ARegion *ar, void *data)
 		Sequence *seq = td->seq_array[i];
 
 		if ((seq->type != SEQ_TYPE_META) && td->trim[i]) {
-
-			x1 = seq->startdisp;
-			x2 = seq->enddisp;
-
-			y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
-			y2 = seq->machine + SEQ_STRIP_OFSTOP;
-
-			pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
-
-			if (pixely <= 0) return;  /* can happen when the view is split/resized */
-
-			blendcol[0] = blendcol[1] = blendcol[2] = 120;
-
-			if (seq->startofs) {
-				glEnable(GL_BLEND);
-				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-				color3ubv_from_seq(scene, seq, col);
-
-				if (seq->flag & SELECT) {
-					UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
-					glColor4ub(col[0], col[1], col[2], 170);
-				}
-				else {
-					UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
-					glColor4ub(col[0], col[1], col[2], 110);
-				}
-
-				glRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
-
-				if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
-				else glColor4ub(col[0], col[1], col[2], 160);
-
-				fdrawbox((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);  //outline
-
-				glDisable(GL_BLEND);
-			}
-			if (seq->endofs) {
-				glEnable(GL_BLEND);
-				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-				color3ubv_from_seq(scene, seq, col);
-
-				if (seq->flag & SELECT) {
-					UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
-					glColor4ub(col[0], col[1], col[2], 170);
-				}
-				else {
-					UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
-					glColor4ub(col[0], col[1], col[2], 110);
-				}
-
-				glRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
-
-				if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
-				else glColor4ub(col[0], col[1], col[2], 160);
-
-				fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
-
-				glDisable(GL_BLEND);
-			}
-			if (seq->startstill) {
-				color3ubv_from_seq(scene, seq, col);
-				UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
-				glColor3ubv((GLubyte *)col);
-
-				draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
-
-				/* feint pinstripes, helps see exactly which is extended and which isn't,
-				 * especially when the extension is very small */
-				if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
-				else UI_GetColorPtrShade3ubv(col, col, -16);
-
-				glColor3ubv((GLubyte *)col);
-
-				for (a = y1; a < y2; a += pixely * 2.0f) {
-					fdrawline(x1,  a,  (float)(seq->start),  a);
-				}
-			}
-			if (seq->endstill) {
-				color3ubv_from_seq(scene, seq, col);
-				UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
-				glColor3ubv((GLubyte *)col);
-
-				draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2);
-
-				/* feint pinstripes, helps see exactly which is extended and which isn't,
-				 * especially when the extension is very small */
-				if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
-				else UI_GetColorPtrShade3ubv(col, col, -16);
-
-				glColor3ubv((GLubyte *)col);
-
-				for (a = y1; a < y2; a += pixely * 2.0f) {
-					fdrawline((float)(seq->start + seq->len),  a,  x2,  a);
-				}
-			}
+			draw_sequence_extensions(scene, ar, seq);
 		}
 	}
 }
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index f3723b7..4e11b4d 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -56,6 +56,7 @@ void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
 void draw_image_seq(const struct bContext *C, struct Scene *scene, struct  ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, bool draw_overlay, bool draw_backdrop);
 void color3ubv_from_seq(struct Scene *curscene, struct Sequence *seq, unsigned char col[3]);
 void draw_shadedstrip(struct Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2);
+void draw_sequence_extensions(struct Scene *scene, struct ARegion *ar, struct Sequence *seq);
 
 /* UNUSED */
 // void seq_reset_imageofs(struct SpaceSeq *sseq);




More information about the Bf-blender-cvs mailing list