~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_sequencer/sequencer_draw.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

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