2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation, 2003-2009
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/editors/space_sequencer/sequencer_draw.c
34 #include "MEM_guardedalloc.h"
36 #include "BLI_blenlib.h"
38 #include "BLI_utildefines.h"
40 #include "IMB_imbuf_types.h"
42 #include "DNA_scene_types.h"
43 #include "DNA_mask_types.h"
44 #include "DNA_screen_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_userdef_types.h"
47 #include "DNA_sound_types.h"
49 #include "BKE_context.h"
50 #include "BKE_global.h"
51 #include "BKE_sequencer.h"
53 #include "BKE_sound.h"
55 #include "IMB_colormanagement.h"
56 #include "IMB_imbuf.h"
59 #include "BIF_glutil.h"
61 #include "ED_anim_api.h"
62 #include "ED_gpencil.h"
63 #include "ED_markers.h"
65 #include "ED_sequencer.h"
67 #include "ED_space_api.h"
69 #include "UI_interface.h"
70 #include "UI_resources.h"
71 #include "UI_view2d.h"
77 #include "sequencer_intern.h"
80 #define SEQ_LEFTHANDLE 1
81 #define SEQ_RIGHTHANDLE 2
83 #define SEQ_HANDLE_SIZE_MIN 7.0f
84 #define SEQ_HANDLE_SIZE_MAX 40.0f
87 /* Note, Don't use SEQ_BEGIN/SEQ_END while drawing!
88 * it messes up transform, - Campbell */
89 static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2);
91 static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[3])
93 unsigned char blendcol[3];
94 SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
98 UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
102 UI_GetThemeColor3ubv(TH_SEQ_META, col);
106 UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
109 case SEQ_TYPE_MOVIECLIP:
110 UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col);
114 UI_GetThemeColor3ubv(TH_SEQ_MASK, col); /* TODO */
118 UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
120 if (seq->scene == curscene) {
121 UI_GetColorPtrShade3ubv(col, col, 20);
127 case SEQ_TYPE_GAMCROSS:
129 UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
131 /* slightly offset hue to distinguish different effects */
132 if (seq->type == SEQ_TYPE_CROSS) rgb_byte_set_hue_float_offset(col, 0.04);
133 if (seq->type == SEQ_TYPE_GAMCROSS) rgb_byte_set_hue_float_offset(col, 0.08);
134 if (seq->type == SEQ_TYPE_WIPE) rgb_byte_set_hue_float_offset(col, 0.12);
138 case SEQ_TYPE_TRANSFORM:
143 case SEQ_TYPE_ALPHAOVER:
144 case SEQ_TYPE_ALPHAUNDER:
145 case SEQ_TYPE_OVERDROP:
147 case SEQ_TYPE_MULTICAM:
148 case SEQ_TYPE_ADJUSTMENT:
149 UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
151 /* slightly offset hue to distinguish different effects */
152 if (seq->type == SEQ_TYPE_ADD) rgb_byte_set_hue_float_offset(col, 0.04);
153 else if (seq->type == SEQ_TYPE_SUB) rgb_byte_set_hue_float_offset(col, 0.08);
154 else if (seq->type == SEQ_TYPE_MUL) rgb_byte_set_hue_float_offset(col, 0.12);
155 else if (seq->type == SEQ_TYPE_ALPHAOVER) rgb_byte_set_hue_float_offset(col, 0.16);
156 else if (seq->type == SEQ_TYPE_ALPHAUNDER) rgb_byte_set_hue_float_offset(col, 0.20);
157 else if (seq->type == SEQ_TYPE_OVERDROP) rgb_byte_set_hue_float_offset(col, 0.24);
158 else if (seq->type == SEQ_TYPE_GLOW) rgb_byte_set_hue_float_offset(col, 0.28);
159 else if (seq->type == SEQ_TYPE_TRANSFORM) rgb_byte_set_hue_float_offset(col, 0.36);
160 else if (seq->type == SEQ_TYPE_MULTICAM) rgb_byte_set_hue_float_offset(col, 0.32);
161 else if (seq->type == SEQ_TYPE_ADJUSTMENT) rgb_byte_set_hue_float_offset(col, 0.40);
166 rgb_float_to_uchar(col, colvars->col);
169 col[0] = col[1] = col[2] = 128;
173 case SEQ_TYPE_SOUND_RAM:
174 UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
175 blendcol[0] = blendcol[1] = blendcol[2] = 128;
176 if (seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
180 col[0] = 10; col[1] = 255; col[2] = 40;
184 static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x2, float y2, float stepsize)
187 * x1 is the starting x value to draw the wave,
188 * x2 the end x value, same for y1 and y2
189 * stepsize is width of a pixel.
191 if (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) {
193 int length = floor((x2 - x1) / stepsize) + 1;
194 float ymid = (y1 + y2) / 2;
195 float yscale = (y2 - y1) / 2;
197 float startsample, endsample;
200 SoundWaveform *waveform;
202 if (!seq->sound->waveform)
203 sound_read_waveform(seq->sound);
205 if (!seq->sound->waveform)
206 return; /* zero length sound */
208 waveform = seq->sound->waveform;
213 startsample = floor((seq->startofs + seq->anim_startofs) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
214 endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
215 samplestep = (endsample - startsample) * stepsize / (x2 - x1);
217 if (length > floor((waveform->length - startsample) / samplestep))
218 length = floor((waveform->length - startsample) / samplestep);
220 glBegin(GL_LINE_STRIP);
221 for (i = 0; i < length; i++) {
222 pos = startsample + i * samplestep;
224 value = waveform->data[pos * 3];
226 for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
227 if (value > waveform->data[j * 3])
228 value = waveform->data[j * 3];
231 glVertex2f(x1 + i * stepsize, ymid + value * yscale);
235 glBegin(GL_LINE_STRIP);
236 for (i = 0; i < length; i++) {
237 pos = startsample + i * samplestep;
239 value = waveform->data[pos * 3 + 1];
241 for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
242 if (value < waveform->data[j * 3 + 1])
243 value = waveform->data[j * 3 + 1];
246 glVertex2f(x1 + i * stepsize, ymid + value * yscale);
252 static void drawmeta_stipple(int value)
255 glEnable(GL_POLYGON_STIPPLE);
256 glPolygonStipple(stipple_halftone);
258 glEnable(GL_LINE_STIPPLE);
259 glLineStipple(1, 0x8888);
262 glDisable(GL_POLYGON_STIPPLE);
263 glDisable(GL_LINE_STIPPLE);
267 static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
269 /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
270 * seq->depth value, (needed by transform when doing overlap checks)
271 * so for now, just use the meta's immediate children, could be fixed but
272 * its only drawing - campbell */
274 unsigned char col[4];
276 int chan_min = MAXSEQ;
279 float draw_range = y2 - y1;
283 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
285 if (seqm->flag & SEQ_MUTE)
288 for (seq = seqm->seqbase.first; seq; seq = seq->next) {
289 chan_min = min_ii(chan_min, seq->machine);
290 chan_max = max_ii(chan_max, seq->machine);
293 chan_range = (chan_max - chan_min) + 1;
294 draw_height = draw_range / chan_range;
296 col[3] = 196; /* alpha, used for all meta children */
298 for (seq = seqm->seqbase.first; seq; seq = seq->next) {
299 if ((seq->startdisp > x2 || seq->enddisp < x1) == 0) {
300 float y_chan = (seq->machine - chan_min) / (float)(chan_range) * draw_range;
301 float x1_chan = seq->startdisp;
302 float x2_chan = seq->enddisp;
303 float y1_chan, y2_chan;
305 if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
308 get_seq_color3ubv(scene, seq, col);
312 /* clamp within parent sequence strip bounds */
313 if (x1_chan < x1) x1_chan = x1;
314 if (x2_chan > x2) x2_chan = x2;
316 y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
317 y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
319 glRectf(x1_chan, y1_chan, x2_chan, y2_chan);
321 UI_GetColorPtrShade3ubv(col, col, -30);
323 fdrawbox(x1_chan, y1_chan, x2_chan, y2_chan);
325 if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
330 if (seqm->flag & SEQ_MUTE)
336 /* clamp handles to defined size in pixel space */
337 static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx)
339 const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
340 const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
341 return CLAMPIS(seq->handsize, minhandle, maxhandle);
344 /* draw a handle, for each end of a sequence strip */
345 static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction)
347 float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
348 float x1, x2, y1, y2;
350 unsigned int whichsel = 0;
355 y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
356 y2 = seq->machine + SEQ_STRIP_OFSTOP;
358 /* set up co-ordinates/dimensions for either left or right handle */
359 if (direction == SEQ_LEFTHANDLE) {
361 rx2 = x1 + handsize_clamped * 0.75f;
363 v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
364 v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
365 v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
367 whichsel = SEQ_LEFTSEL;
369 else if (direction == SEQ_RIGHTHANDLE) {
370 rx1 = x2 - handsize_clamped * 0.75f;
373 v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
374 v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
375 v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
377 whichsel = SEQ_RIGHTSEL;
381 if (seq->type < SEQ_TYPE_EFFECT ||
382 BKE_sequence_effect_get_num_inputs(seq->type) == 0)
386 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
388 if (seq->flag & whichsel) glColor4ub(0, 0, 0, 80);
389 else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30);
390 else glColor4ub(0, 0, 0, 22);
392 glRectf(rx1, y1, rx2, y2);
394 if (seq->flag & whichsel) glColor4ub(255, 255, 255, 200);
395 else glColor4ub(0, 0, 0, 50);
397 glEnable(GL_POLYGON_SMOOTH);
398 glBegin(GL_TRIANGLES);
399 glVertex2fv(v1); glVertex2fv(v2); glVertex2fv(v3);
402 glDisable(GL_POLYGON_SMOOTH);
406 if (G.moving || (seq->flag & whichsel)) {
407 const char col[4] = {255, 255, 255, 255};
408 if (direction == SEQ_LEFTHANDLE) {
409 BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp);
414 BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
415 x1 = x2 - handsize_clamped * 0.75f;
418 UI_view2d_text_cache_add(v2d, x1, y1, numstr, col);
422 static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
424 float x1, x2, y1, y2, pixely, a;
425 unsigned char col[3], blendcol[3];
426 View2D *v2d = &ar->v2d;
428 if (seq->type >= SEQ_TYPE_EFFECT) return;
433 y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
434 y2 = seq->machine + SEQ_STRIP_OFSTOP;
436 pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
438 if (pixely <= 0) return; /* can happen when the view is split/resized */
440 blendcol[0] = blendcol[1] = blendcol[2] = 120;
444 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
446 get_seq_color3ubv(scene, seq, col);
448 if (seq->flag & SELECT) {
449 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
450 glColor4ub(col[0], col[1], col[2], 170);
453 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
454 glColor4ub(col[0], col[1], col[2], 110);
457 glRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
459 if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
460 else glColor4ub(col[0], col[1], col[2], 160);
462 fdrawbox((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); //outline
468 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
470 get_seq_color3ubv(scene, seq, col);
472 if (seq->flag & SELECT) {
473 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
474 glColor4ub(col[0], col[1], col[2], 170);
477 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
478 glColor4ub(col[0], col[1], col[2], 110);
481 glRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
483 if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
484 else glColor4ub(col[0], col[1], col[2], 160);
486 fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
490 if (seq->startstill) {
491 get_seq_color3ubv(scene, seq, col);
492 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
493 glColor3ubv((GLubyte *)col);
495 draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
497 /* feint pinstripes, helps see exactly which is extended and which isn't,
498 * especially when the extension is very small */
499 if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
500 else UI_GetColorPtrShade3ubv(col, col, -16);
502 glColor3ubv((GLubyte *)col);
504 for (a = y1; a < y2; a += pixely * 2.0f) {
505 fdrawline(x1, a, (float)(seq->start), a);
509 get_seq_color3ubv(scene, seq, col);
510 UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
511 glColor3ubv((GLubyte *)col);
513 draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2);
515 /* feint pinstripes, helps see exactly which is extended and which isn't,
516 * especially when the extension is very small */
517 if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
518 else UI_GetColorPtrShade3ubv(col, col, -16);
520 glColor3ubv((GLubyte *)col);
522 for (a = y1; a < y2; a += pixely * 2.0f) {
523 fdrawline((float)(seq->start + seq->len), a, x2, a);
528 /* draw info text on a sequence strip */
529 static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3])
532 char str[32 + FILE_MAX];
533 const char *name = seq->name + 2;
536 /* note, all strings should include 'name' */
538 name = BKE_sequence_give_name(seq);
540 if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
541 BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
543 else if (seq->type == SEQ_TYPE_SCENE) {
545 if (seq->scene_camera) {
546 BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d",
547 name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len);
550 BLI_snprintf(str, sizeof(str), "%s: %s | %d",
551 name, seq->scene->id.name + 2, seq->len);
555 BLI_snprintf(str, sizeof(str), "%s | %d",
559 else if (seq->type == SEQ_TYPE_MOVIECLIP) {
560 if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) {
561 BLI_snprintf(str, sizeof(str), "%s: %s | %d",
562 name, seq->clip->id.name + 2, seq->len);
565 BLI_snprintf(str, sizeof(str), "%s | %d",
569 else if (seq->type == SEQ_TYPE_MASK) {
570 if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) {
571 BLI_snprintf(str, sizeof(str), "%s: %s | %d",
572 name, seq->mask->id.name + 2, seq->len);
575 BLI_snprintf(str, sizeof(str), "%s | %d",
579 else if (seq->type == SEQ_TYPE_MULTICAM) {
580 BLI_snprintf(str, sizeof(str), "Cam %s: %d",
581 name, seq->multicam_source);
583 else if (seq->type == SEQ_TYPE_IMAGE) {
584 BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
585 name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
587 else if (seq->type & SEQ_TYPE_EFFECT) {
588 BLI_snprintf(str, sizeof(str), "%s | %d",
591 else if (seq->type == SEQ_TYPE_SOUND_RAM) {
593 BLI_snprintf(str, sizeof(str), "%s: %s | %d",
594 name, seq->sound->name, seq->len);
596 BLI_snprintf(str, sizeof(str), "%s | %d",
599 else if (seq->type == SEQ_TYPE_MOVIE) {
600 BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
601 name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
604 if (seq->flag & SELECT) {
605 col[0] = col[1] = col[2] = 255;
607 else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) {
608 col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */
611 col[0] = col[1] = col[2] = 0;
619 UI_view2d_text_cache_rectf(v2d, &rect, str, col);
622 /* draws a shaded strip, made from gradient + flat color + gradient */
623 static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2)
627 if (seq->flag & SEQ_MUTE) {
628 glEnable(GL_POLYGON_STIPPLE);
629 glPolygonStipple(stipple_halftone);
632 ymid1 = (y2 - y1) * 0.25f + y1;
633 ymid2 = (y2 - y1) * 0.65f + y1;
635 glShadeModel(GL_SMOOTH);
638 if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
639 else if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50);
640 /* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */
647 if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
648 else if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5);
649 else UI_GetColorPtrShade3ubv(col, col, -5);
651 glColor3ubv((GLubyte *)col);
653 glVertex2f(x2, ymid1);
654 glVertex2f(x1, ymid1);
658 glRectf(x1, ymid1, x2, ymid2);
662 glVertex2f(x1, ymid2);
663 glVertex2f(x2, ymid2);
665 if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15);
666 else UI_GetColorPtrShade3ubv(col, col, 25);
668 glColor3ubv((GLubyte *)col);
675 if (seq->flag & SEQ_MUTE) {
676 glDisable(GL_POLYGON_STIPPLE);
681 * Draw a sequence strip, bounds check already made
682 * ARegion is currently only used to get the windows width in pixels
683 * so wave file sample drawing precision is zoom adjusted
685 static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline_tint, float pixelx)
687 View2D *v2d = &ar->v2d;
688 float x1, x2, y1, y2;
689 unsigned char col[3], background_col[3], is_single_image;
690 const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
692 /* we need to know if this is a single image/color or not for drawing */
693 is_single_image = (char)BKE_sequence_single_check(seq);
696 x1 = (seq->startstill) ? seq->start : seq->startdisp;
697 y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
698 x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
699 y2 = seq->machine + SEQ_STRIP_OFSTOP;
702 /* get the correct color per strip type*/
703 //get_seq_color3ubv(scene, seq, col);
704 get_seq_color3ubv(scene, seq, background_col);
706 /* draw the main strip body */
707 if (is_single_image) { /* single image */
708 draw_shadedstrip(seq, background_col,
709 BKE_sequence_tx_get_final_left(seq, 0), y1,
710 BKE_sequence_tx_get_final_right(seq, 0), y2);
712 else { /* normal operation */
713 draw_shadedstrip(seq, background_col, x1, y1, x2, y2);
716 /* draw additional info and controls */
717 if (!is_single_image)
718 draw_seq_extensions(scene, ar, seq);
720 draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE);
721 draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE);
723 /* draw the strip outline */
727 /* draw sound wave */
728 if (seq->type == SEQ_TYPE_SOUND_RAM) {
729 drawseqwave(scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
733 if (seq->flag & SEQ_LOCK) {
734 glEnable(GL_POLYGON_STIPPLE);
738 glColor4ub(255, 255, 255, 32);
739 glPolygonStipple(stipple_diag_stripes_pos);
740 glRectf(x1, y1, x2, y2);
743 glColor4ub(0, 0, 0, 32);
744 glPolygonStipple(stipple_diag_stripes_neg);
745 glRectf(x1, y1, x2, y2);
747 glDisable(GL_POLYGON_STIPPLE);
751 if (!BKE_sequence_is_valid_check(seq)) {
752 glEnable(GL_POLYGON_STIPPLE);
755 glColor4ub(255, 0, 0, 255);
756 glPolygonStipple(stipple_diag_stripes_pos);
757 glRectf(x1, y1, x2, y2);
759 glDisable(GL_POLYGON_STIPPLE);
762 get_seq_color3ubv(scene, seq, col);
763 if (G.moving && (seq->flag & SELECT)) {
764 if (seq->flag & SEQ_OVERLAP) {
765 col[0] = 255; col[1] = col[2] = 40;
768 UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint);
771 UI_GetColorPtrShade3ubv(col, col, outline_tint);
773 glColor3ubv((GLubyte *)col);
775 if (seq->flag & SEQ_MUTE) {
776 glEnable(GL_LINE_STIPPLE);
777 glLineStipple(1, 0x8888);
780 uiDrawBoxShade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
782 if (seq->flag & SEQ_MUTE) {
783 glDisable(GL_LINE_STIPPLE);
786 if (seq->type == SEQ_TYPE_META) {
787 drawmeta_contents(scene, seq, x1, y1, x2, y2);
790 /* calculate if seq is long enough to print a name */
791 x1 = seq->startdisp + handsize_clamped;
792 x2 = seq->enddisp - handsize_clamped;
794 /* info text on the strip */
795 if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin;
796 else if (x1 > v2d->cur.xmax) x1 = v2d->cur.xmax;
797 if (x2 < v2d->cur.xmin) x2 = v2d->cur.xmin;
798 else if (x2 > v2d->cur.xmax) x2 = v2d->cur.xmax;
800 /* nice text here would require changing the view matrix for texture text */
801 if ((x2 - x1) / pixelx > 32) {
802 draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col);
806 static Sequence *special_seq_update = NULL;
808 static void UNUSED_FUNCTION(set_special_seq_update) (int val)
812 /* if mouse over a sequence && LEFTMOUSE */
814 // XXX special_seq_update = find_nearest_seq(&x);
817 special_seq_update = NULL;
821 ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs)
823 SeqRenderData context;
826 float render_size = 0.0;
827 float proxy_size = 100.0;
828 short is_break = G.is_break;
830 render_size = sseq->render_size;
831 if (render_size == 0) {
832 render_size = scene->r.size;
835 proxy_size = render_size;
838 if (render_size < 0) {
842 rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f;
843 recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
845 context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size);
847 /* sequencer could start rendering, in this case we need to be sure it wouldn't be canceled
848 * by Esc pressed somewhere in the past
852 if (special_seq_update)
853 ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update);
854 else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
855 ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown);
857 ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown);
859 /* restore state so real rendering would be canceled (if needed) */
860 G.is_break = is_break;
865 static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf)
867 if (scopes->reference_ibuf != ibuf) {
868 if (scopes->zebra_ibuf) {
869 IMB_freeImBuf(scopes->zebra_ibuf);
870 scopes->zebra_ibuf = NULL;
873 if (scopes->waveform_ibuf) {
874 IMB_freeImBuf(scopes->waveform_ibuf);
875 scopes->waveform_ibuf = NULL;
878 if (scopes->sep_waveform_ibuf) {
879 IMB_freeImBuf(scopes->sep_waveform_ibuf);
880 scopes->sep_waveform_ibuf = NULL;
883 if (scopes->vector_ibuf) {
884 IMB_freeImBuf(scopes->vector_ibuf);
885 scopes->vector_ibuf = NULL;
888 if (scopes->histogram_ibuf) {
889 IMB_freeImBuf(scopes->histogram_ibuf);
890 scopes->histogram_ibuf = NULL;
895 static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf))
897 ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
900 IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
901 &scene->display_settings);
903 scope = make_scope_cb(display_ibuf);
905 IMB_freeImBuf(display_ibuf);
910 void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
912 struct Main *bmain = CTX_data_main(C);
913 struct ImBuf *ibuf = NULL;
914 struct ImBuf *scope = NULL;
915 struct View2D *v2d = &ar->v2d;
916 /* int rectx, recty; */ /* UNUSED */
917 float viewrectx, viewrecty;
918 float render_size = 0.0;
919 float proxy_size = 100.0;
923 void *display_buffer;
924 void *cache_handle = NULL;
925 const int is_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
927 bool glsl_used = false;
929 if (G.is_rendering == FALSE && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
930 /* stop all running jobs, except screen one. currently previews frustrate Render
931 * needed to make so sequencer's rendering doesn't conflict with compositor
933 WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_COMPOSITE);
935 if ((scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
936 /* in case of final rendering used for preview, kill all previews,
937 * otherwise threading conflict will happen in rendering module
939 WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_RENDER_PREVIEW);
943 render_size = sseq->render_size;
944 if (render_size == 0) {
945 render_size = scene->r.size;
948 proxy_size = render_size;
950 if (render_size < 0) {
954 viewrectx = (render_size * (float)scene->r.xsch) / 100.0f;
955 viewrecty = (render_size * (float)scene->r.ysch) / 100.0f;
957 /* rectx = viewrectx + 0.5f; */ /* UNUSED */
958 /* recty = viewrecty + 0.5f; */ /* UNUSED */
960 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
961 viewrectx *= scene->r.xasp / scene->r.yasp;
962 viewrectx /= proxy_size / 100.0f;
963 viewrecty /= proxy_size / 100.0f;
966 if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
967 UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
968 glClearColor(col[0], col[1], col[2], 0.0);
969 glClear(GL_COLOR_BUFFER_BIT);
972 /* without this colors can flicker from previous opengl state */
973 glColor4ub(255, 255, 255, 255);
975 UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f);
976 UI_view2d_curRect_validate(v2d);
978 /* only initialize the preview if a render is in progress */
982 ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs);
987 if (ibuf->rect == NULL && ibuf->rect_float == NULL)
990 if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) {
991 SequencerScopes *scopes = &sseq->scopes;
993 sequencer_check_scopes(scopes, ibuf);
995 switch (sseq->mainb) {
996 case SEQ_DRAW_IMG_IMBUF:
997 if (!scopes->zebra_ibuf) {
998 ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
1000 if (display_ibuf->rect_float) {
1001 IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
1002 &scene->display_settings);
1004 scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
1005 IMB_freeImBuf(display_ibuf);
1007 scope = scopes->zebra_ibuf;
1009 case SEQ_DRAW_IMG_WAVEFORM:
1010 if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
1011 if (!scopes->sep_waveform_ibuf)
1012 scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
1013 scope = scopes->sep_waveform_ibuf;
1016 if (!scopes->waveform_ibuf)
1017 scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
1018 scope = scopes->waveform_ibuf;
1021 case SEQ_DRAW_IMG_VECTORSCOPE:
1022 if (!scopes->vector_ibuf)
1023 scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
1024 scope = scopes->vector_ibuf;
1026 case SEQ_DRAW_IMG_HISTOGRAM:
1027 if (!scopes->histogram_ibuf)
1028 scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
1029 scope = scopes->histogram_ibuf;
1033 scopes->reference_ibuf = ibuf;
1036 /* setting up the view - actual drawing starts here */
1037 UI_view2d_view_ortho(v2d);
1039 /* only draw alpha for main buffer */
1040 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
1041 if (sseq->flag & SEQ_USE_ALPHA) {
1043 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1045 fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
1046 glColor4f(1.0, 1.0, 1.0, 1.0);
1051 IMB_freeImBuf(ibuf);
1054 if (ibuf->rect_float && ibuf->rect == NULL) {
1055 IMB_rect_from_float(ibuf);
1058 display_buffer = (unsigned char *)ibuf->rect;
1060 type = GL_UNSIGNED_BYTE;
1063 bool force_fallback = false;
1065 force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
1066 force_fallback |= (ibuf->dither != 0.0f);
1068 if (force_fallback) {
1069 /* Fallback to CPU based color space conversion */
1072 type = GL_UNSIGNED_BYTE;
1073 display_buffer = NULL;
1075 else if (ibuf->rect_float) {
1076 display_buffer = ibuf->rect_float;
1078 if (ibuf->channels == 4) {
1081 else if (ibuf->channels == 3) {
1085 BLI_assert(!"Incompatible number of channels for float buffer in sequencer");
1087 display_buffer = NULL;
1092 if (ibuf->float_colorspace) {
1093 glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->float_colorspace, TRUE);
1096 glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, TRUE);
1099 else if (ibuf->rect) {
1100 display_buffer = ibuf->rect;
1102 type = GL_UNSIGNED_BYTE;
1104 glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, FALSE);
1108 type = GL_UNSIGNED_BYTE;
1109 display_buffer = NULL;
1112 /* there's a data to be displayed, but GLSL is not initialized
1113 * properly, in this case we fallback to CPU-based display transform
1115 if ((ibuf->rect || ibuf->rect_float) && !glsl_used) {
1116 display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
1118 type = GL_UNSIGNED_BYTE;
1122 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1123 glColor4f(1.0, 1.0, 1.0, 1.0);
1125 last_texid = glaGetOneInteger(GL_TEXTURE_2D);
1126 glEnable(GL_TEXTURE_2D);
1127 glGenTextures(1, (GLuint *)&texid);
1129 glBindTexture(GL_TEXTURE_2D, texid);
1131 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1132 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1134 if (type == GL_FLOAT)
1135 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, ibuf->x, ibuf->y, 0, format, type, display_buffer);
1137 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer);
1142 if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
1144 tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
1145 tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
1146 tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
1147 tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
1149 glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
1150 glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
1151 glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax);
1152 glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin);
1154 else if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
1155 glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
1156 glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
1157 glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
1158 glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
1162 glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
1163 glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
1164 glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
1165 glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
1168 glBindTexture(GL_TEXTURE_2D, last_texid);
1169 glDisable(GL_TEXTURE_2D);
1170 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA)
1171 glDisable(GL_BLEND);
1172 glDeleteTextures(1, &texid);
1175 IMB_colormanagement_finish_glsl_draw();
1177 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
1179 float x1 = v2d->tot.xmin;
1180 float y1 = v2d->tot.ymin;
1181 float x2 = v2d->tot.xmax;
1182 float y2 = v2d->tot.ymax;
1187 UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);
1189 glBegin(GL_LINE_LOOP);
1190 glVertex2f(x1 - 0.5f, y1 - 0.5f);
1191 glVertex2f(x1 - 0.5f, y2 + 0.5f);
1192 glVertex2f(x2 + 0.5f, y2 + 0.5f);
1193 glVertex2f(x2 + 0.5f, y1 - 0.5f);
1197 if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
1200 float a = fac * (x2 - x1);
1204 a = fac * (y2 - y1);
1208 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1210 uiSetRoundBox(UI_CNR_ALL);
1211 uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
1213 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1220 if (sseq->flag & SEQ_SHOW_GPENCIL) {
1222 /* draw grease-pencil (image aligned) */
1223 draw_gpencil_2dimage(C);
1228 IMB_freeImBuf(ibuf);
1230 /* ortho at pixel level */
1231 UI_view2d_view_restore(C);
1233 if (sseq->flag & SEQ_SHOW_GPENCIL) {
1235 /* draw grease-pencil (screen aligned) */
1236 draw_gpencil_view2d(C, 0);
1241 /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
1242 * for now just disable drawing since the strip frame will likely be offset */
1244 //if (sc->mode == SC_MODE_MASKEDIT) {
1245 if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
1246 Mask *mask = BKE_sequencer_mask_get(scene);
1250 float aspx = 1.0f, aspy = 1.0f;
1251 // ED_mask_get_size(C, &width, &height);
1253 //Scene *scene = CTX_data_scene(C);
1254 width = (scene->r.size * scene->r.xsch) / 100;
1255 height = (scene->r.size * scene->r.ysch) / 100;
1257 ED_mask_draw_region(mask, ar,
1267 IMB_display_buffer_release(cache_handle);
1271 void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
1274 int render_size = sseq->render_size;
1275 int proxy_size = 100.0;
1276 if (render_size == 0) {
1277 render_size = scene->r.size;
1280 proxy_size = render_size;
1282 if (render_size < 0) {
1286 rectx = (render_size * scene->r.xsch) / 100;
1287 recty = (render_size * scene->r.ysch) / 100;
1289 if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
1290 give_ibuf_prefetch_request(
1291 rectx, recty, (scene->r.cfra), sseq->chanshown,
1297 /* draw backdrop of the sequencer strips view */
1298 static void draw_seq_backdrop(View2D *v2d)
1302 /* darker gray overlay over the view backdrop */
1303 UI_ThemeColorShade(TH_BACK, -20);
1304 glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
1306 /* Alternating horizontal stripes */
1307 i = max_ii(1, ((int)v2d->cur.ymin) - 1);
1310 while (i < v2d->cur.ymax) {
1312 UI_ThemeColorShade(TH_BACK, -15);
1314 UI_ThemeColorShade(TH_BACK, -25);
1316 glVertex2f(v2d->cur.xmax, i);
1317 glVertex2f(v2d->cur.xmin, i);
1318 glVertex2f(v2d->cur.xmin, i + 1);
1319 glVertex2f(v2d->cur.xmax, i + 1);
1325 /* Darker lines separating the horizontal bands */
1326 i = max_ii(1, ((int)v2d->cur.ymin) - 1);
1327 UI_ThemeColor(TH_GRID);
1330 while (i < v2d->cur.ymax) {
1331 glVertex2f(v2d->cur.xmax, i);
1332 glVertex2f(v2d->cur.xmin, i);
1339 /* draw the contents of the sequencer strips view */
1340 static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
1342 Scene *scene = CTX_data_scene(C);
1343 View2D *v2d = &ar->v2d;
1344 Sequence *last_seq = BKE_sequencer_active_get(scene);
1346 float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
1348 /* loop through twice, first unselected, then selected */
1349 for (j = 0; j < 2; j++) {
1351 int outline_tint = (j) ? -60 : -150; /* highlighting around strip edges indicating selection */
1353 /* loop through strips, checking for those that are visible */
1354 for (seq = ed->seqbasep->first; seq; seq = seq->next) {
1355 /* boundbox and selection tests for NOT drawing the strip... */
1356 if ((seq->flag & SELECT) != sel) continue;
1357 else if (seq == last_seq) continue;
1358 else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
1359 else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
1360 else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
1361 else if (seq->machine > v2d->cur.ymax) continue;
1363 /* strip passed all tests unscathed... so draw it now */
1364 draw_seq_strip(scene, ar, seq, outline_tint, pixelx);
1367 /* draw selected next time round */
1371 /* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
1373 draw_seq_strip(scene, ar, last_seq, 120, pixelx);
1376 static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
1380 /* draw darkened area outside of active timeline
1381 * frame range used is preview range or scene range */
1382 UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);
1384 if (PSFRA < PEFRA+1) {
1385 glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
1386 glRectf((float)(PEFRA + 1), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
1389 glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
1392 UI_ThemeColorShade(TH_BACK, -60);
1393 /* thin lines where the actual frames are */
1394 fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
1395 fdrawline((float)(PEFRA + 1), v2d->cur.ymin, (float)(PEFRA + 1), v2d->cur.ymax);
1397 glDisable(GL_BLEND);
1400 /* Draw Timeline/Strip Editor Mode for Sequencer */
1401 void draw_timeline_seq(const bContext *C, ARegion *ar)
1403 Scene *scene = CTX_data_scene(C);
1404 Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
1405 SpaceSeq *sseq = CTX_wm_space_seq(C);
1406 View2D *v2d = &ar->v2d;
1407 View2DScrollers *scrollers;
1408 short unit = 0, flag = 0;
1411 /* clear and setup matrix */
1412 UI_GetThemeColor3fv(TH_BACK, col);
1413 if (ed && ed->metastack.first)
1414 glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f);
1416 glClearColor(col[0], col[1], col[2], 0.0f);
1417 glClear(GL_COLOR_BUFFER_BIT);
1419 UI_view2d_view_ortho(v2d);
1422 /* calculate extents of sequencer strips/data
1423 * NOTE: needed for the scrollers later
1425 boundbox_seq(scene, &v2d->tot);
1429 draw_seq_backdrop(v2d);
1431 /* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */
1432 // NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30...
1433 UI_view2d_constant_grid_draw(v2d);
1435 ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
1437 seq_draw_sfra_efra(scene, v2d);
1439 /* sequence strips (if there is data available to be drawn) */
1442 draw_seq_strips(C, ed, ar);
1444 /* text draw cached (for sequence names), in pixelspace now */
1445 UI_view2d_text_cache_draw(ar);
1449 UI_view2d_view_ortho(v2d);
1450 if ((sseq->flag & SEQ_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
1451 if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX;
1452 ANIM_draw_cfra(C, v2d, flag);
1455 UI_view2d_view_orthoSpecial(ar, v2d, 1);
1456 draw_markers_time(C, DRAW_MARKERS_LINES);
1459 UI_view2d_view_ortho(v2d);
1460 ANIM_draw_previewrange(C, v2d, 1);
1462 /* overlap playhead */
1463 if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
1464 int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
1465 glColor3f(0.2, 0.2, 0.2);
1466 // glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
1469 glVertex2f(cfra_over, v2d->cur.ymin);
1470 glVertex2f(cfra_over, v2d->cur.ymax);
1476 ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
1478 /* reset view matrix */
1479 UI_view2d_view_restore(C);
1482 unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDSSEQ;
1483 scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
1484 UI_view2d_scrollers_draw(C, v2d, scrollers);
1485 UI_view2d_scrollers_free(scrollers);