Blender V2.61 - r43446

sequencer_draw.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * Contributor(s): Blender Foundation, 2003-2009
00022  *
00023  * ***** END GPL LICENSE BLOCK *****
00024  */
00025 
00031 #include <string.h>
00032 #include <math.h>
00033 
00034 #include "MEM_guardedalloc.h"
00035 
00036 #include "BLI_blenlib.h"
00037 #include "BLI_math.h"
00038 #include "BLI_utildefines.h"
00039 
00040 #include "IMB_imbuf_types.h"
00041 
00042 #include "DNA_scene_types.h"
00043 #include "DNA_screen_types.h"
00044 #include "DNA_space_types.h"
00045 #include "DNA_userdef_types.h"
00046 #include "DNA_sound_types.h"
00047 
00048 #include "BKE_context.h"
00049 #include "BKE_global.h"
00050 #include "BKE_sequencer.h"
00051 
00052 #include "BKE_sound.h"
00053 
00054 #include "IMB_imbuf.h"
00055 
00056 #include "BIF_gl.h"
00057 #include "BIF_glutil.h"
00058 
00059 #include "ED_anim_api.h"
00060 #include "ED_markers.h"
00061 #include "ED_types.h"
00062 
00063 #include "UI_interface.h"
00064 #include "UI_resources.h"
00065 #include "UI_view2d.h"
00066 
00067 /* own include */
00068 #include "sequencer_intern.h"
00069 
00070 
00071 #define SEQ_LEFTHANDLE      1
00072 #define SEQ_RIGHTHANDLE 2
00073 
00074 
00075 /* Note, Dont use SEQ_BEGIN/SEQ_END while drawing!
00076  * it messes up transform, - Campbell */
00077 static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2);
00078 
00079 static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[3])
00080 {
00081     unsigned char blendcol[3];
00082     SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
00083 
00084     switch(seq->type) {
00085     case SEQ_IMAGE:
00086         UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
00087         break;
00088         
00089     case SEQ_META:
00090         UI_GetThemeColor3ubv(TH_SEQ_META, col);
00091         break;
00092         
00093     case SEQ_MOVIE:
00094         UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
00095         break;
00096         
00097     case SEQ_SCENE:
00098         UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
00099         
00100         if(seq->scene==curscene) {
00101             UI_GetColorPtrShade3ubv(col, col, 20);
00102         }
00103         break;
00104         
00105     /* transitions */
00106     case SEQ_CROSS:
00107     case SEQ_GAMCROSS:
00108     case SEQ_WIPE:
00109         UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
00110 
00111         /* slightly offset hue to distinguish different effects */
00112         if (seq->type == SEQ_CROSS)         rgb_byte_set_hue_float_offset(col,0.04);
00113         if (seq->type == SEQ_GAMCROSS)      rgb_byte_set_hue_float_offset(col,0.08);
00114         if (seq->type == SEQ_WIPE)          rgb_byte_set_hue_float_offset(col,0.12);
00115         break;
00116         
00117     /* effects */
00118     case SEQ_TRANSFORM:
00119     case SEQ_SPEED:
00120     case SEQ_ADD:
00121     case SEQ_SUB:
00122     case SEQ_MUL:
00123     case SEQ_ALPHAOVER:
00124     case SEQ_ALPHAUNDER:
00125     case SEQ_OVERDROP:
00126     case SEQ_GLOW:
00127     case SEQ_MULTICAM:
00128     case SEQ_ADJUSTMENT:
00129         UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
00130         
00131         /* slightly offset hue to distinguish different effects */
00132         if (seq->type == SEQ_ADD)           rgb_byte_set_hue_float_offset(col,0.04);
00133         if (seq->type == SEQ_SUB)           rgb_byte_set_hue_float_offset(col,0.08);
00134         if (seq->type == SEQ_MUL)           rgb_byte_set_hue_float_offset(col,0.12);
00135         if (seq->type == SEQ_ALPHAOVER)     rgb_byte_set_hue_float_offset(col,0.16);
00136         if (seq->type == SEQ_ALPHAUNDER)    rgb_byte_set_hue_float_offset(col,0.20);
00137         if (seq->type == SEQ_OVERDROP)      rgb_byte_set_hue_float_offset(col,0.24);
00138         if (seq->type == SEQ_GLOW)          rgb_byte_set_hue_float_offset(col,0.28);
00139         if (seq->type == SEQ_TRANSFORM)     rgb_byte_set_hue_float_offset(col,0.36);
00140         if (seq->type == SEQ_MULTICAM)      rgb_byte_set_hue_float_offset(col,0.32);
00141         if (seq->type == SEQ_ADJUSTMENT)        rgb_byte_set_hue_float_offset(col,0.40);
00142         break;
00143         
00144     case SEQ_COLOR:
00145         if (colvars->col) {
00146             rgb_float_to_byte(colvars->col, col);
00147         } else {
00148             col[0] = col[1] = col[2] = 128;
00149         }
00150         break;
00151         
00152     case SEQ_PLUGIN:
00153         UI_GetThemeColor3ubv(TH_SEQ_PLUGIN, col);
00154         break;
00155         
00156     case SEQ_SOUND:
00157         UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
00158         blendcol[0] = blendcol[1] = blendcol[2] = 128;
00159         if(seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
00160         break;
00161         
00162     default:
00163         col[0] = 10; col[1] = 255; col[2] = 40;
00164     }
00165 }
00166 
00167 static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x2, float y2, float stepsize)
00168 {
00169     /*
00170     x1 is the starting x value to draw the wave,
00171     x2 the end x value, same for y1 and y2
00172     stepsize is width of a pixel.
00173     */
00174     if(seq->flag & SEQ_AUDIO_DRAW_WAVEFORM)
00175     {
00176         int i, j, pos;
00177         int length = floor((x2-x1)/stepsize)+1;
00178         float ymid = (y1+y2)/2;
00179         float yscale = (y2-y1)/2;
00180         float samplestep;
00181         float startsample, endsample;
00182         float value;
00183 
00184         SoundWaveform* waveform;
00185 
00186         if(!seq->sound->waveform)
00187             sound_read_waveform(seq->sound);
00188 
00189         if(!seq->sound->waveform)
00190             return; /* zero length sound */
00191 
00192         waveform = seq->sound->waveform;
00193 
00194         if(!waveform)
00195             return;
00196 
00197         startsample = floor((seq->startofs + seq->anim_startofs)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
00198         endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
00199         samplestep = (endsample-startsample) * stepsize / (x2-x1);
00200 
00201         if(length > floor((waveform->length - startsample) / samplestep))
00202             length = floor((waveform->length - startsample) / samplestep);
00203 
00204         glBegin(GL_LINE_STRIP);
00205         for(i = 0; i < length; i++)
00206         {
00207             pos = startsample + i * samplestep;
00208 
00209             value = waveform->data[pos * 3];
00210 
00211             for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++)
00212             {
00213                 if(value > waveform->data[j * 3])
00214                     value = waveform->data[j * 3];
00215             }
00216 
00217             glVertex2f(x1+i*stepsize, ymid + value * yscale);
00218         }
00219         glEnd();
00220 
00221         glBegin(GL_LINE_STRIP);
00222         for(i = 0; i < length; i++)
00223         {
00224             pos = startsample + i * samplestep;
00225 
00226             value = waveform->data[pos * 3 + 1];
00227 
00228             for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++)
00229             {
00230                 if(value < waveform->data[j * 3 + 1])
00231                     value = waveform->data[j * 3 + 1];
00232             }
00233 
00234             glVertex2f(x1+i*stepsize, ymid + value * yscale);
00235         }
00236         glEnd();
00237     }
00238 }
00239 
00240 static void drawmeta_stipple(int value)
00241 {
00242     if(value) {
00243         glEnable(GL_POLYGON_STIPPLE);
00244         glPolygonStipple(stipple_halftone);
00245         
00246         glEnable(GL_LINE_STIPPLE);
00247         glLineStipple(1, 0x8888);
00248     }
00249     else {
00250         glDisable(GL_POLYGON_STIPPLE);
00251         glDisable(GL_LINE_STIPPLE);
00252     }
00253 }
00254 
00255 static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
00256 {
00257     /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
00258      * seq->depth value, (needed by transform when doing overlap checks)
00259      * so for now, just use the meta's immediate children, could be fixed but
00260      * its only drawing - campbell */
00261     Sequence *seq;
00262     unsigned char col[4];
00263 
00264     int chan_min= MAXSEQ;
00265     int chan_max= 0;
00266     int chan_range= 0;
00267     float draw_range= y2 - y1;
00268     float draw_height;
00269 
00270     glEnable(GL_BLEND);
00271     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00272 
00273     if(seqm->flag & SEQ_MUTE)
00274         drawmeta_stipple(1);
00275 
00276     for (seq= seqm->seqbase.first; seq; seq= seq->next) {
00277         chan_min= MIN2(chan_min, seq->machine);
00278         chan_max= MAX2(chan_max, seq->machine);
00279     }
00280 
00281     chan_range= (chan_max - chan_min) + 1;
00282     draw_height= draw_range / chan_range; 
00283 
00284     col[3]= 196; /* alpha, used for all meta children */
00285 
00286     for (seq= seqm->seqbase.first; seq; seq= seq->next) {
00287         if((seq->startdisp > x2 || seq->enddisp < x1) == 0) {
00288             float y_chan= (seq->machine - chan_min) / (float)(chan_range) * draw_range;
00289             float x1_chan= seq->startdisp;
00290             float x2_chan= seq->enddisp;
00291             float y1_chan, y2_chan;
00292 
00293             if((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
00294                 drawmeta_stipple(1);
00295 
00296             get_seq_color3ubv(scene, seq, col);
00297 
00298             glColor4ubv(col);
00299             
00300             /* clamp within parent sequence strip bounds */
00301             if(x1_chan < x1) x1_chan= x1;
00302             if(x2_chan > x2) x2_chan= x2;
00303 
00304             y1_chan= y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
00305             y2_chan= y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
00306 
00307             glRectf(x1_chan,  y1_chan, x2_chan,  y2_chan);
00308 
00309             UI_GetColorPtrShade3ubv(col, col, -30);
00310             glColor4ubv(col);
00311             fdrawbox(x1_chan,  y1_chan, x2_chan,  y2_chan);
00312 
00313             if((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE))
00314                 drawmeta_stipple(0);
00315         }
00316     }
00317 
00318     if (seqm->flag & SEQ_MUTE)
00319         drawmeta_stipple(0);
00320     
00321     glDisable(GL_BLEND);
00322 }
00323 
00324 /* draw a handle, for each end of a sequence strip */
00325 static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short direction)
00326 {
00327     float v1[2], v2[2], v3[2], rx1=0, rx2=0; //for triangles and rect
00328     float x1, x2, y1, y2;
00329     float handsize;
00330     float minhandle, maxhandle;
00331     char numstr[32];
00332     unsigned int whichsel=0;
00333     
00334     x1= seq->startdisp;
00335     x2= seq->enddisp;
00336     
00337     y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
00338     y2= seq->machine+SEQ_STRIP_OFSTOP;
00339     
00340     /* clamp handles to defined size in pixel space */
00341     handsize = seq->handsize;
00342     minhandle = 7;
00343     maxhandle = 40;
00344     CLAMP(handsize, minhandle*pixelx, maxhandle*pixelx);
00345     
00346     /* set up co-ordinates/dimensions for either left or right handle */
00347     if (direction == SEQ_LEFTHANDLE) {  
00348         rx1 = x1;
00349         rx2 = x1+handsize * 0.75f;
00350         
00351         v1[0]= x1+handsize/4; v1[1]= y1+( ((y1+y2)/2.0f - y1)/2);
00352         v2[0]= x1+handsize/4; v2[1]= y2-( ((y1+y2)/2.0f - y1)/2);
00353         v3[0]= v2[0] + handsize/4; v3[1]= (y1+y2)/2.0f;
00354         
00355         whichsel = SEQ_LEFTSEL;
00356     } else if (direction == SEQ_RIGHTHANDLE) {  
00357         rx1 = x2-handsize*0.75f;
00358         rx2 = x2;
00359         
00360         v1[0]= x2-handsize/4; v1[1]= y1+( ((y1+y2)/2.0f - y1)/2);
00361         v2[0]= x2-handsize/4; v2[1]= y2-( ((y1+y2)/2.0f - y1)/2);
00362         v3[0]= v2[0] - handsize/4; v3[1]= (y1+y2)/2.0f;
00363         
00364         whichsel = SEQ_RIGHTSEL;
00365     }
00366     
00367     /* draw! */
00368     if(seq->type < SEQ_EFFECT || 
00369        get_sequence_effect_num_inputs(seq->type) == 0) {
00370         glEnable( GL_BLEND );
00371         
00372         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00373         
00374         if(seq->flag & whichsel) glColor4ub(0, 0, 0, 80);
00375         else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30);
00376         else glColor4ub(0, 0, 0, 22);
00377         
00378         glRectf(rx1, y1, rx2, y2);
00379         
00380         if(seq->flag & whichsel) glColor4ub(255, 255, 255, 200);
00381         else glColor4ub(0, 0, 0, 50);
00382         
00383         glEnable( GL_POLYGON_SMOOTH );
00384         glBegin(GL_TRIANGLES);
00385         glVertex2fv(v1); glVertex2fv(v2); glVertex2fv(v3);
00386         glEnd();
00387         
00388         glDisable( GL_POLYGON_SMOOTH );
00389         glDisable( GL_BLEND );
00390     }
00391     
00392     if(G.moving || (seq->flag & whichsel)) {
00393         const char col[4]= {255, 255, 255, 255};
00394         if (direction == SEQ_LEFTHANDLE) {
00395             BLI_snprintf(numstr, sizeof(numstr),"%d", seq->startdisp);
00396             x1= rx1;
00397             y1 -= 0.45f;
00398         } else {
00399             BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
00400             x1= x2 - handsize*0.75f;
00401             y1= y2 + 0.05f;
00402         }
00403         UI_view2d_text_cache_add(v2d, x1, y1, numstr, col);
00404     }   
00405 }
00406 
00407 static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
00408 {
00409     float x1, x2, y1, y2, pixely, a;
00410     unsigned char col[3], blendcol[3];
00411     View2D *v2d= &ar->v2d;
00412     
00413     if(seq->type >= SEQ_EFFECT) return;
00414 
00415     x1= seq->startdisp;
00416     x2= seq->enddisp;
00417     
00418     y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
00419     y2= seq->machine+SEQ_STRIP_OFSTOP;
00420 
00421     pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
00422     
00423     if(pixely <= 0) return; /* can happen when the view is split/resized */
00424     
00425     blendcol[0] = blendcol[1] = blendcol[2] = 120;
00426 
00427     if(seq->startofs) {
00428         glEnable( GL_BLEND );
00429         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00430         
00431         get_seq_color3ubv(scene, seq, col);
00432         
00433         if (seq->flag & SELECT) {
00434             UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
00435             glColor4ub(col[0], col[1], col[2], 170);
00436         } else {
00437             UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
00438             glColor4ub(col[0], col[1], col[2], 110);
00439         }
00440         
00441         glRectf((float)(seq->start), y1-SEQ_STRIP_OFSBOTTOM, x1, y1);
00442         
00443         if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
00444         else glColor4ub(col[0], col[1], col[2], 160);
00445 
00446         fdrawbox((float)(seq->start), y1-SEQ_STRIP_OFSBOTTOM, x1, y1);  //outline
00447         
00448         glDisable( GL_BLEND );
00449     }
00450     if(seq->endofs) {
00451         glEnable( GL_BLEND );
00452         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00453         
00454         get_seq_color3ubv(scene, seq, col);
00455         
00456         if (seq->flag & SELECT) {
00457             UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40);
00458             glColor4ub(col[0], col[1], col[2], 170);
00459         } else {
00460             UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0);
00461             glColor4ub(col[0], col[1], col[2], 110);
00462         }
00463         
00464         glRectf(x2, y2, (float)(seq->start+seq->len), y2+SEQ_STRIP_OFSBOTTOM);
00465         
00466         if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255);
00467         else glColor4ub(col[0], col[1], col[2], 160);
00468 
00469         fdrawbox(x2, y2, (float)(seq->start+seq->len), y2+SEQ_STRIP_OFSBOTTOM); //outline
00470         
00471         glDisable( GL_BLEND );
00472     }
00473     if(seq->startstill) {
00474         get_seq_color3ubv(scene, seq, col);
00475         UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
00476         glColor3ubv((GLubyte *)col);
00477         
00478         draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2);
00479         
00480         /* feint pinstripes, helps see exactly which is extended and which isn't,
00481         * especially when the extension is very small */ 
00482         if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24);
00483         else UI_GetColorPtrShade3ubv(col, col, -16);
00484         
00485         glColor3ubv((GLubyte *)col);
00486         
00487         for(a=y1; a< y2; a+= pixely * 2.0f) {
00488             fdrawline(x1,  a,  (float)(seq->start),  a);
00489         }
00490     }
00491     if(seq->endstill) {
00492         get_seq_color3ubv(scene, seq, col);
00493         UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40);
00494         glColor3ubv((GLubyte *)col);
00495         
00496         draw_shadedstrip(seq, col, (float)(seq->start+seq->len), y1, x2, y2);
00497         
00498         /* feint pinstripes, helps see exactly which is extended and which isn't,
00499         * especially when the extension is very small */ 
00500         if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24);
00501         else UI_GetColorPtrShade3ubv(col, col, -16);
00502         
00503         glColor3ubv((GLubyte *)col);
00504         
00505         for(a=y1; a< y2; a+= pixely * 2.0f) {
00506             fdrawline((float)(seq->start+seq->len),  a,  x2,  a);
00507         }
00508     }
00509 }
00510 
00511 /* draw info text on a sequence strip */
00512 static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3])
00513 {
00514     rctf rect;
00515     char str[32 + FILE_MAX];
00516     const char *name= seq->name+2;
00517     char col[4];
00518 
00519     /* note, all strings should include 'name' */
00520     if(name[0]=='\0')
00521         name= give_seqname(seq);
00522 
00523     if(seq->type == SEQ_META || seq->type == SEQ_ADJUSTMENT) {
00524         BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name);
00525     }
00526     else if(seq->type == SEQ_SCENE) {
00527         if(seq->scene) {
00528             if(seq->scene_camera) {
00529                 BLI_snprintf(str, sizeof(str), "%d | %s: %s (%s)", seq->len, name, seq->scene->id.name+2, ((ID *)seq->scene_camera)->name+2);
00530             } else {
00531                 BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->scene->id.name+2);
00532             }
00533         }
00534         else {
00535             BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name);
00536         }
00537     }
00538     else if(seq->type == SEQ_MULTICAM) {
00539         BLI_snprintf(str, sizeof(str), "Cam | %s: %d", name, seq->multicam_source);
00540     }
00541     else if(seq->type == SEQ_IMAGE) {
00542         BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", seq->len, name, seq->strip->dir, seq->strip->stripdata->name);
00543     }
00544     else if(seq->type & SEQ_EFFECT) {
00545         int can_float = (seq->type != SEQ_PLUGIN)
00546             || (seq->plugin && seq->plugin->version >= 4);
00547 
00548         if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3)
00549             BLI_snprintf(str, sizeof(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!");
00550         else if (seq->seq1 && seq->seq2)
00551             BLI_snprintf(str, sizeof(str), "%d | %s: %d>%d%s", seq->len, name, seq->seq1->machine, seq->seq2->machine, can_float ? "" : " No float, upgrade plugin!");
00552         else
00553             BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name);
00554     }
00555     else if (seq->type == SEQ_SOUND) {
00556         BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->sound->name);
00557     }
00558     else if (seq->type == SEQ_MOVIE) {
00559         BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", seq->len, name, seq->strip->dir, seq->strip->stripdata->name);
00560     }
00561     
00562     if(seq->flag & SELECT){
00563         col[0]= col[1]= col[2]= 255;
00564     }else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50){
00565         col[0]= col[1]= col[2]= 80; /* use lighter text color for dark background */
00566     }else{
00567         col[0]= col[1]= col[2]= 0;
00568     }
00569     col[3]= 255;
00570 
00571     rect.xmin= x1;
00572     rect.ymin= y1;
00573     rect.xmax= x2;
00574     rect.ymax= y2;
00575     UI_view2d_text_cache_rectf(v2d, &rect, str, col);
00576 }
00577 
00578 /* draws a shaded strip, made from gradient + flat color + gradient */
00579 static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2)
00580 {
00581     float ymid1, ymid2;
00582     
00583     if (seq->flag & SEQ_MUTE) {
00584         glEnable(GL_POLYGON_STIPPLE);
00585         glPolygonStipple(stipple_halftone);
00586     }
00587     
00588     ymid1 = (y2-y1)*0.25f + y1;
00589     ymid2 = (y2-y1)*0.65f + y1;
00590     
00591     glShadeModel(GL_SMOOTH);
00592     glBegin(GL_QUADS);
00593     
00594     if(seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; }
00595     else if(seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50);
00596     /* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */
00597     
00598     glColor3ubv(col);
00599     
00600     glVertex2f(x1,y1);
00601     glVertex2f(x2,y1);
00602 
00603     if(seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; }
00604     else if(seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5);
00605     else UI_GetColorPtrShade3ubv(col, col, -5);
00606 
00607     glColor3ubv((GLubyte *)col);
00608     
00609     glVertex2f(x2,ymid1);
00610     glVertex2f(x1,ymid1);
00611     
00612     glEnd();
00613     
00614     glRectf(x1,  ymid1,  x2,  ymid2);
00615     
00616     glBegin(GL_QUADS);
00617     
00618     glVertex2f(x1,ymid2);
00619     glVertex2f(x2,ymid2);
00620     
00621     if(seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15);
00622     else UI_GetColorPtrShade3ubv(col, col, 25);
00623     
00624     glColor3ubv((GLubyte *)col);
00625     
00626     glVertex2f(x2,y2);
00627     glVertex2f(x1,y2);
00628     
00629     glEnd();
00630     
00631     if (seq->flag & SEQ_MUTE) {
00632         glDisable(GL_POLYGON_STIPPLE);
00633     }
00634 }
00635 
00636 /*
00637 Draw a sequence strip, bounds check already made
00638 ARegion is currently only used to get the windows width in pixels
00639 so wave file sample drawing precision is zoom adjusted
00640 */
00641 static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline_tint, float pixelx)
00642 {
00643     View2D *v2d= &ar->v2d;
00644     float x1, x2, y1, y2;
00645     unsigned char col[3], background_col[3], is_single_image;
00646 
00647     /* we need to know if this is a single image/color or not for drawing */
00648     is_single_image = (char)seq_single_check(seq);
00649     
00650     /* body */
00651     if(seq->startstill) x1= seq->start;
00652     else x1= seq->startdisp;
00653     y1= seq->machine+SEQ_STRIP_OFSBOTTOM;
00654     if(seq->endstill) x2= seq->start+seq->len;
00655     else x2= seq->enddisp;
00656     y2= seq->machine+SEQ_STRIP_OFSTOP;
00657     
00658     
00659     /* get the correct color per strip type*/
00660     //get_seq_color3ubv(scene, seq, col);
00661     get_seq_color3ubv(scene, seq, background_col);
00662     
00663     /* draw the main strip body */
00664     if (is_single_image) /* single image */
00665         draw_shadedstrip(seq, background_col, seq_tx_get_final_left(seq, 0), y1, seq_tx_get_final_right(seq, 0), y2);
00666     else /* normal operation */
00667         draw_shadedstrip(seq, background_col, x1, y1, x2, y2);
00668     
00669     /* draw additional info and controls */
00670     if (!is_single_image)
00671         draw_seq_extensions(scene, ar, seq);
00672     
00673     draw_seq_handle(v2d, seq, pixelx, SEQ_LEFTHANDLE);
00674     draw_seq_handle(v2d, seq, pixelx, SEQ_RIGHTHANDLE);
00675     
00676     /* draw the strip outline */
00677     x1= seq->startdisp;
00678     x2= seq->enddisp;
00679     
00680     /* draw sound wave */
00681     if(seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx);
00682 
00683     /* draw lock */
00684     if(seq->flag & SEQ_LOCK) {
00685         glEnable(GL_POLYGON_STIPPLE);
00686         glEnable(GL_BLEND);
00687 
00688         /* light stripes */
00689         glColor4ub(255, 255, 255, 32);
00690         glPolygonStipple(stipple_diag_stripes_pos);
00691         glRectf(x1, y1, x2, y2);
00692 
00693         /* dark stripes */
00694         glColor4ub(0, 0, 0, 32);
00695         glPolygonStipple(stipple_diag_stripes_neg);
00696         glRectf(x1, y1, x2, y2);
00697 
00698         glDisable(GL_POLYGON_STIPPLE);
00699         glDisable(GL_BLEND);
00700     }
00701 
00702     get_seq_color3ubv(scene, seq, col);
00703     if (G.moving && (seq->flag & SELECT)) {
00704         if(seq->flag & SEQ_OVERLAP) {
00705             col[0]= 255; col[1]= col[2]= 40;
00706         }
00707         else
00708             UI_GetColorPtrShade3ubv(col, col, 120+outline_tint);
00709     }
00710     else
00711         UI_GetColorPtrShade3ubv(col, col, outline_tint);
00712     
00713     glColor3ubv((GLubyte *)col);
00714     
00715     if (seq->flag & SEQ_MUTE) {
00716         glEnable(GL_LINE_STIPPLE);
00717         glLineStipple(1, 0x8888);
00718     }
00719     
00720     uiDrawBoxShade(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0);
00721     
00722     if (seq->flag & SEQ_MUTE) {
00723         glDisable(GL_LINE_STIPPLE);
00724     }
00725     
00726     if(seq->type==SEQ_META) drawmeta_contents(scene, seq, x1, y1, x2, y2);
00727     
00728     /* calculate if seq is long enough to print a name */
00729     x1= seq->startdisp+seq->handsize;
00730     x2= seq->enddisp-seq->handsize;
00731 
00732     /* info text on the strip */
00733     if(x1<v2d->cur.xmin) x1= v2d->cur.xmin;
00734     else if(x1>v2d->cur.xmax) x1= v2d->cur.xmax;
00735     if(x2<v2d->cur.xmin) x2= v2d->cur.xmin;
00736     else if(x2>v2d->cur.xmax) x2= v2d->cur.xmax;
00737 
00738     /* nice text here would require changing the view matrix for texture text */
00739     if( (x2-x1) / pixelx > 32) {
00740         draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col);
00741     }
00742 }
00743 
00744 static Sequence *special_seq_update= NULL;
00745 
00746 static void UNUSED_FUNCTION(set_special_seq_update)(int val)
00747 {
00748 //  int x;
00749 
00750     /* if mouse over a sequence && LEFTMOUSE */
00751     if(val) {
00752 // XXX      special_seq_update= find_nearest_seq(&x);
00753     }
00754     else special_seq_update= NULL;
00755 }
00756 
00757 void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
00758 {
00759     struct Main *bmain= CTX_data_main(C);
00760     struct ImBuf *ibuf= NULL;
00761     struct ImBuf *scope= NULL;
00762     struct View2D *v2d = &ar->v2d;
00763     int rectx, recty;
00764     float viewrectx, viewrecty;
00765     float render_size = 0.0;
00766     float proxy_size = 100.0;
00767     GLuint texid;
00768     GLuint last_texid;
00769     SeqRenderData context;
00770 
00771     render_size = sseq->render_size;
00772     if (render_size == 0) {
00773         render_size = scene->r.size;
00774     } else {
00775         proxy_size = render_size;
00776     }
00777     if (render_size < 0) {
00778         return;
00779     }
00780 
00781     viewrectx = (render_size*(float)scene->r.xsch)/100.0f;
00782     viewrecty = (render_size*(float)scene->r.ysch)/100.0f;
00783 
00784     rectx = viewrectx + 0.5f;
00785     recty = viewrecty + 0.5f;
00786 
00787     if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
00788         viewrectx *= scene->r.xasp / scene->r.yasp;
00789         viewrectx /= proxy_size / 100.0f;
00790         viewrecty /= proxy_size / 100.0f;
00791     }
00792 
00793     if(frame_ofs == 0) {
00794         /* XXX TODO: take color from theme */
00795         glClearColor(0.0, 0.0, 0.0, 0.0);
00796         glClear(GL_COLOR_BUFFER_BIT);
00797     }
00798 
00799     /* without this colors can flicker from previous opengl state */
00800     glColor4ub(255, 255, 255, 255);
00801 
00802     UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f);
00803     UI_view2d_curRect_validate(v2d);
00804 
00805     /* only initialize the preview if a render is in progress */
00806     if(G.rendering)
00807         return;
00808 
00809     context = seq_new_render_data(bmain, scene, rectx, recty, proxy_size);
00810 
00811     if (special_seq_update)
00812         ibuf= give_ibuf_seq_direct(context, cfra + frame_ofs, special_seq_update);
00813     else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
00814         ibuf= (ImBuf *)give_ibuf_seq(context, cfra + frame_ofs, sseq->chanshown);
00815     else
00816         ibuf= (ImBuf *)give_ibuf_seq_threaded(context, cfra + frame_ofs, sseq->chanshown);
00817     
00818     if(ibuf==NULL) 
00819         return;
00820 
00821     if(ibuf->rect==NULL && ibuf->rect_float == NULL) 
00822         return;
00823     
00824     switch(sseq->mainb) {
00825     case SEQ_DRAW_IMG_IMBUF:
00826         if (sseq->zebra != 0) {
00827             scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra);
00828         }
00829         break;
00830     case SEQ_DRAW_IMG_WAVEFORM:
00831         if ((sseq->flag & SEQ_DRAW_COLOR_SEPERATED) != 0) {
00832             scope = make_sep_waveform_view_from_ibuf(ibuf);
00833         } else {
00834             scope = make_waveform_view_from_ibuf(ibuf);
00835         }
00836         break;
00837     case SEQ_DRAW_IMG_VECTORSCOPE:
00838         scope = make_vectorscope_view_from_ibuf(ibuf);
00839         break;
00840     case SEQ_DRAW_IMG_HISTOGRAM:
00841         scope = make_histogram_view_from_ibuf(ibuf);
00842         break;
00843     }
00844 
00845     if (scope) {
00846         IMB_freeImBuf(ibuf);
00847         ibuf = scope;
00848     }
00849 
00850     if(ibuf->rect_float && ibuf->rect==NULL) {
00851         IMB_rect_from_float(ibuf);  
00852     }
00853     
00854     /* setting up the view - actual drawing starts here */
00855     UI_view2d_view_ortho(v2d);
00856 
00857     last_texid= glaGetOneInteger(GL_TEXTURE_2D);
00858     glEnable(GL_TEXTURE_2D);
00859     glGenTextures(1, (GLuint *)&texid);
00860 
00861     glBindTexture(GL_TEXTURE_2D, texid);
00862 
00863     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00864     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
00865 
00866     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
00867     glBegin(GL_QUADS);
00868 
00869     if(frame_ofs) {
00870         rctf tot_clip;
00871         tot_clip.xmin= v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin);
00872         tot_clip.ymin= v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin);
00873         tot_clip.xmax= v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax);
00874         tot_clip.ymax= v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax);
00875 
00876         glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin);glVertex2f(tot_clip.xmin, tot_clip.ymin);
00877         glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax);glVertex2f(tot_clip.xmin, tot_clip.ymax);
00878         glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax);glVertex2f(tot_clip.xmax, tot_clip.ymax);
00879         glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin);glVertex2f(tot_clip.xmax, tot_clip.ymin);
00880     }
00881     else {
00882         glTexCoord2f(0.0f, 0.0f);glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
00883         glTexCoord2f(0.0f, 1.0f);glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
00884         glTexCoord2f(1.0f, 1.0f);glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
00885         glTexCoord2f(1.0f, 0.0f);glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
00886     }
00887     glEnd( );
00888     glBindTexture(GL_TEXTURE_2D, last_texid);
00889     glDisable(GL_TEXTURE_2D);
00890     glDeleteTextures(1, &texid);
00891 
00892     if(sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
00893 
00894         float x1 = v2d->tot.xmin;
00895         float y1 = v2d->tot.ymin;
00896         float x2 = v2d->tot.xmax;
00897         float y2 = v2d->tot.ymax;
00898 
00899         /* border */
00900         setlinestyle(3);
00901 
00902         UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);
00903 
00904         glBegin(GL_LINE_LOOP);
00905         glVertex2f(x1-0.5f, y1-0.5f);
00906         glVertex2f(x1-0.5f, y2+0.5f);
00907         glVertex2f(x2+0.5f, y2+0.5f);
00908         glVertex2f(x2+0.5f, y1-0.5f);
00909         glEnd();
00910 
00911         /* safety border */
00912         if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
00913             float fac= 0.1;
00914 
00915             float a= fac*(x2-x1);
00916             x1+= a;
00917             x2-= a;
00918 
00919             a= fac*(y2-y1);
00920             y1+= a;
00921             y2-= a;
00922 
00923             glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
00924 
00925             uiSetRoundBox(UI_CNR_ALL);
00926             uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
00927 
00928             glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00929 
00930         }
00931 
00932         setlinestyle(0);
00933     }
00934     
00935     /* draw grease-pencil (image aligned) */
00936 //  if (sseq->flag & SEQ_DRAW_GPENCIL)
00937 // XXX      draw_gpencil_2dimage(sa, ibuf);
00938 
00939     IMB_freeImBuf(ibuf);
00940     
00941     /* draw grease-pencil (screen aligned) */
00942 //  if (sseq->flag & SEQ_DRAW_GPENCIL)
00943 // XXX      draw_gpencil_view2d(sa, 0);
00944     
00945     /* ortho at pixel level */
00946     UI_view2d_view_restore(C);
00947 }
00948 
00949 #if 0
00950 void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
00951 {
00952     int rectx, recty;
00953     int render_size = sseq->render_size;
00954     int proxy_size = 100.0; 
00955     if (render_size == 0) {
00956         render_size = scene->r.size;
00957     } else {
00958         proxy_size = render_size;
00959     }
00960     if (render_size < 0) {
00961         return;
00962     }
00963 
00964     rectx= (render_size*scene->r.xsch)/100;
00965     recty= (render_size*scene->r.ysch)/100;
00966 
00967     if(sseq->mainb != SEQ_DRAW_SEQUENCE) {
00968         give_ibuf_prefetch_request(
00969             rectx, recty, (scene->r.cfra), sseq->chanshown,
00970             proxy_size);
00971     }
00972 }
00973 #endif
00974 
00975 /* draw backdrop of the sequencer strips view */
00976 static void draw_seq_backdrop(View2D *v2d)
00977 {
00978     int i;
00979     
00980     /* darker grey overlay over the view backdrop */
00981     UI_ThemeColorShade(TH_BACK, -20);
00982     glRectf(v2d->cur.xmin,  -1.0,  v2d->cur.xmax,  1.0);
00983 
00984     /* Alternating horizontal stripes */
00985     i= MAX2(1, ((int)v2d->cur.ymin)-1);
00986 
00987     glBegin(GL_QUADS);
00988         while (i<v2d->cur.ymax) {
00989             if (((int)i) & 1)
00990                 UI_ThemeColorShade(TH_BACK, -15);
00991             else
00992                 UI_ThemeColorShade(TH_BACK, -25);
00993             
00994             glVertex2f(v2d->cur.xmax, i);
00995             glVertex2f(v2d->cur.xmin, i);
00996             glVertex2f(v2d->cur.xmin, i+1);
00997             glVertex2f(v2d->cur.xmax, i+1);
00998             
00999             i+=1.0;
01000         }
01001     glEnd();
01002     
01003     /* Darker lines separating the horizontal bands */
01004     i= MAX2(1, ((int)v2d->cur.ymin)-1);
01005     UI_ThemeColor(TH_GRID);
01006     
01007     glBegin(GL_LINES);
01008         while (i < v2d->cur.ymax) {
01009             glVertex2f(v2d->cur.xmax, i);
01010             glVertex2f(v2d->cur.xmin, i);
01011             
01012             i+=1.0;
01013         }
01014     glEnd();
01015 }
01016 
01017 /* draw the contents of the sequencer strips view */
01018 static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
01019 {
01020     Scene *scene= CTX_data_scene(C);
01021     View2D *v2d= &ar->v2d;
01022     Sequence *last_seq = seq_active_get(scene);
01023     int sel = 0, j;
01024     float pixelx = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin);
01025     
01026     /* loop through twice, first unselected, then selected */
01027     for (j=0; j<2; j++) {
01028         Sequence *seq;
01029         int outline_tint= (j) ? -60 : -150; /* highlighting around strip edges indicating selection */
01030         
01031         /* loop through strips, checking for those that are visible */
01032         for (seq= ed->seqbasep->first; seq; seq= seq->next) {
01033             /* boundbox and selection tests for NOT drawing the strip... */
01034             if ((seq->flag & SELECT) != sel) continue;
01035             else if (seq == last_seq) continue;
01036             else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
01037             else if (MAX2(seq->enddisp, seq->start+seq->len) < v2d->cur.xmin) continue;
01038             else if (seq->machine+1.0f < v2d->cur.ymin) continue;
01039             else if (seq->machine > v2d->cur.ymax) continue;
01040             
01041             /* strip passed all tests unscathed... so draw it now */
01042             draw_seq_strip(scene, ar, seq, outline_tint, pixelx);
01043         }
01044         
01045         /* draw selected next time round */
01046         sel= SELECT; 
01047     }
01048     
01049     /* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
01050     if (last_seq)
01051         draw_seq_strip(scene, ar, last_seq, 120, pixelx);
01052 }
01053 
01054 static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
01055 {   
01056     glEnable(GL_BLEND);
01057     
01058     /* draw darkened area outside of active timeline 
01059      * frame range used is preview range or scene range */
01060     UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);
01061 
01062     if (PSFRA < PEFRA) {
01063         glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
01064         glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
01065     }
01066     else {
01067         glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
01068     }
01069 
01070     UI_ThemeColorShade(TH_BACK, -60);
01071     /* thin lines where the actual frames are */
01072     fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
01073     fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax);
01074     
01075     glDisable(GL_BLEND);
01076 }
01077 
01078 /* Draw Timeline/Strip Editor Mode for Sequencer */
01079 void draw_timeline_seq(const bContext *C, ARegion *ar)
01080 {
01081     Scene *scene= CTX_data_scene(C);
01082     Editing *ed= seq_give_editing(scene, FALSE);
01083     SpaceSeq *sseq= CTX_wm_space_seq(C);
01084     View2D *v2d= &ar->v2d;
01085     View2DScrollers *scrollers;
01086     short unit=0, flag=0;
01087     float col[3];
01088     
01089     /* clear and setup matrix */
01090     UI_GetThemeColor3fv(TH_BACK, col);
01091     if (ed && ed->metastack.first) 
01092         glClearColor(col[0], col[1], col[2]-0.1f, 0.0f);
01093     else 
01094         glClearColor(col[0], col[1], col[2], 0.0f);
01095     glClear(GL_COLOR_BUFFER_BIT);
01096 
01097     UI_view2d_view_ortho(v2d);
01098     
01099     
01100     /* calculate extents of sequencer strips/data 
01101      * NOTE: needed for the scrollers later
01102      */
01103     boundbox_seq(scene, &v2d->tot);
01104     
01105     
01106     /* draw backdrop */
01107     draw_seq_backdrop(v2d);
01108     
01109     /* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */
01110     // NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30...
01111     UI_view2d_constant_grid_draw(v2d);
01112     
01113     seq_draw_sfra_efra(scene, v2d); 
01114 
01115     /* sequence strips (if there is data available to be drawn) */
01116     if (ed) {
01117         /* draw the data */
01118         draw_seq_strips(C, ed, ar);
01119         
01120         /* text draw cached (for sequence names), in pixelspace now */
01121         UI_view2d_text_cache_draw(ar);
01122     }
01123     
01124     /* current frame */
01125     UI_view2d_view_ortho(v2d);
01126     if ((sseq->flag & SEQ_DRAWFRAMES)==0)   flag |= DRAWCFRA_UNIT_SECONDS;
01127     if ((sseq->flag & SEQ_NO_DRAW_CFRANUM)==0)  flag |= DRAWCFRA_SHOW_NUMBOX;
01128     ANIM_draw_cfra(C, v2d, flag);
01129     
01130     /* markers */
01131     UI_view2d_view_orthoSpecial(ar, v2d, 1);
01132     draw_markers_time(C, DRAW_MARKERS_LINES);
01133     
01134     /* preview range */
01135     UI_view2d_view_ortho(v2d);
01136     ANIM_draw_previewrange(C, v2d);
01137 
01138     /* overlap playhead */
01139     if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
01140         int cfra_over= (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
01141         glColor3f(0.2, 0.2, 0.2);
01142         // glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
01143 
01144         glBegin(GL_LINES);
01145             glVertex2f(cfra_over, v2d->cur.ymin);
01146             glVertex2f(cfra_over, v2d->cur.ymax);
01147         glEnd();
01148 
01149     }
01150     
01151     /* reset view matrix */
01152     UI_view2d_view_restore(C);
01153 
01154     /* scrollers */
01155     unit= (sseq->flag & SEQ_DRAWFRAMES)? V2D_UNIT_FRAMES : V2D_UNIT_SECONDSSEQ;
01156     scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
01157     UI_view2d_scrollers_draw(C, v2d, scrollers);
01158     UI_view2d_scrollers_free(scrollers);
01159 }
01160 
01161