basic transform for sequencer strips
can transform the strips or move their handles Still todo, click-drag transform, metastrips support, snapping, markers overlap checks and constrain to valid channels.
This commit is contained in:
		@@ -166,3 +166,14 @@ void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq
 | 
			
		||||
// extern
 | 
			
		||||
struct SeqEffectHandle get_sequence_effect(struct Sequence *seq);
 | 
			
		||||
int get_sequence_effect_num_inputs(int seq_type);
 | 
			
		||||
 | 
			
		||||
/* for transform but also could use elsewhere */
 | 
			
		||||
int seq_tx_get_start(struct Sequence *seq);
 | 
			
		||||
int seq_tx_get_end(struct Sequence *seq);
 | 
			
		||||
int seq_tx_get_final_left(struct Sequence *seq, int metaclip);
 | 
			
		||||
int seq_tx_get_final_right(struct Sequence *seq, int metaclip);
 | 
			
		||||
void seq_tx_set_final_left(struct Sequence *seq, int val);
 | 
			
		||||
void seq_tx_set_final_right(struct Sequence *seq, int val);
 | 
			
		||||
void seq_tx_handle_xlimits(struct Sequence *seq, int leftflag, int rightflag);
 | 
			
		||||
int check_single_seq(struct Sequence *seq);
 | 
			
		||||
void fix_single_seq(struct Sequence *seq);
 | 
			
		||||
 
 | 
			
		||||
@@ -3064,3 +3064,132 @@ void do_render_seq(RenderResult *rr, int cfra)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* seq funcs's for transforming internally
 | 
			
		||||
 notice the difference between start/end and left/right.
 | 
			
		||||
 | 
			
		||||
 left and right are the bounds at which the sequence is rendered,
 | 
			
		||||
start and end are from the start and fixed length of the sequence.
 | 
			
		||||
*/
 | 
			
		||||
int seq_tx_get_start(Sequence *seq) {
 | 
			
		||||
	return seq->start;
 | 
			
		||||
}
 | 
			
		||||
