[Bf-blender-cvs] [ab4da07] terrible_consequencer: Add simple code to add (ctrl-P) and display parents. (WIP)

Antony Riakiotakis noreply at git.blender.org
Fri Aug 15 16:58:42 CEST 2014


Commit: ab4da07b76c3b025204aa1a4250ab1d470666b7f
Author: Antony Riakiotakis
Date:   Fri Aug 15 16:58:30 2014 +0200
Branches: terrible_consequencer
https://developer.blender.org/rBab4da07b76c3b025204aa1a4250ab1d470666b7f

Add simple code to add (ctrl-P) and display parents. (WIP)

This is not a serious attempt though and possibly a good solution should
go through a dependency graph. Also there are some crashes on undo.

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

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
M	source/blender/editors/space_sequencer/sequencer_ops.c
M	source/blender/makesdna/DNA_sequence_types.h

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

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index c0cbe09..aa8dc67 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -630,6 +630,11 @@ static char strip_color_storage[36][3];
 const static unsigned short strip_element_buffer[] = {9, 10, 8, 11, 7, 12, 6, 13, 5, 14, 4, 15, 3, 16, 2, 17, 1, 18, 0, 19, 35, 20,
                                        34, 21, 33, 22, 32, 23, 31, 24, 30, 25, 29, 26, 28, 27};
 
+static float calculate_cuddly_radius_x(float x1, float x2, float h, float aspect)
+{
+	return 0.5f * min_ff(h * 0.25f / aspect, (x2 - x1));	
+}
+
 static void generate_strip_vertices(float x1, float y1, float x2, float y2, float aspect)
 {
 	float ymid1, ymid2;
@@ -637,7 +642,8 @@ static void generate_strip_vertices(float x1, float y1, float x2, float y2, floa
 	int i;
 	float h = (y2 - y1);
 	float cuddly_radius = h * 0.25f;
-	float cuddly_radius_x = 0.5f * min_ff(cuddly_radius / aspect, (x2 - x1));
+	float cuddly_radius_x = calculate_cuddly_radius_x(x1, x2, h, aspect);
+	
 	ymid1 = h * 0.25f + y1;
 	ymid2 = h * 0.65f + y1;
 
@@ -804,7 +810,7 @@ static void draw_shaded_cuddly_strip(Sequence *seq, unsigned char col[3])
 static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline_tint, float pixelx, float aspect)
 {
 	View2D *v2d = &ar->v2d;
-	float x1, x2, y1, y2;
+	float x1, x2, y1, y2, xchild;
 	unsigned char col[3], background_col[3], is_single_image;
 	const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
 
@@ -817,6 +823,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
 	x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
 	y2 = seq->machine + SEQ_STRIP_OFSTOP;
 
+	xchild = x1 + calculate_cuddly_radius_x(x1, x2, SEQ_STRIP_OFSTOP - SEQ_STRIP_OFSBOTTOM, aspect);
 	/* get the correct color per strip type*/
 	//get_seq_color3ubv(scene, seq, col);
 	get_seq_color3ubv(scene, seq, background_col);
@@ -925,6 +932,37 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
 	if ((x2 - x1) / pixelx > 32) {
 		draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col);
 	}
+	
+	/* lastly, draw strip parent indicator */
+	if (seq->parent && seq->parent->machine != seq->machine) {
+		Sequence *parent = seq->parent;
+		float x1_par, x2_par, xpar;
+		float ypar, yseq;
+		x1_par = (parent->startstill) ? parent->start : parent->startdisp;
+		x2_par = (parent->endstill) ? (parent->start + parent->len) : parent->enddisp;
+		y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+		y2 = seq->machine + SEQ_STRIP_OFSTOP;
+		
+		xpar = max_ff(x1_par + calculate_cuddly_radius_x(x1_par, x2_par, SEQ_STRIP_OFSTOP - SEQ_STRIP_OFSBOTTOM, aspect), xchild);
+		xpar = min_ff(x2_par, xpar);
+
+		if (seq->machine > parent->machine) {
+			yseq = seq->machine + SEQ_STRIP_OFSBOTTOM;
+			ypar = parent->machine + SEQ_STRIP_OFSTOP;
+		}		
+		else {
+			yseq = seq->machine + SEQ_STRIP_OFSTOP;
+			ypar = parent->machine + SEQ_STRIP_OFSBOTTOM;	
+		}
+		
+		glBegin(GL_TRIANGLES);
+		glColor3f(0.5f, 0.5f, 0.5f);
+		glVertex2f(xpar, ypar);
+		glColor3f(0.9f, 0.9f, 1.0f);
+		glVertex2f(xchild + 0.05f / aspect, yseq);
+		glVertex2f(xchild, yseq);
+		glEnd();
+	}
 }
 
 static Sequence *special_seq_update = NULL;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index dcf13db..5dcb5ca 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1231,6 +1231,46 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot)
 	RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be snapped", INT_MIN, INT_MAX);
 }
 
+static int sequencer_parent_exec(bContext *C, wmOperator *UNUSED(op))
+{
+	Scene *scene = CTX_data_scene(C);
+	
+	if (scene) {
+		Editing *ed = BKE_sequencer_editing_get(scene, false);
+		Sequence *seq, *active_seq = ed->act_seq;
+		
+		for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+			if (seq == active_seq)
+				continue;
+			
+			if (seq->flag & SELECT) {
+				seq->parent = active_seq;
+			}
+		}
+	}
+	
+	WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+	
+	return OPERATOR_FINISHED;
+}
+
+void SEQUENCER_OT_parent(struct wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Parent Strips";
+	ot->idname = "SEQUENCER_OT_parent";
+	ot->description = "";
+
+	/* api callbacks */
+	ot->exec = sequencer_parent_exec;
+	ot->poll = sequencer_edit_poll;
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+	
+}
+
+
 /* mute operator */
 static int sequencer_mute_exec(bContext *C, wmOperator *op)
 {
@@ -3270,4 +3310,3 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
 	                               WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES,
 	                               FILE_DEFAULTDISPLAY);
 }
-
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 60fc300..c4d90d4 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -99,6 +99,7 @@ void SEQUENCER_OT_images_separate(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_make(struct wmOperatorType *ot);
 void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot);
+void SEQUENCER_OT_parent(struct wmOperatorType *ot);
 
 void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot);
 void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index e69a02a..8b73608 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -53,6 +53,7 @@ void sequencer_operatortypes(void)
 	WM_operatortype_append(SEQUENCER_OT_mute);
 	WM_operatortype_append(SEQUENCER_OT_unmute);
 	WM_operatortype_append(SEQUENCER_OT_lock);
+	WM_operatortype_append(SEQUENCER_OT_parent);
 	WM_operatortype_append(SEQUENCER_OT_unlock);
 	WM_operatortype_append(SEQUENCER_OT_reload);
 	WM_operatortype_append(SEQUENCER_OT_refresh_all);
@@ -152,6 +153,8 @@ void sequencer_keymap(wmKeyConfig *keyconf)
 	kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0);
 	RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD);
 
+	kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_parent", PKEY, KM_PRESS, KM_CTRL, 0);
+	
 	kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
 	RNA_boolean_set(kmi->ptr, "unselected", false);
 	kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 4795048..44cbd89 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -160,6 +160,8 @@ typedef struct Sequence {
 
 	/* pointers for effects: */
 	struct Sequence *seq1, *seq2, *seq3;
+	
+	struct Sequence *parent; /* parent strip */
 
 	ListBase seqbase;       /* list of strips for metastrips */




More information about the Bf-blender-cvs mailing list