[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12743] trunk/blender/source/blender/src: rewrote strip cut, now it works on metastrips and selects the strips depending on the side of the frame your mouse is on .
Campbell Barton
ideasman42 at gmail.com
Sat Dec 1 14:40:59 CET 2007
Revision: 12743
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12743
Author: campbellbarton
Date: 2007-12-01 14:40:59 +0100 (Sat, 01 Dec 2007)
Log Message:
-----------
rewrote strip cut, now it works on metastrips and selects the strips depending on the side of the frame your mouse is on.
also removed WHILE_SEQ from transform loops - about 5 or so because it allocates memory each time.
Modified Paths:
--------------
trunk/blender/source/blender/src/editseq.c
trunk/blender/source/blender/src/space.c
Modified: trunk/blender/source/blender/src/editseq.c
===================================================================
--- trunk/blender/source/blender/src/editseq.c 2007-12-01 12:34:15 UTC (rev 12742)
+++ trunk/blender/source/blender/src/editseq.c 2007-12-01 13:40:59 UTC (rev 12743)
@@ -114,6 +114,15 @@
static int test_overlap_seq(Sequence *);
static void shuffle_seq(Sequence *);
+typedef struct TransSeq {
+ int start, machine;
+ int startstill, endstill;
+ int startdisp, enddisp;
+ int startofs, endofs;
+ int final_left, final_right;
+ int len;
+} TransSeq;
+
Sequence *get_last_seq()
{
if(!_last_seq_init) {
@@ -325,6 +334,16 @@
|| (get_sequence_effect_num_inputs(seq->type) == 0);
}
+char mouse_cfra_side( int frame ) {
+ short mval[2];
+ float xmouse, ymouse;
+ getmouseco_areawin(mval);
+
+ /* choose the side based on which side of the playhead the mouse is on */
+ areamouseco_to_ipoco(G.v2d, mval, &xmouse, &ymouse);
+ return (xmouse > frame) ? 'R' : 'L';
+}
+
Sequence *find_neighboring_sequence(Sequence *test, int lr, int sel) {
/* looks to the left on lr==1, to the right on lr==2
sel - 0==unselected, 1==selected, -1==done care*/
@@ -2147,139 +2166,274 @@
allqueue(REDRAWSEQ, 0);
}
-static void recurs_dupli_seq(ListBase *old, ListBase *new)
-{
- Sequence *seq;
- Sequence *seqn = 0;
- Sequence *last_seq = get_last_seq();
+static Sequence *dupli_seq(Sequence *seq) {
+ Sequence *seqn = NULL;
+
+ if(seq->type==SEQ_META) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
+
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata = 0;
+ seqn->strip->tstripdata = 0;
- seq= old->first;
+ seqn->seqbase.first= seqn->seqbase.last= 0;
+ /* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */
+ /* - recurs_dupli_seq(&seq->seqbase,&seqn->seqbase);*/
+ }
+ else if(seq->type == SEQ_SCENE) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- while(seq) {
- seq->tmp= NULL;
- if(seq->flag & SELECT) {
- if(seq->type==SEQ_META) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata = 0;
+ seqn->strip->tstripdata = 0;
+ }
+ else if(seq->type == SEQ_MOVIE) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata = 0;
- seqn->strip->tstripdata = 0;
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata =
+ MEM_dupallocN(seq->strip->stripdata);
+ seqn->strip->tstripdata = 0;
+ seqn->anim= 0;
+ }
+ else if(seq->type == SEQ_RAM_SOUND) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- seq->flag &= SEQ_DESEL;
- seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata =
+ MEM_dupallocN(seq->strip->stripdata);
+ seqn->strip->tstripdata = 0;
- seqn->seqbase.first= seqn->seqbase.last= 0;
- recurs_dupli_seq(&seq->seqbase,&seqn->seqbase);
+ seqn->anim= 0;
+ seqn->sound->id.us++;
+ if(seqn->ipo) seqn->ipo->id.us++;
+ }
+ else if(seq->type == SEQ_HD_SOUND) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- }
- else if(seq->type == SEQ_SCENE) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata =
+ MEM_dupallocN(seq->strip->stripdata);
+ seqn->strip->tstripdata = 0;
+ seqn->anim= 0;
+ seqn->hdaudio = 0;
+ if(seqn->ipo) seqn->ipo->id.us++;
+ } else if(seq->type == SEQ_IMAGE) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata = 0;
- seqn->strip->tstripdata = 0;
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata =
+ MEM_dupallocN(seq->strip->stripdata);
+ seqn->strip->tstripdata = 0;
+ } else if(seq->type >= SEQ_EFFECT) {
+ seqn= MEM_dupallocN(seq);
+ seq->tmp= seqn;
- seq->flag &= SEQ_DESEL;
- seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
- }
- else if(seq->type == SEQ_MOVIE) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp;
+ if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp;
+ if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp;
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata =
- MEM_dupallocN(seq->strip->stripdata);
- seqn->strip->tstripdata = 0;
- seqn->anim= 0;
+ if(seqn->ipo) seqn->ipo->id.us++;
- seq->flag &= SEQ_DESEL;
- seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
- }
- else if(seq->type == SEQ_RAM_SOUND) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ if (seq->type & SEQ_EFFECT) {
+ struct SeqEffectHandle sh;
+ sh = get_sequence_effect(seq);
+ if(sh.copy)
+ sh.copy(seq, seqn);
+ }
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata =
- MEM_dupallocN(seq->strip->stripdata);
- seqn->strip->tstripdata = 0;
+ seqn->strip= MEM_dupallocN(seq->strip);
+ seqn->strip->stripdata = 0;
+ seqn->strip->tstripdata = 0;
+
+ } else {
+ fprintf(stderr, "Aiiiiekkk! sequence type not "
+ "handled in duplicate!\nExpect a crash"
+ " now...\n");
+ }
+
+ return seqn;
+}
- seqn->anim= 0;
- seqn->sound->id.us++;
- if(seqn->ipo) seqn->ipo->id.us++;
+static void recurs_dupli_seq(ListBase *old, ListBase *new)
+{
+ Sequence *seq;
+ Sequence *seqn = 0;
+ Sequence *last_seq = get_last_seq();
+ for(seq= old->first; seq; seq= seq->next) {
+ seq->tmp= NULL;
+ if(seq->flag & SELECT) {
+ seqn = dupli_seq(seq);
+ if (seqn) { /*should never fail */
seq->flag &= SEQ_DESEL;
seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
+
+ BLI_addtail(new, seqn);
+ if(seq->type==SEQ_META)
+ recurs_dupli_seq(&seq->seqbase,&seqn->seqbase);
+
+ if (seq == last_seq) {
+ set_last_seq(seqn);
+ }
}
- else if(seq->type == SEQ_HD_SOUND) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ }
+ }
+}
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata =
- MEM_dupallocN(seq->strip->stripdata);
- seqn->strip->tstripdata = 0;
- seqn->anim= 0;
- seqn->hdaudio = 0;
- if(seqn->ipo) seqn->ipo->id.us++;
+/* like duplicate, but only duplicate and cut overlapping strips,
+ * strips to the left of the cutframe are ignored and strips to the right are moved into the new list */
+static void recurs_cut_seq(ListBase *old, ListBase *new, int cutframe)
+{
+ Sequence *seq, *seq_next;
+ Sequence *seqn = 0;
+
+ TransSeq ts;
- seq->flag &= SEQ_DESEL;
- seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
- } else if(seq->type == SEQ_IMAGE) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
+ seq= old->first;
+
+ while(seq) {
+ seq_next = seq->next; /* we need this because we may remove seq */
+
+ seq->tmp= NULL;
+ if(seq->flag & SELECT) {
+ if(cutframe > seq->startdisp && cutframe < seq->enddisp) {
+
+ /* backup values */
+ 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.len= seq->len;
+
+ /* First Strip! */
+ /* strips with extended stillfames before */
+ if(seq->type!=SEQ_META) {
+
+ if ((seq->startstill) && (cutframe <seq->start)) {
+ seq->start= cutframe -1;
+ seq->startstill= cutframe -seq->startdisp -1;
+ seq->len= 1;
+ seq->endstill= 0;
+ }
+
+ /* normal strip */
+ else if ((cutframe >=seq->start)&&(cutframe <=(seq->start+seq->len))) {
+ seq->endofs = (seq->start+seq->len) - cutframe;
+ }
+
+ /* strips with extended stillframes after */
+ else if (((seq->start+seq->len) < cutframe) && (seq->endstill)) {
+ seq->endstill -= seq->enddisp - cutframe;
+ }
+
+ calc_sequence(seq);
+ }
+
+ /* Duplicate AFTER the first change */
+ seqn = dupli_seq(seq);
+
+ if (seqn) { /* should never fail */
+ seqn->flag |= SELECT;
+
+
+ BLI_addtail(new, seqn);
+
+ /* dont transform meta's - just do their children then recalc */
+ if(seq->type==SEQ_META) {
+ recurs_cut_seq(&seq->seqbase,&seqn->seqbase, cutframe);
+ } else {
+ /* Second Strip! */
+ /* strips with extended stillframes before */
+ if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
+ seqn->start = ts.start;
+ seqn->startstill= ts.start- cutframe;
+ seqn->len = ts.len;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* normal strip */
+ else if ((cutframe>=seqn->start)&&(cutframe<=(seqn->start+seqn->len))) {
+ seqn->startstill = 0;
+ seqn->startofs = cutframe - ts.start;
+ seqn->endofs = ts.endofs;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* strips with extended stillframes after */
+ else if (((seqn->start+seqn->len) < cutframe) && (seqn->endstill)) {
+ seqn->start = cutframe - ts.len +1;
+ seqn->startofs = ts.len-1;
+ seqn->endstill = ts.enddisp - cutframe -1;
+ seqn->startstill = 0;
+ }
+ }
+
+ if(seq->type==SEQ_META) /* account for strips within changing */
+ calc_sequence(seq);
+
+ calc_sequence(seqn);
+ }
+ } else if (seq->enddisp <= cutframe) {
+ /* do nothing */
+ } else if (seq->startdisp >= cutframe) {
+ /* move into new list */
+ BLI_remlink(old, seq);
+ BLI_addtail(new, seq);
+ }
+ }
+ seq = seq_next;
+ }
+}
- seqn->strip= MEM_dupallocN(seq->strip);
- seqn->strip->stripdata =
- MEM_dupallocN(seq->strip->stripdata);
- seqn->strip->tstripdata = 0;
-
- seq->flag &= SEQ_DESEL;
-
- seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL);
- } else if(seq->type >= SEQ_EFFECT) {
- seqn= MEM_dupallocN(seq);
- seq->tmp= seqn;
- BLI_addtail(new, seqn);
-
- if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp;
- if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp;
- if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp;
-
- if(seqn->ipo) seqn->ipo->id.us++;
-
- if (seq->type & SEQ_EFFECT) {
- struct SeqEffectHandle sh;
- sh = get_sequence_effect(seq);
- if(sh.copy)
- sh.copy(seq, seqn);
+void seq_cut(int cutframe)
+{
+ Editing *ed;
+ ListBase newlist;
+ char side;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list