[Bf-blender-cvs] [18bc829] terrible_consequencer: Trim tool:

Antony Riakiotakis noreply at git.blender.org
Mon Oct 20 15:01:50 CEST 2014


Commit: 18bc829e5ea911fc29c502ee5bf2256d571c9159
Author: Antony Riakiotakis
Date:   Mon Oct 20 15:01:34 2014 +0200
Branches: terrible_consequencer
https://developer.blender.org/rB18bc829e5ea911fc29c502ee5bf2256d571c9159

Trim tool:

Support metastrips and multiple strips at once.

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

M	source/blender/editors/space_sequencer/sequencer_edit.c

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

diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 65e4aa0..be87b76 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1722,143 +1722,227 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot)
 typedef struct TrimData {
 	int init_mouse[2];
 	float init_mouseloc[2];
-	TransSeq ts;
+	TransSeq *ts;
+	Sequence **seq_array;
+	bool *trim;
+	int num_seq;
 	bool slow;
 	int slow_offset; /* offset at the point where offset was turned on */
-	Sequence *seq;
 	void *draw_handle;
 } TrimData;
 
+static void transseq_backup(TransSeq *ts, Sequence *seq)
+{
+	ts->start = seq->start;
+	ts->machine = seq->machine;
+	ts->startstill = seq->startstill;
+	ts->endstill = seq->endstill;
+	ts->startdisp = seq->startdisp;
+	ts->enddisp = seq->enddisp;
+	ts->startofs = seq->startofs;
+	ts->endofs = seq->endofs;
+	ts->anim_startofs = seq->anim_startofs;
+	ts->anim_endofs = seq->anim_endofs;
+	ts->len = seq->len;
+}
+
+
+static void transseq_restore(TransSeq *ts, Sequence *seq)
+{
+	seq->start = ts->start;
+	seq->machine = ts->machine;
+	seq->startstill = ts->startstill;
+	seq->endstill = ts->endstill;
+	seq->startdisp = ts->startdisp;
+	seq->enddisp = ts->enddisp;
+	seq->startofs = ts->startofs;
+	seq->endofs = ts->endofs;
+	seq->anim_startofs = ts->anim_startofs;
+	seq->anim_endofs = ts->anim_endofs;
+	seq->len = ts->len;
+}
+
 static void draw_trim_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;
-	Sequence *seq = ((TrimData *)data)->seq;
-	
-	if (seq->type >= SEQ_TYPE_EFFECT) return;
+	TrimData *td = data;
+	int i;
 
-	x1 = seq->startdisp;
-	x2 = seq->enddisp;
-	
-	y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
-	y2 = seq->machine + SEQ_STRIP_OFSTOP;
+	for (i = 0; i < td->num_seq; i++) {
+		Sequence *seq = td->seq_array[i];
 
-	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->type != SEQ_TYPE_META) && td->trim[i]) {
 
-	if (seq->startofs) {
-		glEnable(GL_BLEND);
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-		
-		get_seq_color3ubv(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);
+			x1 = seq->startdisp;
+			x2 = seq->enddisp;
 
-		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);
-		
-		get_seq_color3ubv(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);
+			y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+			y2 = seq->machine + SEQ_STRIP_OFSTOP;
 
-		fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
-		
-		glDisable(GL_BLEND);
+			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);
+
+				get_seq_color3ubv(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);
+
+				get_seq_color3ubv(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) {
+				get_seq_color3ubv(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) {
+				get_seq_color3ubv(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);
+				}
+			}
+		}
 	}
-	if (seq->startstill) {
-		get_seq_color3ubv(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);
+}
+
+static int trim_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim) {
+	Sequence *seq;
+	int num_items = 0;
+
+	for (seq = seqbasep->first; seq; seq = seq->next) {
+		if (((seq->type & SEQ_TYPE_EFFECT) == 0) && (seq->flag & SELECT)) {
+			if (seq->type == SEQ_TYPE_META) {
+				/* trim the sub-sequences */
+				num_items += trim_add_sequences_rec(&seq->seqbase, seq_array, trim, num_items + offset, false);
+			}
+			else {
+				seq_array[offset + num_items] = seq;
+				trim[offset + num_items] = do_trim;
+				num_items++;
+			}
 		}
 	}
-	if (seq->endstill) {
-		get_seq_color3ubv(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);
+
+	return num_items;
+}
+
+static int trim_count_sequences_rec(ListBase *seqbasep) {
+	Sequence *seq;
+	int trimmed_sequences = 0;
+
+	for (seq = seqbasep->first; seq; seq = seq->next) {
+		if (((seq->type & SEQ_TYPE_EFFECT) == 0) && (seq->flag & SELECT)) {
+			if (seq->type == SEQ_TYPE_META) {
+				/* trim the sub-sequences */
+				trimmed_sequences += trim_count_sequences_rec(&seq->seqbase);
+			}
+			else {
+				trimmed_sequences++;
+			}
 		}
 	}
+
+	return trimmed_sequences;
 }
 
 static int sequencer_trim_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
-	TrimData *data = op->customdata = MEM_mallocN(sizeof(TrimData), "trimdata");	
+	TrimData *data;
 	Scene *scene = CTX_data_scene(C);
-	Sequence *seq = BKE_sequencer_active_get(scene);
+	Editing *ed = BKE_sequencer_editing_get(scene, false);
 	ARegion *ar = CTX_wm_region(C);
 	float mouseloc[2];
+	int num_seq, i;
 	View2D *v2d = UI_view2d_fromcontext(C);
 
-	/* backup values */
-	data->ts.start = seq->start;
-	data->ts.machine = seq->machine;
-	data->ts.startstill = seq->startstill;
-	data->ts.endstill = seq->endstill;
-	data->ts.startdisp = seq->startdisp;
-	data->ts.enddisp = seq->enddisp;
-	data->ts.startofs = seq->startofs;
-	data->ts.endofs = seq->endofs;
-	data->ts.anim_startofs = seq->anim_startofs;
-	data->ts.anim_endofs = seq->anim_endofs;
-	data->ts.len = seq->len;
-	data->seq = seq;
+	/* first recursively cound the trimmed elements */
+	num_seq = trim_count_sequences_rec(ed->seqbasep

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list