basic transform for sequencer strips
authorCampbell Barton <ideasman42@gmail.com>
Wed, 21 Jan 2009 07:01:20 +0000 (07:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 21 Jan 2009 07:01:20 +0000 (07:01 +0000)
can transform the strips or move their handles
Still todo, click-drag transform, metastrips support, snapping, markers overlap checks and constrain to valid channels.

12 files changed:
source/blender/blenkernel/BKE_sequence.h
source/blender/blenkernel/intern/sequence.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_ops.c
source/blender/python/intern/bpy_compat.h

index 94eb8e0495feba05dcb94e3d83ea19ddbc2722e8..e71099743d2f087ac6e3ec7d3d09d05ea1ddc3f7 100644 (file)
@@ -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);
index 1c0e62fd01041afc5c8f83c70d913be3e432bb9a..3af67a3f99e0b59e97168705b07b71d6396164f1 100644 (file)
@@ -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;
+       }
+}
\ No newline at end of file
index 02fee25dfdb03ee6b638d24128236ecbe661a3f0..b2cc5eae5f1d641197b9994e9198a4fb15fe6678 100644 (file)
@@ -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);
        
index 5430dad237243debca5c185375ccf7f24221fd23..77fcebafdf45d9428c7d312e0637ae309b94b70c 100644 (file)
@@ -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);
                }
index 35a188293bbf3d73a9960e7c541442aa0ae996ca..b31b4a44bdea1c024cd0fefd20a3c2b21c409fdd 100644 (file)
@@ -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);
 }
 
index d9a3fbbe8c7bdffaa72e1d4d40c2096f79d96f73..09e00c28414d664ee07fd82d282cad9d1e54ef52 100644 (file)
@@ -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;
                        }
index 9b6a9ee2476086a9db81d7f56e05eb21ac4e9c48..b721e23ef6d90046b96916221d26424322a1220b 100644 (file)
@@ -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);
index cc1968a100f7dca6cbd83ac7c855f08e0fef26a9..5e8c6936d0d6b9eee3ef08308432e639a61eac42 100644 (file)
@@ -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]);
index 40c0975a3b08d090883953e585826bd15293c2b0..97ce4dbeb800e57ac625a21673cee763b7356c54 100644 (file)
@@ -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) 
 {
@@ -3704,8 +3848,11 @@ 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);
index 707fed7267dade257a2b98ddaed579af63a4223a..75a2710cf63a9f09b216d3fb74682d441ef09694 100644 (file)
@@ -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) {
index 7af8b48219cfc819cd308df66960cb0ac8249320..d3153f45050679d31e4f346fe1b02e4b37e5d883 100644 (file)
@@ -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;
        }
index 0032b760219fecdb40da66e515d54a04da7bf128..bc201a3e80292769f0a1e1c646a19d10c59d7b6d 100644 (file)
 #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