From 401d9ef738d1c8e25909bcd2100d55109fe98075 Mon Sep 17 00:00:00 2001 From: Roel Spruit Date: Fri, 18 Jun 2004 15:04:27 +0000 Subject: [PATCH] Added the possibillity of naming sequence strips in the sequence editor. previously this was not possible for all types. - Change the name of a strip in the NKEY menu of the strip. - If a strip HAS a name, it will be displayed in the strip, instead of all that garbage that was previously there (image locations, lengths, whatever) Still TODO: while adding new effects to the sequencer I will also add this for effect strips. at the moment it's not clear yet what should go in the NKEY menu. --- source/blender/src/drawseq.c | 242 ++++++++++++++++++++--------------- 1 file changed, 140 insertions(+), 102 deletions(-) diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index f6a7dafb9fc..bcfd50f7123 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -86,19 +86,19 @@ int no_rightbox=0, no_leftbox= 0; static void EmbossBoxf(float x1, float y1, float x2, float y2, int sel, unsigned int dark, unsigned int light) { - if(sel) cpack(dark); + if(sel) cpack(dark); else cpack(light); if(sel) glLineWidth(2.0); fdrawline(x1, y2, x2, y2); /* top */ if(no_leftbox==0) fdrawline(x1, y1, x1, y2); /* left */ - + if(sel) glLineWidth(1.0); - - if(sel) cpack(light); - else cpack(dark); + + if(sel) cpack(light); + else cpack(dark); fdrawline(x1, y1, x2, y1); /* bottom */ if(no_rightbox==0) fdrawline(x2, y1, x2, y2); /* right */ - + } static char *give_seqname(Sequence *seq) @@ -107,9 +107,10 @@ static char *give_seqname(Sequence *seq) if(seq->name[2]) return seq->name+2; return "META"; } + else if(seq->type==SEQ_IMAGE) return "IMAGE"; else if(seq->type==SEQ_SCENE) return "SCENE"; else if(seq->type==SEQ_MOVIE) return "MOVIE"; - else if(seq->type==SEQ_SOUND) return "AUDIO"; + else if(seq->type==SEQ_SOUND) return "AUDIO"; else if(seq->typestrip->dir; else if(seq->type==SEQ_CROSS) return "CROSS"; else if(seq->type==SEQ_GAMCROSS) return "GAMMA CROSS"; @@ -124,7 +125,7 @@ static char *give_seqname(Sequence *seq) return "PLUGIN"; } else return "EFFECT"; - + } static void draw_cfra_seq(void) { @@ -170,22 +171,22 @@ static unsigned int seq_color(Sequence *seq) default: return 0x906060; } - + } static void drawmeta_contents(Sequence *seqm, float x1, float y1, float x2, float y2) { Sequence *seq; float dx; int nr; - + nr= 0; WHILE_SEQ(&seqm->seqbase) { nr++; } END_SEQ - + dx= (x2-x1)/nr; - + WHILE_SEQ(&seqm->seqbase) { cpack(seq_color(seq)); glRectf(x1, y1, x1+0.9*dx, y2); @@ -204,12 +205,12 @@ void drawseqwave(Sequence *seq, float x1, float y1, float x2, float y2) audio_makestream(seq->sound); if(seq->sound->stream==NULL) return; - + if (seq->flag & SEQ_MUTE) glColor3ub(0x70, 0x80, 0x80); else glColor3ub(0x70, 0xc0, 0xc0); sound = seq->sound; sofs = ((int)( (((float)(seq->startdisp-seq->start))/(float)G.scene->r.frs_sec)*(float)G.scene->audio.mixrate*4.0 )) & (~3); - eofs = ((int)( (((float)(seq->enddisp-seq->start))/(float)G.scene->r.frs_sec)*(float)G.scene->audio.mixrate*4.0 )) & (~3); - + eofs = ((int)( (((float)(seq->enddisp-seq->start))/(float)G.scene->r.frs_sec)*(float)G.scene->audio.mixrate*4.0 )) & (~3); + for (f=x1; f<=x2; f+=0.2) { offset = (int) ((float)sofs + ((f-x1)/(x2-x1)) * (float)(eofs-sofs)) & (~3); if (offset >= sound->streamlen) offset = sound->streamlen-1; @@ -230,7 +231,7 @@ void drawseq(Sequence *seq) int len, size; short mval[2]; char str[120], *strp; - + if(seq->startdisp > seq->enddisp) body= 0x707070; @@ -253,12 +254,12 @@ void drawseq(Sequence *seq) if(seq->endstill) x2= seq->start+seq->len; else x2= seq->enddisp; y2= seq->machine+0.8; - + cpack(body); glRectf(x1, y1, x2, y2); if (seq->type == SEQ_SOUND) drawseqwave(seq, x1, y1, x2, y2); EmbossBoxf(x1, y1, x2, y2, seq->flag & 1, dark, light); - + v1[1]= y1; v2[1]= y2; if(seq->type < SEQ_EFFECT) { @@ -266,7 +267,7 @@ void drawseq(Sequence *seq) /* decoration: the bars */ x1= seq->startdisp; x2= seq->enddisp; - + if(seq->startofs) { cpack(0x707070); glRectf((float)(seq->start), y1-0.2, x1, y1); @@ -292,21 +293,21 @@ void drawseq(Sequence *seq) EmbossBoxf((float)(seq->start+seq->len), y1+0.1, x2, y1+0.5, seq->flag & 1, dark, light); no_leftbox= 0; } - + } /* calculate if seq is long enough to print a name */ x1= seq->startdisp+seq->handsize; x2= seq->enddisp-seq->handsize; - + /* but first the contents of a meta */ if(seq->type==SEQ_META) drawmeta_contents(seq, x1, y1+0.15, x2, y2-0.15); - + if(x1cur.xmin) x1= G.v2d->cur.xmin; else if(x1>G.v2d->cur.xmax) x1= G.v2d->cur.xmax; if(x2cur.xmin) x2= G.v2d->cur.xmin; else if(x2>G.v2d->cur.xmax) x2= G.v2d->cur.xmax; - + if(x1 != x2) { v1[0]= x1; ipoco_to_areaco_noclip(G.v2d, v1, mval); @@ -315,39 +316,48 @@ void drawseq(Sequence *seq) ipoco_to_areaco_noclip(G.v2d, v2, mval); x2= mval[0]; size= x2-x1; - - if(seq->type == SEQ_META) sprintf(str, "%d %s", seq->len, give_seqname(seq)); - else if(seq->type == SEQ_SCENE) { - if(seq->scene) sprintf(str, "%d %s %s", seq->len, give_seqname(seq), seq->scene->id.name+2); - else sprintf(str, "%d %s", seq->len, give_seqname(seq)); - } - else if(seq->type & SEQ_EFFECT) { - if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3) - sprintf(str, "%d %s: %d-%d (use %d)", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, seq->seq3->machine); - else - sprintf(str, "%d %s: %d-%d", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine); - } - else if(seq->name[2]) sprintf(str, "%s", seq->name+2); - else { - if (seq->type == SEQ_SOUND) { + + if(seq->name[2]) { + sprintf(str, "%s: %s (%d)", give_seqname(seq), seq->name+2, seq->len); + }else{ + if(seq->type == SEQ_META) { + sprintf(str, "%d %s", seq->len, give_seqname(seq)); + } + else if(seq->type == SEQ_SCENE) { + if(seq->scene) sprintf(str, "%d %s %s", seq->len, give_seqname(seq), seq->scene->id.name+2); + else sprintf(str, "%d %s", seq->len, give_seqname(seq)); + + } + else if(seq->type == SEQ_IMAGE) { + sprintf(str, "%d %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); + } + else if(seq->type & SEQ_EFFECT) { + if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3) + sprintf(str, "%d %s: %d-%d (use %d)", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, seq->seq3->machine); + else + sprintf(str, "%d %s: %d-%d", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine); + } + else if (seq->type == SEQ_SOUND) { sprintf(str, "%d %s", seq->len, seq->strip->stripdata->name); - } else { - sprintf(str, "%d %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); + } + else if (seq->type == SEQ_MOVIE) { + sprintf(str, "%d %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name); } } + strp= str; - + while( (len= BMF_GetStringWidth(G.font, strp)) > size) { if(len < 10) break; if(strp[1]==0) break; strp++; } - + mval[0]= (x1+x2-len+1)/2; mval[1]= 1; areamouseco_to_ipoco(G.v2d, mval, &x1, &x2); - + if(seq->flag & SELECT) cpack(0xFFFFFF); else cpack(0x0); glRasterPos3f(x1, y1+0.2, 0.0); @@ -362,7 +372,7 @@ void drawseq(Sequence *seq) body+= 0x101010; dark= 0x202020; light= 0xB0B0B0; - + /* left triangle */ if(seq->flag & SEQ_LEFTSEL) { cpack(body+0x20); @@ -398,9 +408,9 @@ void drawseq(Sequence *seq) sprintf(str, "%d", seq->startdisp); BMF_DrawString(G.font, str); } - + /* right triangle */ - if(seq->type < SEQ_EFFECT) { + if(seq->type < SEQ_EFFECT) { dark= 0x202020; light= 0xB0B0B0; @@ -419,7 +429,7 @@ void drawseq(Sequence *seq) v1[0]= x2; glVertex2fv(v1); v2[0]-= seq->handsize; v2[1]= (y1+y2)/2.0; glVertex2fv(v2); v2[1]= y2; glEnd(); - + cpack(dark); glBegin(GL_LINE_STRIP); v2[0]= x2; glVertex2fv(v2); @@ -458,7 +468,7 @@ static void draw_image_seq(void) StripElem *se; struct ImBuf *ibuf; int x1, y1; - + glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -477,16 +487,16 @@ static void draw_image_seq(void) } } if(ibuf==0 || ibuf->rect==0) return; - + sseq= curarea->spacedata.first; if(sseq==0) return; - + /* calc location */ x1= curarea->winrct.xmin+(curarea->winx-sseq->zoom*ibuf->x)/2; y1= curarea->winrct.ymin+(curarea->winy-sseq->zoom*ibuf->y)/2; - - rectwrite_part(curarea->winrct.xmin, curarea->winrct.ymin, - curarea->winrct.xmax, curarea->winrct.ymax, + + rectwrite_part(curarea->winrct.xmin, curarea->winrct.ymin, + curarea->winrct.xmax, curarea->winrct.ymax, x1, y1, ibuf->x, ibuf->y, (float)sseq->zoom,(float)sseq->zoom, ibuf->rect); } @@ -498,16 +508,16 @@ static void draw_extra_seqinfo(void) float xco, xfac; int sta, end; char str[256]; - + if(last_seq==0) return; - + /* xfac: size of 1 pixel */ xfac= G.v2d->cur.xmax - G.v2d->cur.xmin; xfac/= (float)(G.v2d->mask.xmax-G.v2d->mask.xmin); xco= G.v2d->cur.xmin+40*xfac; - + BIF_ThemeColor(TH_TEXT); - + /* NAME */ glRasterPos3f(xco, 0.3, 0.0); strcpy(str, give_seqname(last_seq)); @@ -523,15 +533,15 @@ static void draw_extra_seqinfo(void) /* LEN */ if(last_seq->type & SEQ_EFFECT) sprintf(str, "len: %d From %d - %d", last_seq->len, last_seq->startdisp, last_seq->enddisp-1); - else + else sprintf(str, "len: %d (%d)", last_seq->enddisp-last_seq->startdisp, last_seq->len); - + glRasterPos3f(xco, 0.3, 0.0); BMF_DrawString(G.font, str); xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac; if(last_seq->type==SEQ_IMAGE) { - + /* CURRENT */ se= (StripElem *)give_stripelem(last_seq, (G.scene->r.cfra)); if(se) { @@ -540,20 +550,20 @@ static void draw_extra_seqinfo(void) BMF_DrawString(G.font, str); xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac; } - + /* FIRST AND LAST */ - + if(last_seq->strip) { se= last_seq->strip->stripdata; last= se+last_seq->len-1; if(last_seq->startofs) se+= last_seq->startofs; if(last_seq->endofs) last-= last_seq->endofs; - + sprintf(str, "First: %s at %d Last: %s at %d", se->name, last_seq->startdisp, last->name, last_seq->enddisp-1); glRasterPos3f(xco, 0.3, 0.0); BMF_DrawString(G.font, str); xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac; - + /* orig size */ sprintf(str, "OrigSize: %d x %d", last_seq->strip->orx, last_seq->strip->ory); glRasterPos3f(xco, 0.3, 0.0); @@ -562,46 +572,47 @@ static void draw_extra_seqinfo(void) } } else if(last_seq->type==SEQ_MOVIE) { - + sta= last_seq->startofs; end= last_seq->len-1-last_seq->endofs; - - sprintf(str, "%s %s%s First: %d at %d Last: %d at %d Cur: %d", - last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name, + + sprintf(str, "%s %s%s First: %d at %d Last: %d at %d Cur: %d", + last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name, sta, last_seq->startdisp, end, last_seq->enddisp-1, (G.scene->r.cfra)-last_seq->startdisp); - + glRasterPos3f(xco, 0.3, 0.0); BMF_DrawString(G.font, str); } else if(last_seq->type==SEQ_SOUND) { - + sta= last_seq->startofs; end= last_seq->len-1-last_seq->endofs; - - sprintf(str, "%s %s%s First: %d at %d Last: %d at %d Cur: %d Gain: %.2f dB Pan: %.2f", - last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name, + + sprintf(str, "%s %s%s First: %d at %d Last: %d at %d Cur: %d Gain: %.2f dB Pan: %.2f", + last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name, sta, last_seq->startdisp, end, last_seq->enddisp-1, (G.scene->r.cfra)-last_seq->startdisp, last_seq->level, last_seq->pan); - + glRasterPos3f(xco, 0.3, 0.0); BMF_DrawString(G.font, str); - } + } } #define SEQ_BUT_PLUGIN 1 #define SEQ_BUT_MOVIE 2 +#define SEQ_BUT_IMAGE 3 void do_seqbuttons(short val) { extern Sequence *last_seq; StripElem *se; - + switch(val) { case SEQ_BUT_PLUGIN: new_stripdata(last_seq); free_imbuf_effect_spec(CFRA); break; - + case SEQ_BUT_MOVIE: se= last_seq->curelem; if(se && se->ibuf ) { @@ -609,8 +620,10 @@ void do_seqbuttons(short val) se->ibuf= 0; } break; + case SEQ_BUT_IMAGE: + break; } - + allqueue(REDRAWSEQ, 0); } @@ -618,7 +631,7 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES { extern Sequence *last_seq; uiBlock *block; - + block= uiNewBlock(&curarea->uiblocks, "seq_panel_properties", UI_EMBOSS, UI_HELV, curarea->win); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(SEQ_HANDLER_PROPERTIES); // for close and esc @@ -630,10 +643,12 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES PluginSeq *pis; VarStruct *varstr; int a, xco, yco; - + + uiDefBut(block, LABEL, 0, "Striptype: Plugin", 10,50,70,20, 0, 0, 0, 0, 0, ""); + pis= last_seq->plugin; if(pis->vars==0) return; - + varstr= pis->varstr; if(varstr) { for(a=0; avars; a++, varstr++) { @@ -644,28 +659,51 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES } } } + else if(last_seq->type==SEQ_IMAGE) { + + uiDefBut(block, LABEL, 0, "Striptype: Image", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + + } + else if(last_seq->type==SEQ_META) { + + uiDefBut(block, LABEL, 0, "Striptype: Meta", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + + } + else if(last_seq->type==SEQ_SCENE) { + + uiDefBut(block, LABEL, 0, "Striptype: Scene", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + + } else if(last_seq->type==SEQ_MOVIE) { if(last_seq->mul==0.0) last_seq->mul= 1.0; - uiDefBut(block, TEX, 0, "Name ", 10,140,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); - uiDefButS(block, TOG|BIT|4, SEQ_BUT_MOVIE, "FilterY ", 10,120,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, ""); - uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Mul:", 10,100,150,19, &last_seq->mul, 0.001, 5.0, 100, 0, ""); + uiDefBut(block, LABEL, 0, "Striptype: Movie", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + + uiDefButS(block, TOG|BIT|4, SEQ_BUT_MOVIE, "FilterY ", 10,90,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, ""); + uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Mul:", 10,70,150,19, &last_seq->mul, 0.001, 5.0, 100, 0, ""); } else if(last_seq->type==SEQ_SOUND) { - uiDefBut(block, TEX, 0, "Name ", 10,140,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); - uiDefButS(block, TOG|BIT|5, 0, "Mute", 10,120,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, ""); - uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Gain (dB):", 10,100,150,19, &last_seq->level, -96.0, 6.0, 100, 0, ""); - uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Pan:", 10,80,150,19, &last_seq->pan, -1.0, 1.0, 100, 0, ""); - } - else if(last_seq->type==SEQ_META) { + uiDefBut(block, LABEL, 0, "Striptype: Audio", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); - uiDefBut(block, TEX, 0, "Name ", 10,140,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + uiDefButS(block, TOG|BIT|5, 0, "Mute", 10,90,120,19, &last_seq->flag, 0.0, 21.0, 100, 0, ""); + uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Gain (dB):", 10,70,150,19, &last_seq->level, -96.0, 6.0, 100, 0, ""); + uiDefButF(block, NUM, SEQ_BUT_MOVIE, "Pan:", 10,50,150,19, &last_seq->pan, -1.0, 1.0, 100, 0, ""); + } + else if(last_seq->type>=SEQ_EFFECT) { + uiDefBut(block, LABEL, 0, "Striptype: Effect", 10,140,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); } + } static void seq_blockhandlers(ScrArea *sa) @@ -682,7 +720,7 @@ static void seq_blockhandlers(ScrArea *sa) case SEQ_HANDLER_PROPERTIES: seq_panel_properties(sseq->blockhandler[a+1]); break; - + } /* clear action value for event */ sseq->blockhandler[a+1]= 0; @@ -700,7 +738,7 @@ void drawseqspace(ScrArea *sa, void *spacedata) int ofsx, ofsy; ed= G.scene->ed; - + sseq= curarea->spacedata.first; if(sseq->mainb==1) { draw_image_seq(); @@ -713,33 +751,33 @@ void drawseqspace(ScrArea *sa, void *spacedata) BIF_GetThemeColor3fv(TH_BACK, col); if(ed && ed->metastack.first) glClearColor(col[0], col[1], col[2]-1.0, 0.0); else glClearColor(col[0], col[1], col[2], 0.0); - + glClear(GL_COLOR_BUFFER_BIT); calc_scrollrcts(G.v2d, curarea->winx, curarea->winy); if(curarea->winx>SCROLLB+10 && curarea->winy>SCROLLH+10) { - if(G.v2d->scroll) { + if(G.v2d->scroll) { ofsx= curarea->winrct.xmin; /* because of mywin */ ofsy= curarea->winrct.ymin; - glViewport(ofsx+G.v2d->mask.xmin, ofsy+G.v2d->mask.ymin, ( ofsx+G.v2d->mask.xmax-1)-(ofsx+G.v2d->mask.xmin)+1, ( ofsy+G.v2d->mask.ymax-1)-( ofsy+G.v2d->mask.ymin)+1); + glViewport(ofsx+G.v2d->mask.xmin, ofsy+G.v2d->mask.ymin, ( ofsx+G.v2d->mask.xmax-1)-(ofsx+G.v2d->mask.xmin)+1, ( ofsy+G.v2d->mask.ymax-1)-( ofsy+G.v2d->mask.ymin)+1); glScissor(ofsx+G.v2d->mask.xmin, ofsy+G.v2d->mask.ymin, ( ofsx+G.v2d->mask.xmax-1)-(ofsx+G.v2d->mask.xmin)+1, ( ofsy+G.v2d->mask.ymax-1)-( ofsy+G.v2d->mask.ymin)+1); } } myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); - + BIF_ThemeColorShade(TH_BACK, -20); glRectf(G.v2d->cur.xmin, 0.0, G.v2d->cur.xmax, 1.0); - + boundbox_seq(); - calc_ipogrid(); + calc_ipogrid(); draw_ipogrid(); draw_cfra_seq(); /* sequences: first deselect */ - + if(ed) { seq= ed->seqbasep->first; while(seq) { @@ -769,7 +807,7 @@ void drawseqspace(ScrArea *sa, void *spacedata) drawscroll(0); } } - + draw_area_emboss(sa); if(sseq->mainb==0) { @@ -777,7 +815,7 @@ void drawseqspace(ScrArea *sa, void *spacedata) bwin_scalematrix(sa->win, sseq->blockscale, sseq->blockscale, sseq->blockscale); seq_blockhandlers(sa); } - + curarea->win_swap= WIN_BACK_OK; }