int seq_tx_get_end(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	return seq->start+seq->len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int seq_tx_get_final_left(Sequence *seq, int metaclip)
 | 
			
		||||
{
 | 
			
		||||
	if (metaclip && seq->tmp) {
 | 
			
		||||
		/* return the range clipped by the parents range */
 | 
			
		||||
		return MAX2( seq_tx_get_final_left(seq, 0), seq_tx_get_final_left((Sequence *)seq->tmp, 1) );
 | 
			
		||||
	} else {
 | 
			
		||||
		return (seq->start - seq->startstill) + seq->startofs;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
int seq_tx_get_final_right(Sequence *seq, int metaclip)
 | 
			
		||||
{
 | 
			
		||||
	if (metaclip && seq->tmp) {
 | 
			
		||||
		/* return the range clipped by the parents range */
 | 
			
		||||
		return MIN2( seq_tx_get_final_right(seq, 0), seq_tx_get_final_right((Sequence *)seq->tmp, 1) );
 | 
			
		||||
	} else {
 | 
			
		||||
		return ((seq->start+seq->len) + seq->endstill) - seq->endofs;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void seq_tx_set_final_left(Sequence *seq, int val)
 | 
			
		||||
{
 | 
			
		||||
	if (val < (seq)->start) {
 | 
			
		||||
		seq->startstill = abs(val - (seq)->start);
 | 
			
		||||
				(seq)->startofs = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		seq->startofs = abs(val - (seq)->start);
 | 
			
		||||
		seq->startstill = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void seq_tx_set_final_right(Sequence *seq, int val)
 | 
			
		||||
{
 | 
			
		||||
	if (val > (seq)->start + (seq)->len) {
 | 
			
		||||
		seq->endstill = abs(val - (seq->start + (seq)->len));
 | 
			
		||||
		(seq)->endofs = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		seq->endofs = abs(val - ((seq)->start + (seq)->len));
 | 
			
		||||
		seq->endstill = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* used so we can do a quick check for single image seq
 | 
			
		||||
   since they work a bit differently to normal image seq's (during transform) */
 | 
			
		||||
int check_single_seq(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR))
 | 
			
		||||
		return 1;
 | 
			
		||||
	else
 | 
			
		||||
		return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* use to impose limits when dragging/extending - so impossible situations dont happen
 | 
			
		||||
 * Cant use the SEQ_LEFTSEL and SEQ_LEFTSEL directly because the strip may be in a metastrip */
 | 
			
		||||
void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
 | 
			
		||||
{
 | 
			
		||||
	if(leftflag) {
 | 
			
		||||
		if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_final_right(seq, 0)) {
 | 
			
		||||
			seq_tx_set_final_left(seq, seq_tx_get_final_right(seq, 0)-1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (check_single_seq(seq)==0) {
 | 
			
		||||
			if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_end(seq)) {
 | 
			
		||||
				seq_tx_set_final_left(seq, seq_tx_get_end(seq)-1);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			/* dosnt work now - TODO */
 | 
			
		||||
			/*
 | 
			
		||||
			if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) {
 | 
			
		||||
				int ofs;
 | 
			
		||||
				ofs = seq_tx_get_start(seq) - seq_tx_get_final_right(seq, 0);
 | 
			
		||||
				seq->start -= ofs;
 | 
			
		||||
				seq_tx_set_final_left(seq, seq_tx_get_final_left(seq, 0) + ofs );
 | 
			
		||||
			}*/
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(rightflag) {
 | 
			
		||||
		if (seq_tx_get_final_right(seq, 0) <=  seq_tx_get_final_left(seq, 0)) {
 | 
			
		||||
			seq_tx_set_final_right(seq, seq_tx_get_final_left(seq, 0)+1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (check_single_seq(seq)==0) {
 | 
			
		||||
			if (seq_tx_get_final_right(seq, 0) <= seq_tx_get_start(seq)) {
 | 
			
		||||
				seq_tx_set_final_right(seq, seq_tx_get_start(seq)+1);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* sounds cannot be extended past their endpoints */
 | 
			
		||||
	if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) {
 | 
			
		||||
		seq->startstill= 0;
 | 
			
		||||
		seq->endstill= 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fix_single_seq(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	int left, start, offset;
 | 
			
		||||
	if (!check_single_seq(seq))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* make sure the image is always at the start since there is only one,
 | 
			
		||||
	   adjusting its start should be ok */
 | 
			
		||||
	left = seq_tx_get_final_left(seq, 0);
 | 
			
		||||
	start = seq->start;
 | 
			
		||||
	if (start != left) {
 | 
			
		||||
		offset = left - start;
 | 
			
		||||
		seq_tx_set_final_left( seq, seq_tx_get_final_left(seq, 0) - offset );
 | 
			
		||||
		seq_tx_set_final_right( seq, seq_tx_get_final_right(seq, 0) - offset );
 | 
			
		||||
		seq->start += offset;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -997,7 +997,7 @@ static int sequencer_add_color_strip_exec(bContext *C, wmOperator *op)
 | 
			
		||||
	
 | 
			
		||||
	/* basic defaults */
 | 
			
		||||
	seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
 | 
			
		||||
	strip->len = seq->len = end_frame-start_frame; /* Color strips are different in that they can be any length */
 | 
			
		||||
	strip->len = seq->len = 1; /* Color strips are different in that they can be any length */
 | 
			
		||||
	strip->us= 1;
 | 
			
		||||
	
 | 
			
		||||
	strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
 | 
			
		||||
@@ -1005,6 +1005,8 @@ static int sequencer_add_color_strip_exec(bContext *C, wmOperator *op)
 | 
			
		||||
	RNA_string_get(op->ptr, "name", seq->name);
 | 
			
		||||
	RNA_float_get_array(op->ptr, "color", colvars->col);
 | 
			
		||||
	
 | 
			
		||||
	seq_tx_set_final_right(seq, end_frame);
 | 
			
		||||
 | 
			
		||||
	calc_sequence_disp(seq);
 | 
			
		||||
	sort_seq(scene);
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -158,62 +158,6 @@ Sequence *get_forground_frame_seq(Scene *scene, int frame)
 | 
			
		||||
	return best_seq;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* seq funcs's for transforming internally
 | 
			
		||||
 notice the difference between start/end and left/right.
 | 
			
		||||
 
 | 
			
		||||
 left and right are the bounds at which the sequence is rendered,
 | 
			
		||||
start and end are from the start and fixed length of the sequence.
 | 
			
		||||
*/
 | 
			
		||||
int seq_tx_get_start(Sequence *seq) {
 | 
			
		||||
	return seq->start;
 | 
			
		||||
}
 | 
			
		||||
int seq_tx_get_end(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	return seq->start+seq->len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int seq_tx_get_final_left(Sequence *seq, int metaclip)
 | 
			
		||||
{
 | 
			
		||||
	if (metaclip && seq->tmp) {
 | 
			
		||||
		/* return the range clipped by the parents range */
 | 
			
		||||
		return MAX2( seq_tx_get_final_left(seq, 0), seq_tx_get_final_left((Sequence *)seq->tmp, 1) );
 | 
			
		||||
	} else {
 | 
			
		||||
		return (seq->start - seq->startstill) + seq->startofs;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
int seq_tx_get_final_right(Sequence *seq, int metaclip)
 | 
			
		||||
{
 | 
			
		||||
	if (metaclip && seq->tmp) {
 | 
			
		||||
		/* return the range clipped by the parents range */
 | 
			
		||||
		return MIN2( seq_tx_get_final_right(seq, 0), seq_tx_get_final_right((Sequence *)seq->tmp, 1) );
 | 
			
		||||
	} else {
 | 
			
		||||
		return ((seq->start+seq->len) + seq->endstill) - seq->endofs;	
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void seq_tx_set_final_left(Sequence *seq, int val)
 | 
			
		||||
{
 | 
			
		||||
	if (val < (seq)->start) {
 | 
			
		||||
		seq->startstill = abs(val - (seq)->start);
 | 
			
		||||
				(seq)->startofs = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		seq->startofs = abs(val - (seq)->start);
 | 
			
		||||
		seq->startstill = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void seq_tx_set_final_right(Sequence *seq, int val)
 | 
			
		||||
{
 | 
			
		||||
	if (val > (seq)->start + (seq)->len) {
 | 
			
		||||
		seq->endstill = abs(val - (seq->start + (seq)->len));
 | 
			
		||||
		(seq)->endofs = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		seq->endofs = abs(val - ((seq)->start + (seq)->len));
 | 
			
		||||
		seq->endstill = 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* check if one side can be transformed */
 | 
			
		||||
int seq_tx_check_left(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
@@ -251,34 +195,6 @@ void seq_rectf(Sequence *seq, rctf *rectf)
 | 
			
		||||
	rectf->ymax= seq->machine+0.8;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* used so we can do a quick check for single image seq
 | 
			
		||||
   since they work a bit differently to normal image seq's (during transform) */
 | 
			
		||||
int check_single_seq(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR))
 | 
			
		||||
		return 1;
 | 
			
		||||
	else
 | 
			
		||||
		return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void fix_single_image_seq(Sequence *seq)
 | 
			
		||||
{
 | 
			
		||||
	int left, start, offset;
 | 
			
		||||
	if (!check_single_seq(seq))
 | 
			
		||||
		return;
 | 
			
		||||
	
 | 
			
		||||
	/* make sure the image is always at the start since there is only one,
 | 
			
		||||
	   adjusting its start should be ok */
 | 
			
		||||
	left = seq_tx_get_final_left(seq, 0);
 | 
			
		||||
	start = seq->start;
 | 
			
		||||
	if (start != left) {
 | 
			
		||||
		offset = left - start;
 | 
			
		||||
		seq_tx_set_final_left( seq, seq_tx_get_final_left(seq, 0) - offset );
 | 
			
		||||
		seq_tx_set_final_right( seq, seq_tx_get_final_right(seq, 0) - offset );
 | 
			
		||||
		seq->start += offset;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int test_overlap_seq(Scene *scene, Sequence *test)
 | 
			
		||||
{
 | 
			
		||||
	Sequence *seq;
 | 
			
		||||
@@ -1824,50 +1740,6 @@ static int seq_get_snaplimit(View2D *v2d)
 | 
			
		||||
	return (int)(x - xmouse);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* use to impose limits when dragging/extending - so impossible situations dont happen */
 | 
			
		||||
static void transform_grab_xlimits(Sequence *seq, int leftflag, int rightflag)
 | 
			
		||||
{
 | 
			
		||||
	if(leftflag) {
 | 
			
		||||
		if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_final_right(seq, 0)) {
 | 
			
		||||
			seq_tx_set_final_left(seq, seq_tx_get_final_right(seq, 0)-1);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (check_single_seq(seq)==0) {
 | 
			
		||||
			if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_end(seq)) {
 | 
			
		||||
				seq_tx_set_final_left(seq, seq_tx_get_end(seq)-1);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			/* dosnt work now - TODO */
 | 
			
		||||
			/*
 | 
			
		||||
			if (seq_tx_get_start(seq) >= seq_tx_get_final_right(seq, 0)) {
 | 
			
		||||
				int ofs;
 | 
			
		||||
				ofs = seq_tx_get_start(seq) - seq_tx_get_final_right(seq, 0);
 | 
			
		||||
				seq->start -= ofs;
 | 
			
		||||
				seq_tx_set_final_left(seq, seq_tx_get_final_left(seq, 0) + ofs );
 | 
			
		||||
			}*/
 | 
			
		||||
			
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	if(rightflag) {
 | 
			
		||||
		if (seq_tx_get_final_right(seq, 0) <=  seq_tx_get_final_left(seq, 0)) {
 | 
			
		||||
			seq_tx_set_final_right(seq, seq_tx_get_final_left(seq, 0)+1);
 | 
			
		||||
		}
 | 
			
		||||
									
 | 
			
		||||
		if (check_single_seq(seq)==0) {
 | 
			
		||||
			if (seq_tx_get_final_right(seq, 0) <= seq_tx_get_start(seq)) {
 | 
			
		||||
				seq_tx_set_final_right(seq, seq_tx_get_start(seq)+1);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/* sounds cannot be extended past their endpoints */
 | 
			
		||||
	if (seq->type == SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND) {
 | 
			
		||||
		seq->startstill= 0;
 | 
			
		||||
		seq->endstill= 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int can_transform_seq_test_func(Sequence * seq)
 | 
			
		||||
{
 | 
			
		||||
	if((seq->flag & SELECT) && !(seq->depth==0 && seq->flag & SEQ_LOCK)) {
 | 
			
		||||
@@ -2171,7 +2043,7 @@ void transform_seq(Scene *scene, SpaceSeq *sseq, View2D *v2d, int mode, int cont
 | 
			
		||||
							myofs = (ts->endstill - ts->endofs);
 | 
			
		||||
							seq_tx_set_final_right(seq, ts->start + seq->len + (myofs + ix));
 | 
			
		||||
						}
 | 
			
		||||
						transform_grab_xlimits(seq, sel_flag & SEQ_LEFTSEL, sel_flag & SEQ_RIGHTSEL);
 | 
			
		||||
						seq_tx_handle_xlimits(seq, sel_flag & SEQ_LEFTSEL, sel_flag & SEQ_RIGHTSEL);
 | 
			
		||||
						
 | 
			
		||||
						if( (sel_flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0 ) {
 | 
			
		||||
							if(sequence_is_free_transformable(seq)) seq->start= ts->start+ ix;
 | 
			
		||||
@@ -2247,7 +2119,7 @@ void transform_seq(Scene *scene, SpaceSeq *sseq, View2D *v2d, int mode, int cont
 | 
			
		||||
										also include the startstill so the contense dosnt go outside the bounds, 
 | 
			
		||||
										if the seq->startofs is 0 then its ignored */
 | 
			
		||||
										
 | 
			
		||||
										/* TODO remove, add check to transform_grab_xlimits, works ok for now */
 | 
			
		||||
										/* TODO remove, add check to seq_tx_handle_xlimits, works ok for now */
 | 
			
		||||
										if (xnew + seq->startstill > final_right-1) {
 | 
			
		||||
											xnew = (final_right-1) - seq->startstill;
 | 
			
		||||
										}
 | 
			
		||||
@@ -2258,7 +2130,7 @@ void transform_seq(Scene *scene, SpaceSeq *sseq, View2D *v2d, int mode, int cont
 | 
			
		||||
										/* done with unique stuff */
 | 
			
		||||
										
 | 
			
		||||
										seq_tx_set_final_left(seq, xnew);
 | 
			
		||||
										transform_grab_xlimits(seq, 1, 0);
 | 
			
		||||
										seq_tx_handle_xlimits(seq, 1, 0);
 | 
			
		||||
										
 | 
			
		||||
										/* Special case again - setting the end back to what it was */
 | 
			
		||||
										seq_tx_set_final_right(seq, final_right);
 | 
			
		||||
@@ -2267,20 +2139,20 @@ void transform_seq(Scene *scene, SpaceSeq *sseq, View2D *v2d, int mode, int cont
 | 
			
		||||
										myofs = (ts->endstill - ts->endofs);
 | 
			
		||||
										xnew = ts->start + seq->len + (myofs + ix);
 | 
			
		||||
										seq_tx_set_final_right(seq, xnew);
 | 
			
		||||
										transform_grab_xlimits(seq, 0, 1);
 | 
			
		||||
										seq_tx_handle_xlimits(seq, 0, 1);
 | 
			
		||||
									}
 | 
			
		||||
								} else { /* R */
 | 
			
		||||
									if (move_left) {
 | 
			
		||||
										myofs = (ts->startofs - ts->startstill);
 | 
			
		||||
										xnew = ts->start + (myofs + ix);
 | 
			
		||||
										seq_tx_set_final_left(seq, xnew);
 | 
			
		||||
										transform_grab_xlimits(seq, 1, 0);
 | 
			
		||||
										seq_tx_handle_xlimits(seq, 1, 0);
 | 
			
		||||
									}
 | 
			
		||||
									if (move_right) {
 | 
			
		||||
										myofs = (ts->endstill - ts->endofs);
 | 
			
		||||
										xnew = ts->start + seq->len + (myofs + ix);
 | 
			
		||||
										seq_tx_set_final_right(seq, xnew);
 | 
			
		||||
										transform_grab_xlimits(seq, 0, 1);
 | 
			
		||||
										seq_tx_handle_xlimits(seq, 0, 1);
 | 
			
		||||
									}
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
@@ -2431,7 +2303,7 @@ void transform_seq(Scene *scene, SpaceSeq *sseq, View2D *v2d, int mode, int cont
 | 
			
		||||
			/* fixes single image strips - makes sure their start is not out of bounds
 | 
			
		||||
			ideally this would be done during transform since data is rendered at that time
 | 
			
		||||
			however it ends up being a lot messier! - Campbell */
 | 
			
		||||
			fix_single_image_seq(seq);
 | 
			
		||||
			fix_single_seq(seq);
 | 
			
		||||
			
 | 
			
		||||
			if(seq->type == SEQ_META) {
 | 
			
		||||
				calc_sequence(seq);
 | 
			
		||||
@@ -2574,7 +2446,7 @@ void seq_snap(Scene *scene, short event)
 | 
			
		||||
				} else { /* SEQ_RIGHTSEL */
 | 
			
		||||
					seq_tx_set_final_right(seq, CFRA);
 | 
			
		||||
				}
 | 
			
		||||
				transform_grab_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
 | 
			
		||||
				seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
 | 
			
		||||
			}
 | 
			
		||||
			calc_sequence(seq);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,8 @@
 | 
			
		||||
#include "BLI_arithb.h"
 | 
			
		||||
#include "BLI_blenlib.h"
 | 
			
		||||
 | 
			
		||||
#include "BIF_transform.h" /* transform keymap */
 | 
			
		||||
 | 
			
		||||
#include "BKE_context.h"
 | 
			
		||||
#include "BKE_global.h"
 | 
			
		||||
#include "BKE_utildefines.h"
 | 
			
		||||
@@ -116,5 +118,7 @@ void sequencer_keymap(wmWindowManager *wm)
 | 
			
		||||
	WM_keymap_add_item(keymap, "SEQUENCER_OT_borderselect", BKEY, KM_PRESS, 0, 0);
 | 
			
		||||
	
 | 
			
		||||
	WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
 | 
			
		||||
	
 | 
			
		||||
	transform_keymap_for_space(wm, keymap, SPACE_SEQ);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -187,13 +187,13 @@ static void sequencer_header_area_draw(const bContext *C, ARegion *ar)
 | 
			
		||||
 | 
			
		||||
static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn)
 | 
			
		||||
{
 | 
			
		||||
	/* context changes */
 | 
			
		||||
	/* context changes */
 | 
			
		||||
	switch(wmn->category) {
 | 
			
		||||
		case NC_SCENE:
 | 
			
		||||
			switch(wmn->data) {
 | 
			
		||||
				case ND_FRAME:
 | 
			
		||||
				case ND_MARKERS:
 | 
			
		||||
				case ND_SEQUENCER:
 | 
			
		||||
					ED_region_tag_redraw(ar);
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -221,6 +221,17 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
 | 
			
		||||
		divx= v2d->mask.xmax-v2d->mask.xmin;
 | 
			
		||||
		divy= v2d->mask.ymax-v2d->mask.ymin;
 | 
			
		||||
		
 | 
			
		||||
		vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
 | 
			
		||||
		vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
 | 
			
		||||
		vec[2]= 0.0f;
 | 
			
		||||
	}
 | 
			
		||||
	else if(t->spacetype==SPACE_SEQ) {
 | 
			
		||||
		View2D *v2d = &t->ar->v2d;
 | 
			
		||||
		float divx, divy;
 | 
			
		||||
 | 
			
		||||
		divx= v2d->mask.xmax-v2d->mask.xmin;
 | 
			
		||||
		divy= v2d->mask.ymax-v2d->mask.ymin;
 | 
			
		||||
 | 
			
		||||
		vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
 | 
			
		||||
		vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
 | 
			
		||||
		vec[2]= 0.0f;
 | 
			
		||||
@@ -339,6 +350,10 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
 | 
			
		||||
		//ED_area_tag_redraw(t->sa);
 | 
			
		||||
		WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
 | 
			
		||||
	}
 | 
			
		||||
	else if(t->spacetype == SPACE_SEQ)
 | 
			
		||||
	{
 | 
			
		||||
		WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL);
 | 
			
		||||
	}
 | 
			
		||||
#if 0 // TRANSFORM_FIX_ME
 | 
			
		||||
	else if (t->spacetype==SPACE_IMAGE) {
 | 
			
		||||
		if (G.sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
 | 
			
		||||
 
 | 
			
		||||
@@ -150,6 +150,11 @@ typedef struct TransDataCurveHandleFlags {
 | 
			
		||||
	char *h1, *h2;
 | 
			
		||||
} TransDataCurveHandleFlags;
 | 
			
		||||
 | 
			
		||||
/* for sequencer transform */
 | 
			
		||||
typedef struct TransDataSeq {
 | 
			
		||||
	struct Sequence *seq;
 | 
			
		||||
	short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */
 | 
			
		||||
} TransDataSeq;
 | 
			
		||||
 | 
			
		||||
typedef struct TransData {
 | 
			
		||||
	float  dist;         /* Distance needed to affect element (for Proportionnal Editing)                  */
 | 
			
		||||
@@ -438,6 +443,7 @@ void flushTransUVs(TransInfo *t);
 | 
			
		||||
void flushTransParticles(TransInfo *t);
 | 
			
		||||
int clipUVTransform(TransInfo *t, float *vec, int resize);
 | 
			
		||||
void flushTransNodes(TransInfo *t);
 | 
			
		||||
void flushTransSeq(TransInfo *t);
 | 
			
		||||
 | 
			
		||||
/*********************** exported from transform_manipulator.c ********** */
 | 
			
		||||
void draw_manipulator_ext(struct ScrArea *sa, int type, char axis, int col, float vec[3], float mat[][3]);
 | 
			
		||||
 
 | 
			
		||||
@@ -59,6 +59,7 @@
 | 
			
		||||
#include "DNA_scene_types.h"
 | 
			
		||||
#include "DNA_screen_types.h"
 | 
			
		||||
#include "DNA_space_types.h"
 | 
			
		||||
#include "DNA_sequence_types.h"
 | 
			
		||||
#include "DNA_texture_types.h"
 | 
			
		||||
#include "DNA_view3d_types.h"
 | 
			
		||||
#include "DNA_world_types.h"
 | 
			
		||||
@@ -91,6 +92,7 @@
 | 
			
		||||
#include "BKE_modifier.h"
 | 
			
		||||
#include "BKE_object.h"
 | 
			
		||||
#include "BKE_particle.h"
 | 
			
		||||
#include "BKE_sequence.h"
 | 
			
		||||
#include "BKE_pointcache.h"
 | 
			
		||||
#include "BKE_softbody.h"
 | 
			
		||||
#include "BKE_utildefines.h"
 | 
			
		||||
@@ -2300,6 +2302,48 @@ void flushTransNodes(TransInfo *t)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* *** SEQUENCE EDITOR *** */
 | 
			
		||||
void flushTransSeq(TransInfo *t)
 | 
			
		||||
{
 | 
			
		||||
	int a, new_frame;
 | 
			
		||||
	TransData *td= t->data;
 | 
			
		||||
	TransData2D *td2d= t->data2d;
 | 
			
		||||
	TransDataSeq *tdsq= NULL;
 | 
			
		||||
	Sequence *seq;
 | 
			
		||||
 | 
			
		||||
	/* flush to 2d vector from internally used 3d vector */
 | 
			
		||||
	for(a=0; a<t->total; a++, td++, td2d++) {
 | 
			
		||||
 | 
			
		||||
		tdsq= (TransDataSeq *)td->extra;
 | 
			
		||||
		seq= tdsq->seq;
 | 
			
		||||
		new_frame= (int)(td2d->loc[0] + 0.5f);
 | 
			
		||||
 | 
			
		||||
		/* TODO, only use seq flags for non nested strips
 | 
			
		||||
		 * seq_tx_handle_xlimits used below is only correct when your not using metastrips.
 | 
			
		||||
		 * meta children should ignore those flags
 | 
			
		||||
		 */
 | 
			
		||||
 | 
			
		||||
		switch (tdsq->sel_flag) {
 | 
			
		||||
		case SELECT:
 | 
			
		||||
			seq->start= new_frame;
 | 
			
		||||
			seq->machine= (int)(td2d->loc[1] + 0.5f);
 | 
			
		||||
			break;
 | 
			
		||||
		case SEQ_LEFTSEL: /* no vertical transform  */
 | 
			
		||||
			seq_tx_set_final_left(seq, new_frame);
 | 
			
		||||
			seq_tx_handle_xlimits(seq, seq->flag&SEQ_LEFTSEL, seq->flag&SEQ_RIGHTSEL);
 | 
			
		||||
			fix_single_seq(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
 | 
			
		||||
			break;
 | 
			
		||||
		case SEQ_RIGHTSEL: /* no vertical transform  */
 | 
			
		||||
			seq_tx_set_final_right(seq, new_frame);
 | 
			
		||||
			seq_tx_handle_xlimits(seq, seq->flag&SEQ_LEFTSEL, seq->flag&SEQ_RIGHTSEL);
 | 
			
		||||
			fix_single_seq(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		calc_sequence(seq);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ********************* UV ****************** */
 | 
			
		||||
 | 
			
		||||
static void UVsToTransData(TransData *td, TransData2D *td2d, float *uv, int selected)
 | 
			
		||||
@@ -3218,6 +3262,106 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static TransData *SeqToTransData(TransData *td, TransData2D *td2d, TransDataSeq *tdsq, Sequence *seq, int sel_flag)
 | 
			
		||||
{
 | 
			
		||||
	switch(sel_flag) {
 | 
			
		||||
	case SELECT:
 | 
			
		||||
		td2d->loc[0] = seq->start; /* hold original location */
 | 
			
		||||
		break;
 | 
			
		||||
	case SEQ_LEFTSEL:
 | 
			
		||||
		td2d->loc[0] = seq_tx_get_final_left(seq, 0);
 | 
			
		||||
		break;
 | 
			
		||||
	case SEQ_RIGHTSEL:
 | 
			
		||||
		td2d->loc[0] = seq_tx_get_final_right(seq, 0);
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	td2d->loc[1] = seq->machine; /* channel - Y location */
 | 
			
		||||
	td2d->loc[2] = 0.0f;
 | 
			
		||||
	td2d->loc2d = NULL;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	tdsq->sel_flag= sel_flag;
 | 
			
		||||
	tdsq->seq= seq;
 | 
			
		||||
	
 | 
			
		||||
	td->extra= (void *)tdsq; /* allow us to update the strip from here */
 | 
			
		||||
 | 
			
		||||
	td->flag = 0;
 | 
			
		||||
	td->loc = td2d->loc;
 | 
			
		||||
	VECCOPY(td->center, td->loc);
 | 
			
		||||
	VECCOPY(td->iloc, td->loc);
 | 
			
		||||
 | 
			
		||||
	memset(td->axismtx, 0, sizeof(td->axismtx));
 | 
			
		||||
	td->axismtx[2][2] = 1.0f;
 | 
			
		||||
 | 
			
		||||
	td->ext= NULL; td->tdi= NULL; td->val= NULL;
 | 
			
		||||
 | 
			
		||||
	td->flag |= TD_SELECTED;
 | 
			
		||||
	td->dist= 0.0;
 | 
			
		||||
 | 
			
		||||
	Mat3One(td->mtx);
 | 
			
		||||
	Mat3One(td->smtx);
 | 
			
		||||
 | 
			
		||||
	return td;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void createTransSeqData(bContext *C, TransInfo *t)
 | 
			
		||||
{
 | 
			
		||||
	Scene *scene= CTX_data_scene(C);
 | 
			
		||||
	Editing *ed= scene->ed;
 | 
			
		||||
	TransData *td = NULL;
 | 
			
		||||
	TransData2D *td2d= NULL;
 | 
			
		||||
	TransDataSeq *tdsq= NULL;
 | 
			
		||||
 | 
			
		||||
	Sequence *seq;
 | 
			
		||||
 | 
			
		||||
	int count=0;
 | 
			
		||||
	float cfra;
 | 
			
		||||
 | 
			
		||||
	for (seq=ed->seqbasep->first; seq; seq= seq->next) {
 | 
			
		||||
		if (seq->flag & SELECT) {
 | 
			
		||||
			if ((seq->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) == (SEQ_LEFTSEL|SEQ_RIGHTSEL)) {
 | 
			
		||||
				count += 2; /* transform both sides of the strip (not all that common) */
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				count += 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* stop if trying to build list if nothing selected */
 | 
			
		||||
	if (count == 0) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* allocate memory for data */
 | 
			
		||||
	t->total= count;
 | 
			
		||||
 | 
			
		||||
	td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransSeq TransData");
 | 
			
		||||
	td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransSeq TransData2D");
 | 
			
		||||
	tdsq = t->customData= MEM_callocN(t->total*sizeof(TransDataSeq), "TransSeq TransDataSeq");
 | 
			
		||||
 | 
			
		||||
	/* loop 2: build transdata array */
 | 
			
		||||
	for (seq=ed->seqbasep->first; seq; seq= seq->next) {
 | 
			
		||||
		if (seq->flag & SELECT) {
 | 
			
		||||
			if (seq->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) {
 | 
			
		||||
				if (seq->flag & SEQ_LEFTSEL) {
 | 
			
		||||
					SeqToTransData(td++, td2d++, tdsq++, seq, SEQ_LEFTSEL);
 | 
			
		||||
				}
 | 
			
		||||
				if (seq->flag & SEQ_RIGHTSEL) {
 | 
			
		||||
					SeqToTransData(td++, td2d++, tdsq++, seq, SEQ_RIGHTSEL);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				SeqToTransData(td++, td2d++, tdsq++, seq, SELECT);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* transcribe given object into TransData for Transforming */
 | 
			
		||||
static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *ob) 
 | 
			
		||||
{
 | 
			
		||||
@@ -3705,7 +3849,10 @@ void special_aftertrans_update(TransInfo *t)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (t->spacetype == SPACE_ACTION) {
 | 
			
		||||
	if (t->spacetype == SPACE_SEQ) {
 | 
			
		||||
		MEM_freeN(t->customData);
 | 
			
		||||
	}
 | 
			
		||||
	else if (t->spacetype == SPACE_ACTION) {
 | 
			
		||||
		SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
 | 
			
		||||
		Scene *scene;
 | 
			
		||||
		bAnimContext ac;
 | 
			
		||||
@@ -4172,6 +4319,11 @@ void createTransData(bContext *C, TransInfo *t)
 | 
			
		||||
		// TRANSFORM_FIX_ME
 | 
			
		||||
		//createTransNlaData(C, t);
 | 
			
		||||
	}
 | 
			
		||||
	else if (t->spacetype == SPACE_SEQ) {
 | 
			
		||||
		t->flag |= T_POINTS|T_2D_EDIT;
 | 
			
		||||
		t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transformations */
 | 
			
		||||
		createTransSeqData(C, t);
 | 
			
		||||
	}
 | 
			
		||||
	else if (t->spacetype == SPACE_IPO) {
 | 
			
		||||
		t->flag |= T_POINTS|T_2D_EDIT;
 | 
			
		||||
		createTransIpoData(C, t);
 | 
			
		||||
 
 | 
			
		||||
@@ -466,6 +466,9 @@ void recalcData(TransInfo *t)
 | 
			
		||||
	if (t->spacetype==SPACE_NODE) {
 | 
			
		||||
		flushTransNodes(t);
 | 
			
		||||
	}
 | 
			
		||||
	else if (t->spacetype==SPACE_SEQ) {
 | 
			
		||||
		flushTransSeq(t);
 | 
			
		||||
	}
 | 
			
		||||
	else if (t->obedit) {
 | 
			
		||||
		if (t->obedit->type == OB_MESH) {
 | 
			
		||||
			if(t->spacetype==SPACE_IMAGE) {
 | 
			
		||||
 
 | 
			
		||||
@@ -285,7 +285,6 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
 | 
			
		||||
			km= WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0);
 | 
			
		||||
			RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE);
 | 
			
		||||
			break;
 | 
			
		||||
		
 | 
			
		||||
		case SPACE_NODE:
 | 
			
		||||
			km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
 | 
			
		||||
			RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
 | 
			
		||||
@@ -296,6 +295,10 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
 | 
			
		||||
			km = WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, 0, 0);
 | 
			
		||||
			RNA_int_set(km->ptr, "mode", TFM_RESIZE);
 | 
			
		||||
			break;
 | 
			
		||||
		case SPACE_SEQ:
 | 
			
		||||
			km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
 | 
			
		||||
			RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,15 @@
 | 
			
		||||
#undef PyLong_Check
 | 
			
		||||
#define PyLong_Check PyInt_Check
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef PyUnicode_FromString
 | 
			
		||||
#undef PyUnicode_FromString
 | 
			
		||||
#endif
 | 
			
		||||
#define PyUnicode_FromString PyString_FromString
 | 
			
		||||
 | 
			
		||||
#ifdef PyUnicode_FromFormat
 | 
			
		||||
#undef PyUnicode_FromFormat
 | 
			
		||||
#endif
 | 
			
		||||
#define PyUnicode_FromFormat PyString_FromFormat
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user