1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
|
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* Contributor(s): Blender Foundation, 2003-2009
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/space_sequencer/sequencer_draw.c
* \ingroup spseq
*/
#include <string.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "IMB_imbuf_types.h"
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_sound_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "IMB_imbuf.h"
#include "GPU_colors.h"
#include "GPU_primitives.h"
#include "BIF_glutil.h"
#include "ED_anim_api.h"
#include "ED_gpencil.h"
#include "ED_markers.h"
#include "ED_mask.h"
#include "ED_types.h"
#include "ED_space_api.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
/* own include */
#include "sequencer_intern.h"
#define SEQ_LEFTHANDLE 1
#define SEQ_RIGHTHANDLE 2
#define SEQ_HANDLE_SIZE_MIN 7.0f
#define SEQ_HANDLE_SIZE_MAX 40.0f
/* Note, Don't use SEQ_BEGIN/SEQ_END while drawing!
* it messes up transform, - Campbell */
static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2);
static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[3])
{
unsigned char blendcol[3];
SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
switch (seq->type) {
case SEQ_TYPE_IMAGE:
UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
break;
case SEQ_TYPE_META:
UI_GetThemeColor3ubv(TH_SEQ_META, col);
break;
case SEQ_TYPE_MOVIE:
UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
break;
case SEQ_TYPE_MOVIECLIP:
UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col);
break;
case SEQ_TYPE_MASK:
UI_GetThemeColor3ubv(TH_SEQ_MASK, col); /* TODO */
break;
case SEQ_TYPE_SCENE:
UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
if (seq->scene == curscene) {
UI_GetColorPtrShade3ubv(col, col, 20);
}
break;
/* transitions */
case SEQ_TYPE_CROSS:
case SEQ_TYPE_GAMCROSS:
case SEQ_TYPE_WIPE:
UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
/* slightly offset hue to distinguish different effects */
if (seq->type == SEQ_TYPE_CROSS) rgb_byte_set_hue_float_offset(col, 0.04);
if (seq->type == SEQ_TYPE_GAMCROSS) rgb_byte_set_hue_float_offset(col, 0.08);
if (seq->type == SEQ_TYPE_WIPE) rgb_byte_set_hue_float_offset(col, 0.12);
break;
/* effects */
case SEQ_TYPE_TRANSFORM:
case SEQ_TYPE_SPEED:
case SEQ_TYPE_ADD:
case SEQ_TYPE_SUB:
case SEQ_TYPE_MUL:
case SEQ_TYPE_ALPHAOVER:
case SEQ_TYPE_ALPHAUNDER:
case SEQ_TYPE_OVERDROP:
case SEQ_TYPE_GLOW:
case SEQ_TYPE_MULTICAM:
case SEQ_TYPE_ADJUSTMENT:
UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
/* slightly offset hue to distinguish different effects */
if (seq->type == SEQ_TYPE_ADD) rgb_byte_set_hue_float_offset(col, 0.04);
else if (seq->type == SEQ_TYPE_SUB) rgb_byte_set_hue_float_offset(col, 0.08);
else if (seq->type == SEQ_TYPE_MUL) rgb_byte_set_hue_float_offset(col, 0.12);
else if (seq->type == SEQ_TYPE_ALPHAOVER) rgb_byte_set_hue_float_offset(col, 0.16);
else if (seq->type == SEQ_TYPE_ALPHAUNDER) rgb_byte_set_hue_float_offset(col, 0.20);
else if (seq->type == SEQ_TYPE_OVERDROP) rgb_byte_set_hue_float_offset(col, 0.24);
else if (seq->type == SEQ_TYPE_GLOW) rgb_byte_set_hue_float_offset(col, 0.28);
else if (seq->type == SEQ_TYPE_TRANSFORM) rgb_byte_set_hue_float_offset(col, 0.36);
else if (seq->type == SEQ_TYPE_MULTICAM) rgb_byte_set_hue_float_offset(col, 0.32);
else if (seq->type == SEQ_TYPE_ADJUSTMENT) rgb_byte_set_hue_float_offset(col, 0.40);
break;
case SEQ_TYPE_COLOR:
if (colvars->col) {
rgb_float_to_uchar(col, colvars->col);
}
else {
col[0] = col[1] = col[2] = 128;
}
break;
case SEQ_TYPE_SOUND_RAM:
UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
blendcol[0] = blendcol[1] = blendcol[2] = 128;
if (seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
break;
default:
col[0] = 10; col[1] = 255; col[2] = 40;
}
}
static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x2, float y2, float stepsize)
{
/*
* x1 is the starting x value to draw the wave,
* x2 the end x value, same for y1 and y2
* stepsize is width of a pixel.
*/
if (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) {
int i, j, pos;
int length = floor((x2 - x1) / stepsize) + 1;
float ymid = (y1 + y2) / 2;
float yscale = (y2 - y1) / 2;
float samplestep;
float startsample, endsample;
float value;
SoundWaveform *waveform;
if (!seq->sound->waveform)
sound_read_waveform(seq->sound);
if (!seq->sound->waveform)
return; /* zero length sound */
waveform = seq->sound->waveform;
if (!waveform)
return;
startsample = floor((seq->startofs + seq->anim_startofs) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
samplestep = (endsample - startsample) * stepsize / (x2 - x1);
if (length > floor((waveform->length - startsample) / samplestep))
length = floor((waveform->length - startsample) / samplestep);
gpuBegin(GL_LINE_STRIP);
for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
value = waveform->data[pos * 3];
for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value > waveform->data[j * 3])
value = waveform->data[j * 3];
}
gpuVertex2f(x1 + i * stepsize, ymid + value * yscale);
}
gpuEnd();
gpuBegin(GL_LINE_STRIP);
for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
value = waveform->data[pos * 3 + 1];
for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value < waveform->data[j * 3 + 1])
value = waveform->data[j * 3 + 1];
}
gpuVertex2f(x1 + i * stepsize, ymid + value * yscale);
}
gpuEnd();
}
}
static void drawmeta_stipple(int value)
{
if (value) {
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_halftone);
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0x8888);
}
else {
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_LINE_STIPPLE);
}
}
static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
{
/* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
* seq->depth value, (needed by transform when doing overlap checks)
* so for now, just use the meta's immediate children, could be fixed but
* its only drawing - campbell */
Sequence *seq;
unsigned char col[4];
int chan_min = MAXSEQ;
int chan_max = 0;
int chan_range = 0;
float draw_range = y2 - y1;
float draw_height;
glEnable(GL_BLEND);
if (seqm->flag & SEQ_MUTE)
drawmeta_stipple(1);
for (seq = seqm->seqbase.first; seq; seq = seq->next) {
chan_min = MIN2(chan_min, seq->machine);
chan_max = MAX2(chan_max, seq->machine);
}
chan_range = (chan_max - chan_min) + 1;
draw_height = draw_range / chan_range;
col[3] = 196; /* alpha, used for all meta children */
for (seq = seqm->seqbase.first; seq; seq = seq->next) {
if ((seq->startdisp > x2 || seq->enddisp < x1) == 0) {
float y_chan = (seq->machine - chan_min) / (float)(chan_range) * draw_range;
float x1_chan = seq->startdisp;
float x2_chan = seq->enddisp;
float y1_chan, y2_chan;
if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
drawmeta_stipple(1);
get_seq_color3ubv(scene, seq, col);
gpuCurrentColor4ubv(col);
/* clamp within parent sequence strip bounds */
if (x1_chan < x1) x1_chan = x1;
if (x2_chan > x2) x2_chan = x2;
y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
gpuSingleFilledRectf(x1_chan, y1_chan, x2_chan, y2_chan);
UI_GetColorPtrShade3ubv(col, col, -30);
gpuCurrentColor4ubv(col);
gpuSingleWireRectf(x1_chan, y1_chan, x2_chan, y2_chan);
if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
drawmeta_stipple(0);
}
}
if (seqm->flag & SEQ_MUTE)
drawmeta_stipple(0);
glDisable(GL_BLEND);
}
/* clamp handles to defined size in pixel space */
static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
return CLAMPIS(seq->handsize, minhandle, maxhandle);
}
/* draw a handle, for each end of a sequence strip */
static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction)
{
float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
float x1, x2, y1, y2;
char numstr[32];
unsigned int whichsel = 0;
x1 = seq->startdisp;
x2 = seq->enddisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
/* set up co-ordinates/dimensions for either left or right handle */
if (direction == SEQ_LEFTHANDLE) {
rx1 = x1;
rx2 = x1 + handsize_clamped * 0.75f;
v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
whichsel = SEQ_LEFTSEL;
}
else if (direction == SEQ_RIGHTHANDLE) {
rx1 = x2 - handsize_clamped * 0.75f;
rx2 = x2;
v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
whichsel = SEQ_RIGHTSEL;
}
/* draw! */
if (seq->type < SEQ_TYPE_EFFECT ||
get_sequence_effect_num_inputs(seq->type) == 0)
{
glEnable(GL_BLEND);
if (seq->flag & whichsel) {
gpuCurrentColor4x(CPACK_BLACK, 0.314f);
}
else if (seq->flag & SELECT) {
gpuCurrentColor4x(CPACK_WHITE, 0.118f);
}
else {
gpuCurrentColor4x(CPACK_BLACK, 0.086f);
}
gpuSingleFilledRectf(rx1, y1, rx2, y2);
if (seq->flag & whichsel) {
gpuCurrentColor4x(CPACK_WHITE, 0.784f);
}
else {
gpuCurrentColor4x(CPACK_BLACK, 0.196f);
}
glEnable(GL_POLYGON_SMOOTH);
gpuBegin(GL_TRIANGLES);
gpuVertex2fv(v1); gpuVertex2fv(v2); gpuVertex2fv(v3);
gpuEnd();
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_BLEND);
}
if (G.moving || (seq->flag & whichsel)) {
const char col[4] = {255, 255, 255, 255};
if (direction == SEQ_LEFTHANDLE) {
BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp);
x1 = rx1;
y1 -= 0.45f;
}
else {
BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
x1 = x2 - handsize_clamped * 0.75f;
y1 = y2 + 0.05f;
}
UI_view2d_text_cache_add(v2d, x1, y1, numstr, col);
}
}
static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
{
float x1, x2, y1, y2, pixely, a;
unsigned char col[3], blendcol[3];
View2D *v2d = &ar->v2d;
if (seq->type >= SEQ_TYPE_EFFECT) return;
x1 = seq->startdisp;
x2 = seq->enddisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
pixely = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
if (pixely <= 0) return; /* can happen when the view is split/resized */
blendcol[0] = blendcol[1] = blendcol[2] = 120;
gpuImmediateFormat_V2(); // DOODLE: sequencer extensions
if (seq->startofs) {
glEnable(GL_BLEND);
get_seq_color3ubv(scene, seq, col);
if (seq->flag & SELECT) {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
gpuCurrentColor4ub(col[0], col[1], col[2], 170);
}
else {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
gpuCurrentColor4ub(col[0], col[1], col[2], 110);
}
gpuDrawFilledRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
if (seq->flag & SELECT) gpuCurrentColor4ub(col[0], col[1], col[2], 255);
else gpuCurrentColor4ub(col[0], col[1], col[2], 160);
gpuDrawWireRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); //outline
glDisable(GL_BLEND);
}
if (seq->endofs) {
glEnable(GL_BLEND);
get_seq_color3ubv(scene, seq, col);
if (seq->flag & SELECT) {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
gpuCurrentColor4ub(col[0], col[1], col[2], 170);
}
else {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
gpuCurrentColor4ub(col[0], col[1], col[2], 110);
}
gpuDrawFilledRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
if (seq->flag & SELECT) gpuCurrentColor4ub(col[0], col[1], col[2], 255);
else gpuCurrentColor4ub(col[0], col[1], col[2], 160);
gpuDrawWireRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline
glDisable(GL_BLEND);
}
if (seq->startstill) {
get_seq_color3ubv(scene, seq, col);
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
gpuCurrentColor3ubv((GLubyte *)col);
draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
/* feint pinstripes, helps see exactly which is extended and which isn't,
* especially when the extension is very small */
if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
else UI_GetColorPtrShade3ubv(col, col, -16);
gpuCurrentColor3ubv((GLubyte *)col);
gpuBegin(GL_LINES);
for (a = y1; a < y2; a += pixely * 2.0f) {
gpuAppendLinef(x1, a, (float)(seq->start), a);
}
gpuEnd();
}
if (seq->endstill) {
get_seq_color3ubv(scene, seq, col);
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
gpuCurrentColor3ubv((GLubyte *)col);
draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2);
/* feint pinstripes, helps see exactly which is extended and which isn't,
* especially when the extension is very small */
if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
else UI_GetColorPtrShade3ubv(col, col, -16);
gpuCurrentColor3ubv((GLubyte *)col);
gpuBegin(GL_LINES);
for (a = y1; a < y2; a += pixely * 2.0f) {
gpuAppendLinef((float)(seq->start + seq->len), a, x2, a);
}
gpuEnd();
}
gpuImmediateUnformat();
}
/* draw info text on a sequence strip */
static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3])
{
rctf rect;
char str[32 + FILE_MAX];
const char *name = seq->name + 2;
char col[4];
/* note, all strings should include 'name' */
if (name[0] == '\0')
name = give_seqname(seq);
if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
}
else if (seq->type == SEQ_TYPE_SCENE) {
if (seq->scene) {
if (seq->scene_camera) {
BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d",
name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len);
}
else {
BLI_snprintf(str, sizeof(str), "%s: %s | %d",
name, seq->scene->id.name + 2, seq->len);
}
}
else {
BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) {
BLI_snprintf(str, sizeof(str), "%s: %s | %d",
name, seq->clip->id.name + 2, seq->len);
}
else {
BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MASK) {
if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) {
BLI_snprintf(str, sizeof(str), "%s: %s | %d",
name, seq->mask->id.name + 2, seq->len);
}
else {
BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
}
else if (seq->type == SEQ_TYPE_MULTICAM) {
BLI_snprintf(str, sizeof(str), "Cam %s: %d",
name, seq->multicam_source);
}
else if (seq->type == SEQ_TYPE_IMAGE) {
BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
}
else if (seq->type & SEQ_TYPE_EFFECT) {
BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
else if (seq->type == SEQ_TYPE_SOUND_RAM) {
if (seq->sound)
BLI_snprintf(str, sizeof(str), "%s: %s | %d",
name, seq->sound->name, seq->len);
else
BLI_snprintf(str, sizeof(str), "%s | %d",
name, seq->len);
}
else if (seq->type == SEQ_TYPE_MOVIE) {
BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
}
if (seq->flag & SELECT) {
col[0] = col[1] = col[2] = 255;
}
else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) {
col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */
}
else {
col[0] = col[1] = col[2] = 0;
}
col[3] = 255;
rect.xmin = x1;
rect.ymin = y1;
rect.xmax = x2;
rect.ymax = y2;
UI_view2d_text_cache_rectf(v2d, &rect, str, col);
}
/* draws a shaded strip, made from gradient + flat color + gradient */
static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2)
{
float ymid1, ymid2;
if (seq->flag & SEQ_MUTE) {
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_halftone);
}
ymid1 = (y2 - y1) * 0.25f + y1;
ymid2 = (y2 - y1) * 0.65f + y1;
glShadeModel(GL_SMOOTH);
gpuBegin(GL_QUADS);
if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
else if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50);
/* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */
gpuColor3ubv(col);
gpuVertex2f(x1, y1);
gpuVertex2f(x2, y1);
if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; }
else if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5);
else UI_GetColorPtrShade3ubv(col, col, -5);
gpuColor3ubv((GLubyte *)col);
gpuVertex2f(x2, ymid1);
gpuVertex2f(x1, ymid1);
gpuEnd();
gpuSingleFilledRectf(x1, ymid1, x2, ymid2);
gpuBegin(GL_QUADS);
gpuVertex2f(x1, ymid2);
gpuVertex2f(x2, ymid2);
if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15);
else UI_GetColorPtrShade3ubv(col, col, 25);
gpuColor3ubv((GLubyte *)col);
gpuVertex2f(x2, y2);
gpuVertex2f(x1, y2);
gpuEnd();
if (seq->flag & SEQ_MUTE) {
glDisable(GL_POLYGON_STIPPLE);
}
}
/*
* Draw a sequence strip, bounds check already made
* ARegion is currently only used to get the windows width in pixels
* so wave file sample drawing precision is zoom adjusted
*/
static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline_tint, float pixelx)
{
View2D *v2d = &ar->v2d;
float x1, x2, y1, y2;
unsigned char col[3], background_col[3], is_single_image;
const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
/* we need to know if this is a single image/color or not for drawing */
is_single_image = (char)seq_single_check(seq);
/* body */
x1 = (seq->startstill) ? seq->start : seq->startdisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
/* get the correct color per strip type*/
//get_seq_color3ubv(scene, seq, col);
get_seq_color3ubv(scene, seq, background_col);
/* draw the main strip body */
if (is_single_image) { /* single image */
draw_shadedstrip(seq, background_col, seq_tx_get_final_left(seq, 0), y1, seq_tx_get_final_right(seq, 0), y2);
}
else { /* normal operation */
draw_shadedstrip(seq, background_col, x1, y1, x2, y2);
}
/* draw additional info and controls */
if (!is_single_image)
draw_seq_extensions(scene, ar, seq);
draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE);
draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE);
/* draw the strip outline */
x1 = seq->startdisp;
x2 = seq->enddisp;
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin) / ar->winx);
}
/* draw lock */
if (seq->flag & SEQ_LOCK) {
glEnable(GL_POLYGON_STIPPLE);
glEnable(GL_BLEND);
/* light stripes */
gpuCurrentColor4x(CPACK_WHITE, 0.125f);
glPolygonStipple(stipple_diag_stripes_pos);
gpuSingleFilledRectf(x1, y1, x2, y2);
/* dark stripes */
gpuCurrentColor4x(CPACK_BLACK, 0.125f);
glPolygonStipple(stipple_diag_stripes_neg);
gpuSingleFilledRectf(x1, y1, x2, y2);
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_BLEND);
}
get_seq_color3ubv(scene, seq, col);
if (G.moving && (seq->flag & SELECT)) {
if (seq->flag & SEQ_OVERLAP) {
col[0] = 255; col[1] = col[2] = 40;
}
else
UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint);
}
else
UI_GetColorPtrShade3ubv(col, col, outline_tint);
gpuCurrentColor3ubv((GLubyte *)col);
if (seq->flag & SEQ_MUTE) {
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0x8888);
}
uiDrawBoxShade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
if (seq->flag & SEQ_MUTE) {
glDisable(GL_LINE_STIPPLE);
}
if (seq->type == SEQ_TYPE_META) {
drawmeta_contents(scene, seq, x1, y1, x2, y2);
}
/* calculate if seq is long enough to print a name */
x1 = seq->startdisp + handsize_clamped;
x2 = seq->enddisp - handsize_clamped;
/* info text on the strip */
if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin;
else if (x1 > v2d->cur.xmax) x1 = v2d->cur.xmax;
if (x2 < v2d->cur.xmin) x2 = v2d->cur.xmin;
else if (x2 > v2d->cur.xmax) x2 = v2d->cur.xmax;
/* nice text here would require changing the view matrix for texture text */
if ((x2 - x1) / pixelx > 32) {
draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col);
}
}
static Sequence *special_seq_update = NULL;
static void UNUSED_FUNCTION(set_special_seq_update) (int val)
{
// int x;
/* if mouse over a sequence && LEFTMOUSE */
if (val) {
// XXX special_seq_update= find_nearest_seq(&x);
}
else special_seq_update = NULL;
}
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
{
struct Main *bmain = CTX_data_main(C);
struct ImBuf *ibuf = NULL;
struct ImBuf *scope = NULL;
struct View2D *v2d = &ar->v2d;
int rectx, recty;
float viewrectx, viewrecty;
float render_size = 0.0;
float proxy_size = 100.0;
float col[3];
GLuint texid;
GLuint last_texid;
SeqRenderData context;
render_size = sseq->render_size;
if (render_size == 0) {
render_size = scene->r.size;
}
else {
proxy_size = render_size;
}
if (render_size < 0) {
return;
}
viewrectx = (render_size * (float)scene->r.xsch) / 100.0f;
viewrecty = (render_size * (float)scene->r.ysch) / 100.0f;
rectx = viewrectx + 0.5f;
recty = viewrecty + 0.5f;
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
viewrectx *= scene->r.xasp / scene->r.yasp;
viewrectx /= proxy_size / 100.0f;
viewrecty /= proxy_size / 100.0f;
}
if (frame_ofs == 0) {
UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
}
/* without this colors can flicker from previous opengl state */
gpuCurrentColor3x(CPACK_WHITE);
UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f);
UI_view2d_curRect_validate(v2d);
/* only initialize the preview if a render is in progress */
if (G.rendering)
return;
context = seq_new_render_data(bmain, scene, rectx, recty, proxy_size);
if (special_seq_update)
ibuf = give_ibuf_seq_direct(context, cfra + frame_ofs, special_seq_update);
else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
ibuf = give_ibuf_seq(context, cfra + frame_ofs, sseq->chanshown);
else
ibuf = give_ibuf_seq_threaded(context, cfra + frame_ofs, sseq->chanshown);
if (ibuf == NULL)
return;
if (ibuf->rect == NULL && ibuf->rect_float == NULL)
return;
switch (sseq->mainb) {
case SEQ_DRAW_IMG_IMBUF:
if (sseq->zebra != 0) {
scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra);
}
break;
case SEQ_DRAW_IMG_WAVEFORM:
if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
scope = make_sep_waveform_view_from_ibuf(ibuf);
}
else {
scope = make_waveform_view_from_ibuf(ibuf);
}
break;
case SEQ_DRAW_IMG_VECTORSCOPE:
scope = make_vectorscope_view_from_ibuf(ibuf);
break;
case SEQ_DRAW_IMG_HISTOGRAM:
scope = make_histogram_view_from_ibuf(ibuf);
break;
}
if (scope) {
IMB_freeImBuf(ibuf);
ibuf = scope;
}
if (ibuf->rect_float && ibuf->rect == NULL) {
IMB_rect_from_float(ibuf);
}
/* setting up the view - actual drawing starts here */
UI_view2d_view_ortho(v2d);
last_texid = glaGetOneInteger(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, (GLuint *)&texid);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
gpuBegin(GL_QUADS);
if (frame_ofs) {
rctf tot_clip;
tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin);
tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin);
tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax);
tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax);
gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); gpuVertex2f(tot_clip.xmin, tot_clip.ymin);
gpuTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); gpuVertex2f(tot_clip.xmin, tot_clip.ymax);
gpuTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); gpuVertex2f(tot_clip.xmax, tot_clip.ymax);
gpuTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); gpuVertex2f(tot_clip.xmax, tot_clip.ymin);
}
else {
gpuTexCoord2f(0.0f, 0.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymin);
gpuTexCoord2f(0.0f, 1.0f); gpuVertex2f(v2d->tot.xmin, v2d->tot.ymax);
gpuTexCoord2f(1.0f, 1.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymax);
gpuTexCoord2f(1.0f, 0.0f); gpuVertex2f(v2d->tot.xmax, v2d->tot.ymin);
}
gpuEnd();
glBindTexture(GL_TEXTURE_2D, last_texid);
glDisable(GL_TEXTURE_2D);
glDeleteTextures(1, &texid);
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
float x1 = v2d->tot.xmin;
float y1 = v2d->tot.ymin;
float x2 = v2d->tot.xmax;
float y2 = v2d->tot.ymax;
/* border */
setlinestyle(3);
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);
gpuBegin(GL_LINE_LOOP);
gpuVertex2f(x1 - 0.5f, y1 - 0.5f);
gpuVertex2f(x1 - 0.5f, y2 + 0.5f);
gpuVertex2f(x2 + 0.5f, y2 + 0.5f);
gpuVertex2f(x2 + 0.5f, y1 - 0.5f);
gpuEnd();
/* safety border */
if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
float fac = 0.1;
float a = fac * (x2 - x1);
x1 += a;
x2 -= a;
a = fac * (y2 - y1);
y1 += a;
y2 -= a;
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
uiSetRoundBox(UI_CNR_ALL);
uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
setlinestyle(0);
}
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
IMB_freeImBuf(ibuf);
/* ortho at pixel level */
UI_view2d_view_restore(C);
/* draw grease-pencil (screen aligned) */
draw_gpencil_view2d(C, 0);
//if (sc->mode == SC_MODE_MASKEDIT) {
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
Sequence *seq_act = BKE_sequencer_active_get(scene);
if (seq_act && seq_act->type == SEQ_TYPE_MASK && seq_act->mask) {
int x, y;
int width, height;
float zoomx, zoomy;
/* frame image */
float maxdim;
float xofs, yofs;
/* find window pixel coordinates of origin */
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
width = v2d->tot.xmax - v2d->tot.xmin;
height = v2d->tot.ymax - v2d->tot.ymin;
zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin));
zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin));
x += v2d->tot.xmin * zoomx;
y += v2d->tot.ymin * zoomy;
/* frame the image */
maxdim = maxf(width, height);
if (width == height) {
xofs = yofs = 0;
}
else if (width < height) {
xofs = ((height - width) / -2.0f) * zoomx;
yofs = 0.0f;
}
else { /* (width > height) */
xofs = 0.0f;
yofs = ((width - height) / -2.0f) * zoomy;
}
/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
gpuPushMatrix();
gpuTranslate(x + xofs, y + yofs, 0);
gpuScale(maxdim * zoomx, maxdim * zoomy, 0);
ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
gpuPopMatrix();
}
}
}
#if 0
void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
{
int rectx, recty;
int render_size = sseq->render_size;
int proxy_size = 100.0;
if (render_size == 0) {
render_size = scene->r.size;
}
else {
proxy_size = render_size;
}
if (render_size < 0) {
return;
}
rectx = (render_size * scene->r.xsch) / 100;
recty = (render_size * scene->r.ysch) / 100;
if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
give_ibuf_prefetch_request(
rectx, recty, (scene->r.cfra), sseq->chanshown,
proxy_size);
}
}
#endif
/* draw backdrop of the sequencer strips view */
static void draw_seq_backdrop(View2D *v2d)
{
int i;
/* darker gray overlay over the view backdrop */
gpuImmediateFormat_V2();
UI_ThemeColorShade(TH_BACK, -20);
gpuDrawFilledRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
/* Alternating horizontal stripes */
i = MAX2(1, ((int)v2d->cur.ymin) - 1);
gpuBegin(GL_QUADS);
while (i < v2d->cur.ymax) {
if (((int)i) & 1)
UI_ThemeAppendColorShade(TH_BACK, -15);
else
UI_ThemeAppendColorShade(TH_BACK, -25);
gpuVertex2f(v2d->cur.xmax, i);
gpuVertex2f(v2d->cur.xmin, i);
gpuVertex2f(v2d->cur.xmin, i + 1);
gpuVertex2f(v2d->cur.xmax, i + 1);
i += 1.0;
}
gpuEnd();
/* Darker lines separating the horizontal bands */
i = MAX2(1, ((int)v2d->cur.ymin) - 1);
UI_ThemeColor(TH_GRID);
gpuBegin(GL_LINES);
while (i < v2d->cur.ymax) {
gpuVertex2f(v2d->cur.xmax, i);
gpuVertex2f(v2d->cur.xmin, i);
i += 1.0;
}
gpuEnd();
gpuImmediateUnformat();
}
/* draw the contents of the sequencer strips view */
static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = &ar->v2d;
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
float pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
Sequence *seq;
int outline_tint = (j) ? -60 : -150; /* highlighting around strip edges indicating selection */
/* loop through strips, checking for those that are visible */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
/* boundbox and selection tests for NOT drawing the strip... */
if ((seq->flag & SELECT) != sel) continue;
else if (seq == last_seq) continue;
else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
else if (MAX2(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
else if (seq->machine > v2d->cur.ymax) continue;
/* strip passed all tests unscathed... so draw it now */
draw_seq_strip(scene, ar, seq, outline_tint, pixelx);
}
/* draw selected next time round */
sel = SELECT;
}
/* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
if (last_seq)
draw_seq_strip(scene, ar, last_seq, 120, pixelx);
}
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
{
glEnable(GL_BLEND);
/* draw darkened area outside of active timeline
* frame range used is preview range or scene range */
UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);
if (PSFRA < PEFRA) {
gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
gpuSingleFilledRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
gpuSingleFilledRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
gpuImmediateFormat_V2(); // DOODLE: two lines, start frame & end frame (copy paste code)
gpuBegin(GL_LINES);
gpuAppendLinef((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
gpuAppendLinef((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
gpuEnd();
gpuImmediateUnformat();
glDisable(GL_BLEND);
}
/* Draw Timeline/Strip Editor Mode for Sequencer */
void draw_timeline_seq(const bContext *C, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
SpaceSeq *sseq = CTX_wm_space_seq(C);
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
short unit = 0, flag = 0;
float col[3];
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
if (ed && ed->metastack.first)
glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f);
else
glClearColor(col[0], col[1], col[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
/* calculate extents of sequencer strips/data
* NOTE: needed for the scrollers later
*/
boundbox_seq(scene, &v2d->tot);
/* draw backdrop */
draw_seq_backdrop(v2d);
/* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */
// NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30...
UI_view2d_constant_grid_draw(v2d);
seq_draw_sfra_efra(scene, v2d);
/* sequence strips (if there is data available to be drawn) */
if (ed) {
/* draw the data */
draw_seq_strips(C, ed, ar);
/* text draw cached (for sequence names), in pixelspace now */
UI_view2d_text_cache_draw(ar);
}
/* current frame */
UI_view2d_view_ortho(v2d);
if ((sseq->flag & SEQ_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX;
ANIM_draw_cfra(C, v2d, flag);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
draw_markers_time(C, DRAW_MARKERS_LINES);
/* preview range */
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d);
/* overlap playhead */
if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
gpuCurrentGray3f(0.200f);
// gpuSingleFilledRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
gpuSingleLinef(cfra_over, v2d->cur.ymin, cfra_over, v2d->cur.ymax);
}
/* reset view matrix */
UI_view2d_view_restore(C);
/* scrollers */
unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDSSEQ;
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
|