4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * Contributor(s): Blender Foundation, 2003-2009
25 * ***** END GPL LICENSE BLOCK *****
31 #include "MEM_guardedalloc.h"
33 #include "BLI_blenlib.h"
36 #include "IMB_imbuf_types.h"
38 #include "DNA_gpencil_types.h"
39 #include "DNA_sequence_types.h"
40 #include "DNA_scene_types.h"
41 #include "DNA_screen_types.h"
42 #include "DNA_space_types.h"
43 #include "DNA_view2d_types.h"
44 #include "DNA_userdef_types.h"
46 #include "BKE_context.h"
47 #include "BKE_global.h"
48 #include "BKE_plugin_types.h"
49 #include "BKE_sequence.h"
50 #include "BKE_scene.h"
51 #include "BKE_utildefines.h"
53 #include "IMB_imbuf_types.h"
54 #include "IMB_imbuf.h"
57 #include "BIF_glutil.h"
59 #include "ED_anim_api.h"
60 #include "ED_space_api.h"
61 #include "ED_sequencer.h"
64 #include "UI_interface.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
69 #include "sequencer_intern.h"
71 #define SEQ_LEFTHANDLE 1
72 #define SEQ_RIGHTHANDLE 2
75 /* Note, Dont use WHILE_SEQ while drawing! - it messes up transform, - Campbell */
77 int no_rightbox=0, no_leftbox= 0;
78 static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float x2, float y2);
81 static void draw_cfra_seq(View2D *v2d, int cfra)
83 glColor3ub(0x30, 0x90, 0x50);
86 glVertex2f(cfra, v2d->cur.ymin);
87 glVertex2f(cfra, v2d->cur.ymax);
92 static void get_seq_color3ubv(Scene *curscene, Sequence *seq, char *col)
96 SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
100 UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
103 UI_GetThemeColor3ubv(TH_SEQ_META, col);
106 UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
109 UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
111 if(seq->scene==curscene) {
112 UI_GetColorPtrBlendShade3ubv(col, col, col, 1.0, 20);
120 /* slightly offset hue to distinguish different effects */
121 UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
123 rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0;
124 rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
126 if (seq->type == SEQ_CROSS) hsv[0]+= 0.04;
127 if (seq->type == SEQ_GAMCROSS) hsv[0]+= 0.08;
128 if (seq->type == SEQ_WIPE) hsv[0]+= 0.12;
130 if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
131 hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
132 col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255);
145 /* slightly offset hue to distinguish different effects */
146 UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
148 rgb[0] = col[0]/255.0; rgb[1] = col[1]/255.0; rgb[2] = col[2]/255.0;
149 rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
151 if (seq->type == SEQ_ADD) hsv[0]+= 0.04;
152 if (seq->type == SEQ_SUB) hsv[0]+= 0.08;
153 if (seq->type == SEQ_MUL) hsv[0]+= 0.12;
154 if (seq->type == SEQ_ALPHAOVER) hsv[0]+= 0.16;
155 if (seq->type == SEQ_ALPHAUNDER) hsv[0]+= 0.20;
156 if (seq->type == SEQ_OVERDROP) hsv[0]+= 0.24;
157 if (seq->type == SEQ_GLOW) hsv[0]+= 0.28;
158 if (seq->type == SEQ_TRANSFORM) hsv[0]+= 0.36;
160 if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
161 hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
162 col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255);
166 col[0]= (char)(colvars->col[0]*255);
167 col[1]= (char)(colvars->col[1]*255);
168 col[2]= (char)(colvars->col[2]*255);
170 col[0] = col[1] = col[2] = 128;
174 UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col);
177 UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
178 blendcol[0] = blendcol[1] = blendcol[2] = 128;
179 if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
182 col[0] = 10; col[1] = 255; col[2] = 40;
186 static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
188 /* Note, this used to use WHILE_SEQ, but it messes up the seq->depth value, (needed by transform when doing overlap checks)
189 * so for now, just use the meta's immediate children, could be fixed but its only drawing - Campbell */
195 nr= BLI_countlist(&seqm->seqbase);
199 if (seqm->flag & SEQ_MUTE) {
200 glEnable(GL_POLYGON_STIPPLE);
201 glPolygonStipple(stipple_halftone);
203 glEnable(GL_LINE_STIPPLE);
204 glLineStipple(1, 0x8888);
207 for (seq= seqm->seqbase.first; seq; seq= seq->next) {
208 get_seq_color3ubv(scene, seq, col);
210 glColor3ubv((GLubyte *)col);
212 glRectf(x1, y1, x1+0.9*dx, y2);
214 UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -30);
215 glColor3ubv((GLubyte *)col);
217 fdrawbox(x1, y1, x1+0.9*dx, y2);
222 if (seqm->flag & SEQ_MUTE) {
223 glDisable(GL_POLYGON_STIPPLE);
224 glDisable(GL_LINE_STIPPLE);
228 /* draw a handle, for each end of a sequence strip */
229 static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short direction)
231 float v1[2], v2[2], v3[2], rx1=0, rx2=0; //for triangles and rect
232 float x1, x2, y1, y2;
234 float minhandle, maxhandle;
236 unsigned int whichsel=0;
241 y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
242 y2= seq->machine+SEQ_STRIP_OFSTOP;
244 /* clamp handles to defined size in pixel space */
245 handsize = seq->handsize;
248 CLAMP(handsize, minhandle*pixelx, maxhandle*pixelx);
250 /* set up co-ordinates/dimensions for either left or right handle */
251 if (direction == SEQ_LEFTHANDLE) {
253 rx2 = x1+handsize*0.75;
255 v1[0]= x1+handsize/4; v1[1]= y1+( ((y1+y2)/2.0 - y1)/2);
256 v2[0]= x1+handsize/4; v2[1]= y2-( ((y1+y2)/2.0 - y1)/2);
257 v3[0]= v2[0] + handsize/4; v3[1]= (y1+y2)/2.0;
259 whichsel = SEQ_LEFTSEL;
260 } else if (direction == SEQ_RIGHTHANDLE) {
261 rx1 = x2-handsize*0.75;
264 v1[0]= x2-handsize/4; v1[1]= y1+( ((y1+y2)/2.0 - y1)/2);
265 v2[0]= x2-handsize/4; v2[1]= y2-( ((y1+y2)/2.0 - y1)/2);
266 v3[0]= v2[0] - handsize/4; v3[1]= (y1+y2)/2.0;
268 whichsel = SEQ_RIGHTSEL;
272 if(seq->type < SEQ_EFFECT ||
273 get_sequence_effect_num_inputs(seq->type) == 0) {
274 glEnable( GL_BLEND );
276 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
278 if(seq->flag & whichsel) glColor4ub(0, 0, 0, 80);
279 else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30);
280 else glColor4ub(0, 0, 0, 22);
282 glRectf(rx1, y1, rx2, y2);
284 if(seq->flag & whichsel) glColor4ub(255, 255, 255, 200);
285 else glColor4ub(0, 0, 0, 50);
287 glEnable( GL_POLYGON_SMOOTH );
288 glBegin(GL_TRIANGLES);
289 glVertex2fv(v1); glVertex2fv(v2); glVertex2fv(v3);
292 glDisable( GL_POLYGON_SMOOTH );
293 glDisable( GL_BLEND );
296 if(G.moving || (seq->flag & whichsel)) {
298 if (direction == SEQ_LEFTHANDLE) {
299 sprintf(str, "%d", seq->startdisp);
303 sprintf(str, "%d", seq->enddisp - 1);
304 x1= x2 - handsize*0.75;
307 UI_view2d_text_cache_add(v2d, x1, y1, str);
311 static void draw_seq_extensions(Scene *scene, SpaceSeq *sseq, Sequence *seq)
313 float x1, x2, y1, y2, pixely, a;
314 char col[3], blendcol[3];
317 if(seq->type >= SEQ_EFFECT) return;
322 y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
323 y2= seq->machine+SEQ_STRIP_OFSTOP;
326 pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
328 blendcol[0] = blendcol[1] = blendcol[2] = 120;
331 glEnable( GL_BLEND );
332 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
334 get_seq_color3ubv(scene, seq, col);
336 if (seq->flag & SELECT) {
337 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
338 glColor4ub(col[0], col[1], col[2], 170);
340 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
341 glColor4ub(col[0], col[1], col[2], 110);
344 glRectf((float)(seq->start), y1-SEQ_STRIP_OFSBOTTOM, x1, y1);
346 if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
347 else glColor4ub(col[0], col[1], col[2], 160);
349 fdrawbox((float)(seq->start), y1-SEQ_STRIP_OFSBOTTOM, x1, y1); //outline
351 glDisable( GL_BLEND );
354 glEnable( GL_BLEND );
355 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
357 get_seq_color3ubv(scene, seq, col);
359 if (seq->flag & SELECT) {
360 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
361 glColor4ub(col[0], col[1], col[2], 170);
363 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
364 glColor4ub(col[0], col[1], col[2], 110);
367 glRectf(x2, y2, (float)(seq->start+seq->len), y2+SEQ_STRIP_OFSBOTTOM);
369 if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
370 else glColor4ub(col[0], col[1], col[2], 160);
372 fdrawbox(x2, y2, (float)(seq->start+seq->len), y2+SEQ_STRIP_OFSBOTTOM); //outline
374 glDisable( GL_BLEND );
376 if(seq->startstill) {
377 get_seq_color3ubv(scene, seq, col);
378 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
379 glColor3ubv((GLubyte *)col);
381 draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
383 /* feint pinstripes, helps see exactly which is extended and which isn't,
384 * especially when the extension is very small */
385 if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
386 else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -16);
388 glColor3ubv((GLubyte *)col);
390 for(a=y1; a< y2; a+= pixely*2.0 ) {
391 fdrawline(x1, a, (float)(seq->start), a);
395 get_seq_color3ubv(scene, seq, col);
396 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
397 glColor3ubv((GLubyte *)col);
399 draw_shadedstrip(seq, col, (float)(seq->start+seq->len), y1, x2, y2);
401 /* feint pinstripes, helps see exactly which is extended and which isn't,
402 * especially when the extension is very small */
403 if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
404 else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -16);
406 glColor3ubv((GLubyte *)col);
408 for(a=y1; a< y2; a+= pixely*2.0 ) {
409 fdrawline((float)(seq->start+seq->len), a, x2, a);
414 /* draw info text on a sequence strip */
415 static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, char *background_col)
418 char str[32 + FILE_MAXDIR+FILE_MAXFILE];
421 sprintf(str, "%d | %s: %s", seq->len, give_seqname(seq), seq->name+2);
424 if(seq->type == SEQ_META) {
425 sprintf(str, "%d | %s", seq->len, give_seqname(seq));
427 else if(seq->type == SEQ_SCENE) {
428 if(seq->scene) sprintf(str, "%d | %s: %s", seq->len, give_seqname(seq), seq->scene->id.name+2);
429 else sprintf(str, "%d | %s", seq->len, give_seqname(seq));
432 else if(seq->type == SEQ_IMAGE) {
433 sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
435 else if(seq->type & SEQ_EFFECT) {
436 int can_float = (seq->type != SEQ_PLUGIN)
437 || (seq->plugin && seq->plugin->version >= 4);
439 if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3)
440 sprintf(str, "%d | %s: %d>%d (use %d)%s", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, seq->seq3->machine, can_float ? "" : " No float, upgrade plugin!");
441 else if (seq->seq1 && seq->seq2)
442 sprintf(str, "%d | %s: %d>%d%s", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, can_float ? "" : " No float, upgrade plugin!");
444 sprintf(str, "%d | %s", seq->len, give_seqname(seq));
446 else if (seq->type == SEQ_SOUND) {
447 sprintf(str, "%d | %s", seq->len, seq->sound->name);
449 else if (seq->type == SEQ_MOVIE) {
450 sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
454 if(seq->flag & SELECT){
456 }else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50){
457 cpack(0x505050); /* use lighter text colour for dark background */
466 UI_view2d_text_cache_rectf(v2d, &rect, str);
469 /* draws a shaded strip, made from gradient + flat color + gradient */
470 static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float x2, float y2)
474 if (seq->flag & SEQ_MUTE) {
475 glEnable(GL_POLYGON_STIPPLE);
476 glPolygonStipple(stipple_halftone);
479 ymid1 = (y2-y1)*0.25 + y1;
480 ymid2 = (y2-y1)*0.65 + y1;
482 glShadeModel(GL_SMOOTH);
485 if(seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -50);
486 else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 0);
488 glColor3ubv((GLubyte *)col);
493 if(seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5);
494 else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -5);
496 glColor3ubv((GLubyte *)col);
498 glVertex2f(x2,ymid1);
499 glVertex2f(x1,ymid1);
503 glRectf(x1, ymid1, x2, ymid2);
507 glVertex2f(x1,ymid2);
508 glVertex2f(x2,ymid2);
510 if(seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, -15);
511 else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 25);
513 glColor3ubv((GLubyte *)col);
520 if (seq->flag & SEQ_MUTE) {
521 glDisable(GL_POLYGON_STIPPLE);
526 Draw a sequence strip, bounds check alredy made
527 ARegion is currently only used to get the windows width in pixels
528 so wave file sample drawing precision is zoom adjusted
530 static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *seq, int outline_tint, float pixelx)
533 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
534 View2D *v2d= &ar->v2d;
535 float x1, x2, y1, y2;
536 char col[3], background_col[3], is_single_image;
538 /* we need to know if this is a single image/color or not for drawing */
539 is_single_image = (char)check_single_seq(seq);
542 if(seq->startstill) x1= seq->start;
543 else x1= seq->startdisp;
544 y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
545 if(seq->endstill) x2= seq->start+seq->len;
546 else x2= seq->enddisp;
547 y2= seq->machine+SEQ_STRIP_OFSTOP;
550 /* get the correct color per strip type*/
551 //get_seq_color3ubv(scene, seq, col);
552 get_seq_color3ubv(scene, seq, background_col);
554 /* draw the main strip body */
555 if (is_single_image) /* single image */
556 draw_shadedstrip(seq, background_col, seq_tx_get_final_left(seq, 0), y1, seq_tx_get_final_right(seq, 0), y2);
557 else /* normal operation */
558 draw_shadedstrip(seq, background_col, x1, y1, x2, y2);
560 /* draw additional info and controls */
561 if (!is_single_image)
562 draw_seq_extensions(scene, sseq, seq);
564 draw_seq_handle(v2d, seq, pixelx, SEQ_LEFTHANDLE);
565 draw_seq_handle(v2d, seq, pixelx, SEQ_RIGHTHANDLE);
567 /* draw the strip outline */
571 get_seq_color3ubv(scene, seq, col);
572 if (G.moving && (seq->flag & SELECT)) {
573 if(seq->flag & SEQ_OVERLAP) {
574 col[0]= 255; col[1]= col[2]= 40;
575 } else UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 120);
578 UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, outline_tint);
580 glColor3ubv((GLubyte *)col);
582 if (seq->flag & SEQ_MUTE) {
583 glEnable(GL_LINE_STIPPLE);
584 glLineStipple(1, 0x8888);
587 gl_round_box_shade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
589 if (seq->flag & SEQ_MUTE) {
590 glDisable(GL_LINE_STIPPLE);
593 /* calculate if seq is long enough to print a name */
594 x1= seq->startdisp+seq->handsize;
595 x2= seq->enddisp-seq->handsize;
597 /* but first the contents of a meta */
598 if(seq->type==SEQ_META) drawmeta_contents(scene, seq, x1, y1+0.15, x2, y2-0.15);
600 /* info text on the strip */
601 if(x1<v2d->cur.xmin) x1= v2d->cur.xmin;
602 else if(x1>v2d->cur.xmax) x1= v2d->cur.xmax;
603 if(x2<v2d->cur.xmin) x2= v2d->cur.xmin;
604 else if(x2>v2d->cur.xmax) x2= v2d->cur.xmax;
606 /* nice text here would require changing the view matrix for texture text */
607 if( (x2-x1) / pixelx > 32) {
608 draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col);
612 static Sequence *special_seq_update= 0;
614 void set_special_seq_update(int val)
618 /* if mouse over a sequence && LEFTMOUSE */
620 // XXX special_seq_update= find_nearest_seq(&x);
622 else special_seq_update= 0;
626 static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq)
628 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
630 int x1, y1, rectx, recty;
632 static int recursive= 0;
635 float render_size = 0.0;
636 float proxy_size = 100.0;
638 glClearColor(0.0, 0.0, 0.0, 0.0);
639 glClear(GL_COLOR_BUFFER_BIT);
641 render_size = sseq->render_size;
642 if (render_size == 0) {
643 render_size = scene->r.size;
645 proxy_size = render_size;
647 if (render_size < 0) {
651 rectx= (render_size*scene->r.xsch)/100;
652 recty= (render_size*scene->r.ysch)/100;
654 /* BIG PROBLEM: the give_ibuf_seq() can call a rendering, which in turn calls redraws...
655 this shouldn't belong in a window drawing....
656 So: solve this once event based.
657 Now we check for recursion, space type and active area again (ton) */
663 if (special_seq_update) {
664 ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), proxy_size, special_seq_update);
666 else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
667 ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size);
670 ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size);
674 /* XXX HURMF! the give_ibuf_seq can call image display in this window */
675 // if(sa->spacetype!=SPACE_SEQ)
678 // areawinset(sa->win);
685 if(ibuf->rect==NULL && ibuf->rect_float == NULL)
688 switch(sseq->mainb) {
689 case SEQ_DRAW_IMG_IMBUF:
690 if (sseq->zebra != 0) {
691 ibuf = make_zebra_view_from_ibuf(ibuf, sseq->zebra);
695 case SEQ_DRAW_IMG_WAVEFORM:
696 if ((sseq->flag & SEQ_DRAW_COLOR_SEPERATED) != 0) {
697 ibuf = make_sep_waveform_view_from_ibuf(ibuf);
699 ibuf = make_waveform_view_from_ibuf(ibuf);
703 case SEQ_DRAW_IMG_VECTORSCOPE:
704 ibuf = make_vectorscope_view_from_ibuf(ibuf);
707 case SEQ_DRAW_IMG_HISTOGRAM:
708 ibuf = make_histogram_view_from_ibuf(ibuf);
713 if(ibuf->rect_float && ibuf->rect==NULL)
714 IMB_rect_from_float(ibuf);
716 /* needed for gla draw */
717 glaDefine2DArea(&ar->winrct);
719 zoom= SEQ_ZOOM_FAC(sseq->zoom);
720 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
721 zoom /= proxy_size / 100.0;
722 zoomx = zoom * ((float)scene->r.xasp / (float)scene->r.yasp);
725 zoomx = zoomy = zoom;
729 x1= (ar->winx-zoomx*ibuf->x)/2 + sseq->xof;
730 y1= (ar->winy-zoomy*ibuf->y)/2 + sseq->yof;
732 glPixelZoom(zoomx, zoomy);
734 glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
736 glPixelZoom(1.0, 1.0);
739 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF &&
740 (sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
742 float x2 = x1 + ibuf->x * zoomx;
743 float y2 = y1 + ibuf->y * zoomy;
745 float a= fac*(x2-x1);
753 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
756 UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);
759 gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
762 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
765 /* draw grease-pencil (image aligned) */
766 // if (sseq->flag & SEQ_DRAW_GPENCIL)
767 // XXX draw_gpencil_2dimage(sa, ibuf);
773 /* draw grease-pencil (screen aligned) */
774 // if (sseq->flag & SEQ_DRAW_GPENCIL)
775 // XXX draw_gpencil_2dview(sa, 0);
777 /* ortho at pixel level sa */
778 // XXX myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
782 void seq_reset_imageofs(SpaceSeq *sseq)
784 sseq->xof = sseq->yof = sseq->zoom = 0;
789 /* XXX - these should really be made to use View2D instead of so wacko private system - Aligorith */
791 void seq_viewzoom(SpaceSeq *sseq, unsigned short event, int invert)
797 sseq->zoom= (invert)? 2.0: 0.5;
799 sseq->zoom= (invert)? 4.0: 0.25;
801 sseq->zoom= (invert)? 8.0: 0.125;
803 /* ensure pixel exact locations for draw */
804 sseq->xof= (int)sseq->xof;
805 sseq->yof= (int)sseq->yof;
808 void seq_viewmove(Scene *scene, ARegion *ar, SpaceSeq *sseq)
810 short mval[2], mvalo[2];
811 short rectx, recty, xmin, xmax, ymin, ymax, pad;
816 rectx= (scene->r.size*scene->r.xsch)/100;
817 recty= (scene->r.size*scene->r.ysch)/100;
820 xmin = -(ar->winx/2) - rectx/2 + pad;
821 xmax = ar->winx/2 + rectx/2 - pad;
822 ymin = -(ar->winy/2) - recty/2 + pad;
823 ymax = ar->winy/2 + recty/2 - pad;
825 getmouseco_sc(mvalo);
827 oldcursor=get_cursor();
828 win=winlay_get_active_window();
830 SetBlenderCursor(BC_NSEW_SCROLLCURSOR);
832 while(get_mbut()&(L_MOUSE|M_MOUSE)) {
836 if(mvalo[0]!=mval[0] || mvalo[1]!=mval[1]) {
838 sseq->xof -= (mvalo[0]-mval[0]);
839 sseq->yof -= (mvalo[1]-mval[1]);
841 /* prevent dragging image outside of the window and losing it! */
842 CLAMP(sseq->xof, xmin, xmax);
843 CLAMP(sseq->yof, ymin, ymax);
853 void drawprefetchseqspace(Scene *scene, ARegion *ar, SpaceSeq *sseq)
856 int render_size = sseq->render_size;
857 int proxy_size = 100.0;
858 if (render_size == 0) {
859 render_size = scene->r.size;
861 proxy_size = render_size;
863 if (render_size < 0) {
867 rectx= (render_size*scene->r.xsch)/100;
868 recty= (render_size*scene->r.ysch)/100;
870 if(sseq->mainb != SEQ_DRAW_SEQUENCE) {
871 give_ibuf_prefetch_request(
872 rectx, recty, (scene->r.cfra), sseq->chanshown,
877 void drawseqspace(const bContext *C, ARegion *ar)
879 ScrArea *sa= CTX_wm_area(C);
880 SpaceSeq *sseq= sa->spacedata.first;
881 Scene *scene= CTX_data_scene(C);
882 View2D *v2d= &ar->v2d;
883 View2DScrollers *scrollers;
884 Editing *ed= seq_give_editing(scene, FALSE);
889 if(sseq->mainb != SEQ_DRAW_SEQUENCE) {
890 draw_image_seq(scene, ar, sseq);
894 UI_GetThemeColor3fv(TH_BACK, col);
895 if(ed && ed->metastack.first) glClearColor(col[0], col[1], col[2]-0.1, 0.0);
896 else glClearColor(col[0], col[1], col[2], 0.0);
898 glClear(GL_COLOR_BUFFER_BIT);
900 UI_view2d_view_ortho(C, v2d);
902 UI_ThemeColorShade(TH_BACK, -20);
903 glRectf(v2d->cur.xmin, 0.0, v2d->cur.xmax, 1.0);
905 boundbox_seq(scene, &v2d->tot);
907 /* Alternating horizontal stripes */
908 i= MAX2(1, ((int)v2d->cur.ymin)-1);
911 while (i<v2d->cur.ymax) {
913 UI_ThemeColorShade(TH_BACK, -15);
915 UI_ThemeColorShade(TH_BACK, -25);
917 glVertex2f(v2d->cur.xmax, i);
918 glVertex2f(v2d->cur.xmin, i);
919 glVertex2f(v2d->cur.xmin, i+1);
920 glVertex2f(v2d->cur.xmax, i+1);
925 /* Force grid lines */
926 i= MAX2(1, ((int)v2d->cur.ymin)-1);
929 while (i<v2d->cur.ymax) {
930 UI_ThemeColor(TH_GRID);
931 glVertex2f(v2d->cur.xmax, i);
932 glVertex2f(v2d->cur.xmin, i);
937 UI_view2d_constant_grid_draw(C, v2d);
939 draw_cfra_seq(v2d, scene->r.cfra);
941 /* sequences: first deselect */
943 Sequence *last_seq = active_seq_get(scene);
946 float pixelx = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin);
947 /* loop through twice, first unselected, then selected */
948 for (j=0; j<2; j++) {
949 seq= ed->seqbasep->first;
950 if (j==0) outline_tint = -150;
951 else outline_tint = -60;
953 while(seq) { /* bound box test, dont draw outside the view */
954 if ( ((seq->flag & SELECT) == sel) ||
956 MIN2(seq->startdisp, seq->start) > v2d->cur.xmax ||
957 MAX2(seq->enddisp, seq->start+seq->len) < v2d->cur.xmin ||
958 seq->machine+1.0 < v2d->cur.ymin ||
959 seq->machine > v2d->cur.ymax)
963 draw_seq_strip(scene, ar, sseq, seq, outline_tint, pixelx);
967 sel= SELECT; /* draw selected next time round */
969 /* draw the last selected last, removes some overlapping error */
971 draw_seq_strip(scene, ar, sseq, last_seq, 120, pixelx);
975 /* text draw cached, in pixelspace now */
976 UI_view2d_text_cache_draw(ar);
979 // draw_markers_timespace(SCE_MARKERS, DRAW_MARKERS_LINES);
982 UI_view2d_view_ortho(C, v2d);
983 ANIM_draw_previewrange(C, v2d);
985 /* reset view matrix */
986 UI_view2d_view_restore(C);
989 scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_SECONDSSEQ, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
990 UI_view2d_scrollers_draw(C, v2d, scrollers);
991 UI_view2d_scrollers_free(scrollers);