~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/drawipo.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: drawipo.c,v 1.29 2004/04/08 12:22:41 ton Exp $
 
2
 * $Id: drawipo.c,v 1.47 2005/05/14 11:28:53 lukep Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
42
42
#include <unistd.h>
43
43
#else
44
44
#include <io.h>
45
 
#include "BLI_winstuff.h"
46
45
#endif   
47
46
 
48
47
#include "BMF_Api.h"
72
71
#include "BIF_interface.h"
73
72
#include "BIF_mywindow.h"
74
73
#include "BIF_space.h"
 
74
#include "BIF_glutil.h"
75
75
 
76
76
#include "BSE_drawipo.h"
77
77
#include "BSE_view.h"
78
78
#include "BSE_editipo.h"
 
79
#include "BSE_editipo_types.h"
79
80
#include "BSE_editaction_types.h"
80
81
#include "BSE_editnla_types.h"
81
82
 
82
83
#include "mydevice.h"
83
 
#include "ipo.h" /* retains old stuff */
84
84
#include "blendef.h"
85
85
#include "butspace.h"   // shouldnt be...
86
86
 
114
114
        else macht= ipomachtx;
115
115
        
116
116
        if (macht<=0) sprintf(str, "%.*f", 1-macht, val);
117
 
        else sprintf(str, "%d", (int)val);
 
117
        else sprintf(str, "%d", (int)floor(val + 0.375));
118
118
        
119
119
        len= strlen(str);
120
120
        if(dir=='h') x-= 4*len;
136
136
        
137
137
        loga= log10(*step);
138
138
        *macht= (int)(loga);
139
 
        
 
139
 
140
140
        rem= loga- *macht;
141
141
        rem= pow(10.0, rem);
142
142
        
144
144
                if(rem < 0.2) rem= 0.2;
145
145
                else if(rem < 0.5) rem= 0.5;
146
146
                else rem= 1.0;
147
 
                
 
147
 
148
148
                *step= rem*pow(10.0, (float)*macht);
 
149
                
 
150
                // partial of a frame have no meaning
 
151
                if(curarea->spacetype==SPACE_TIME) {
 
152
                        SpaceTime *stime= curarea->spacedata.first;
 
153
                        if(stime->flag & TIME_DRAWFRAMES) {
 
154
                                rem = 1.0;
 
155
                                *step = 1.0;
 
156
                        }
 
157
                }
 
158
                
 
159
                if(rem==1.0) (*macht)++;        // prevents printing 1.0 2.0 3.0 etc
149
160
        }
150
161
        else {
151
162
                if(rem < 2.0) rem= 2.0;
155
166
                *step= rem*pow(10.0, (float)*macht);
156
167
                
157
168
                (*macht)++;
 
169
                if(rem==10.0) (*macht)++;       // prevents printing 1.0 2.0 3.0 etc
158
170
        }
159
 
        
160
171
}
161
172
 
162
173
void calc_ipogrid()
163
174
{
164
 
        float space, pixels;
165
 
        
 
175
        float space, pixels, secondiv=1.0;
 
176
        int secondgrid= 0;
166
177
        /* rule: gridstep is minimal IPOSTEP pixels */
167
178
        /* how large is IPOSTEP pixels? */
168
179
        
169
180
        if(G.v2d==0) return;
170
181
        
 
182
        /* detect of we have seconds or frames, should become argument */
 
183
        if(curarea->spacetype==SPACE_TIME) {
 
184
                SpaceTime *stime= curarea->spacedata.first;
 
185
                if(!(stime->flag & TIME_DRAWFRAMES)) {
 
186
                        secondgrid= 1;
 
187
                        secondiv= 0.01 * (float)G.scene->r.frs_sec;
 
188
                }
 
189
        }
 
190
        
171
191
        space= G.v2d->cur.xmax - G.v2d->cur.xmin;
172
192
        pixels= G.v2d->mask.xmax-G.v2d->mask.xmin;
173
193
        
174
 
        ipogrid_dx= IPOSTEP*space/pixels;
 
194
        ipogrid_dx= IPOSTEP*space/(secondiv*pixels);
175
195
        step_to_grid(&ipogrid_dx, &ipomachtx);
 
196
        ipogrid_dx*= secondiv;
176
197
        
177
 
        if ELEM(curarea->spacetype, SPACE_SEQ, SPACE_SOUND) {
 
198
        if ELEM3(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_TIME) {
178
199
                if(ipogrid_dx < 0.1) ipogrid_dx= 0.1;
179
200
                ipomachtx-= 2;
180
201
                if(ipomachtx<-2) ipomachtx= -2;
185
206
        ipogrid_dy= IPOSTEP*space/pixels;
186
207
        step_to_grid(&ipogrid_dy, &ipomachty);
187
208
        
188
 
        if ELEM(curarea->spacetype, SPACE_SEQ, SPACE_SOUND) {
 
209
        if ELEM3(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_TIME) {
189
210
                if(ipogrid_dy < 1.0) ipogrid_dy= 1.0;
190
211
                if(ipomachty<1) ipomachty= 1;
191
212
        }
192
213
        
193
 
        ipogrid_startx= G.v2d->cur.xmin-fmod(G.v2d->cur.xmin, ipogrid_dx);
 
214
        ipogrid_startx= secondiv*(G.v2d->cur.xmin/secondiv - fmod(G.v2d->cur.xmin/secondiv, ipogrid_dx/secondiv));
194
215
        if(G.v2d->cur.xmin<0.0) ipogrid_startx-= ipogrid_dx;
 
216
        
195
217
        ipogrid_starty= (G.v2d->cur.ymin-fmod(G.v2d->cur.ymin, ipogrid_dy));
196
218
        if(G.v2d->cur.ymin<0.0) ipogrid_starty-= ipogrid_dy;
197
219
        
208
230
        
209
231
        step= (G.v2d->mask.xmax-G.v2d->mask.xmin+1)/IPOSTEP;
210
232
        
211
 
        if(curarea->spacetype==SPACE_SOUND) glColor3ub(0x70, 0x70, 0x60);
212
 
        else BIF_ThemeColor(TH_GRID);
 
233
        BIF_ThemeColor(TH_GRID);
213
234
        
214
235
        for(a=0; a<step; a++) {
215
236
                glBegin(GL_LINE_STRIP);
220
241
        
221
242
        vec2[0]= vec1[0]-= 0.5*ipogrid_dx;
222
243
        
223
 
        if(curarea->spacetype==SPACE_SOUND) glColor3ub(0x80, 0x80, 0x70);
224
 
        else  BIF_ThemeColorShade(TH_GRID, 16);
 
244
        BIF_ThemeColorShade(TH_GRID, 16);
225
245
        
226
246
        step++;
227
247
        for(a=0; a<=step; a++) {
231
251
                vec2[0]= vec1[0]-= ipogrid_dx;
232
252
        }
233
253
        
234
 
        if(curarea->spacetype!=SPACE_SOUND && curarea->spacetype!=SPACE_ACTION && curarea->spacetype!=SPACE_NLA) {
 
254
        if ELEM4(curarea->spacetype, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME);
 
255
        else {
235
256
                vec1[0]= ipogrid_startx;
236
257
                vec1[1]= vec2[1]= ipogrid_starty;
237
258
                vec2[0]= G.v2d->cur.xmax;
360
381
}
361
382
 
362
383
 
363
 
void view2d_zoom(View2D *v2d, float factor, int winx, int winy) {
 
384
void view2d_zoom(View2D *v2d, float factor, int winx, int winy) 
 
385
{
364
386
        float dx= factor*(v2d->cur.xmax-v2d->cur.xmin);
365
387
        float dy= factor*(v2d->cur.ymax-v2d->cur.ymin);
366
 
        v2d->cur.xmin+= dx;
367
 
        v2d->cur.xmax-= dx;
368
 
        v2d->cur.ymin+= dy;
369
 
        v2d->cur.ymax-= dy;
 
388
        if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
 
389
                v2d->cur.xmin+= dx;
 
390
                v2d->cur.xmax-= dx;
 
391
        }
 
392
        if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
 
393
                v2d->cur.ymin+= dy;
 
394
                v2d->cur.ymax-= dy;
 
395
        }
370
396
        test_view2d(v2d, winx, winy);
371
397
}
372
398
 
377
403
        rctf *cur, *tot;
378
404
        float dx, dy, temp, fac, zoom;
379
405
        
 
406
        /* correct winx for scroll */
 
407
        if(v2d->scroll & L_SCROLL) winx-= SCROLLB;
 
408
        if(v2d->scroll & B_SCROLL) winy-= SCROLLH;
 
409
        
380
410
        cur= &v2d->cur;
381
411
        tot= &v2d->tot;
382
412
        
453
483
                   find which is the best new 'cur' rect. thats why it stores 'old' */
454
484
                if(winx!=v2d->oldwinx) do_x= 1;
455
485
                if(winy!=v2d->oldwiny) do_y= 1;
 
486
                
 
487
                dx= (cur->ymax-cur->ymin)/(cur->xmax-cur->xmin);
 
488
                dy= ((float)winy)/((float)winx);
 
489
                
 
490
                if(do_x==do_y) {        // both sizes change, ctrl+uparrow
 
491
                        if(do_x==1 && do_y==1) {
 
492
                                if( ABS(winx-v2d->oldwinx)>ABS(winy-v2d->oldwiny)) do_y= 0;
 
493
                                else do_x= 0;
 
494
                        }
 
495
                        else if( dy > 1.0) do_x= 0; else do_x= 1;
 
496
                }
 
497
                
456
498
                v2d->oldwinx= winx; 
457
499
                v2d->oldwiny= winy;
458
500
                
459
 
                dx= (cur->ymax-cur->ymin)/(cur->xmax-cur->xmin);
460
 
                dy= ((float)winy)/((float)winx);
461
 
                
462
 
                if(do_x==do_y) {
463
 
                        if( dy > 1.0) do_x= 0; else do_x= 1;
464
 
                }
465
 
 
466
501
                if( do_x ) {
467
502
                        
468
503
                        /* portrait window: correct for x */
550
585
}
551
586
 
552
587
 
553
 
void calc_scrollrcts(View2D *v2d, int winx, int winy)
 
588
void calc_scrollrcts(ScrArea *sa, View2D *v2d, int winx, int winy)
554
589
{
555
590
        v2d->mask.xmin= v2d->mask.ymin= 0;
556
591
        v2d->mask.xmax= winx;
557
592
        v2d->mask.ymax= winy;
558
593
        
559
 
        if(curarea->spacetype==SPACE_ACTION) {
 
594
        if(sa->spacetype==SPACE_ACTION) {
560
595
                v2d->mask.xmin+= ACTWIDTH;
561
596
                v2d->hor.xmin+=ACTWIDTH;
562
597
        }
563
 
        else if(curarea->spacetype==SPACE_NLA){
 
598
        else if(sa->spacetype==SPACE_NLA){
564
599
                v2d->mask.xmin+= NLAWIDTH;
565
600
                v2d->hor.xmin+=NLAWIDTH;
566
601
        }
567
 
        else if(curarea->spacetype==SPACE_IPO) {
 
602
        else if(sa->spacetype==SPACE_IPO) {
568
603
                v2d->mask.xmax-= IPOBUTX;
569
604
                
570
605
                if(v2d->mask.xmax<IPOBUTX)
640
675
        }
641
676
}
642
677
 
 
678
/* used for drawing timeline */
 
679
void draw_view2d_numbers_horiz(int drawframes)
 
680
{
 
681
        float fac, fac2, dfac, val;
 
682
        
 
683
        /* the numbers: convert ipogrid_startx and -dx to scroll coordinates */
 
684
        
 
685
        fac= (ipogrid_startx- G.v2d->cur.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
 
686
        fac= G.v2d->mask.xmin+fac*(G.v2d->mask.xmax-G.v2d->mask.xmin);
 
687
        
 
688
        dfac= (ipogrid_dx)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
 
689
        dfac= dfac*(G.v2d->mask.xmax-G.v2d->mask.xmin);
 
690
        
 
691
        BIF_ThemeColor(TH_TEXT);
 
692
        val= ipogrid_startx;
 
693
        while(fac < G.v2d->mask.xmax) {
 
694
                
 
695
                if(drawframes) {
 
696
                        ipomachtx= 1;
 
697
                        scroll_prstr(fac, 2.0+(float)(G.v2d->mask.ymin), val, 'h', 0);
 
698
                }
 
699
                else {
 
700
                        fac2= val/(float)G.scene->r.frs_sec;
 
701
                        scroll_prstr(fac, 2.0+(float)(G.v2d->mask.ymin), fac2, 'h', 0);
 
702
                }
 
703
                
 
704
                fac+= dfac;
 
705
                val+= ipogrid_dx;
 
706
        }
 
707
}
 
708
 
 
709
 
643
710
void drawscroll(int disptype)
644
711
{
645
712
        rcti vert, hor;
688
755
                val= ipogrid_startx;
689
756
                while(fac < hor.xmax) {
690
757
                        
691
 
                        if(curarea->spacetype==SPACE_SEQ) {
 
758
                        if(curarea->spacetype==SPACE_OOPS);
 
759
                        else if(curarea->spacetype==SPACE_SEQ) {
692
760
                                fac2= val/(float)G.scene->r.frs_sec;
693
761
                                tim= floor(fac2);
694
762
                                fac2= fac2-tim;
695
763
                                scroll_prstr(fac, 3.0+(float)(hor.ymin), tim+G.scene->r.frs_sec*fac2/100.0, 'h', disptype);
696
764
                        }
697
 
                        else if(curarea->spacetype==SPACE_SOUND) {
 
765
                        else if (curarea->spacetype==SPACE_SOUND) {
698
766
                                SpaceSound *ssound= curarea->spacedata.first;
699
767
                                
700
768
                                if(ssound->flag & SND_DRAWFRAMES) {
706
774
                                        scroll_prstr(fac, 3.0+(float)(hor.ymin), fac2, 'h', disptype);
707
775
                                }
708
776
                        }
 
777
                        else if (curarea->spacetype==SPACE_TIME) {
 
778
                                SpaceTime *stime= curarea->spacedata.first;
 
779
                                
 
780
                                if(stime->flag & TIME_DRAWFRAMES) {
 
781
                                        ipomachtx= 1;
 
782
                                        scroll_prstr(fac, 3.0+(float)(hor.ymin), val, 'h', disptype);
 
783
                                }
 
784
                                else {
 
785
                                        fac2= val/(float)G.scene->r.frs_sec;
 
786
                                        scroll_prstr(fac, 3.0+(float)(hor.ymin), fac2, 'h', disptype);
 
787
                                }
 
788
                        }
709
789
                        else {
710
790
                                scroll_prstr(fac, 3.0+(float)(hor.ymin), val, 'h', disptype);
711
791
                        }
747
827
                dfac= (ipogrid_dy)/(G.v2d->cur.ymax-G.v2d->cur.ymin);
748
828
                dfac= dfac*(vert.ymax-vert.ymin-SCROLLH);
749
829
                
750
 
                if(curarea->spacetype==SPACE_SEQ) {
 
830
                if(curarea->spacetype==SPACE_OOPS);
 
831
                else if(curarea->spacetype==SPACE_SEQ) {
751
832
                        BIF_ThemeColor(TH_TEXT);
752
833
                        val= ipogrid_starty;
753
834
                        fac+= 0.5*dfac;
806
887
        ei= sipo->editipo;
807
888
        y= area->winy-30+sipo->butofs;
808
889
        for(a=0; a<sipo->totipo; a++, ei++, y-=IPOBUTY) {
809
 
                
810
 
                but= uiDefButI(block, TOG|BIT|a, a+1, ei->name,  v2d->mask.xmax+18, y, IPOBUTX-15, IPOBUTY-1, &(sipo->rowbut), 0, 0, 0, 0, "");
 
890
                // this button defines visiblity, bit zero of flag (IPO_VISIBLE)
 
891
                but= uiDefButS(block, TOG|BIT|0, a+1, ei->name,  v2d->mask.xmax+18, y, IPOBUTX-15, IPOBUTY-1, &(ei->flag), 0, 0, 0, 0, "");
811
892
                // no hilite, its not visible, but most of all the winmatrix is not correct later on...
812
893
                uiButSetFlag(but, UI_TEXT_LEFT|UI_NO_HILITE);
813
894
                
 
895
                // this fake button defines selection of curves
814
896
                if(ei->icu) {
815
897
                        cpack(ei->col);
816
898
                        
896
978
                         * on TNT2 / Linux with NVidia's drivers
897
979
                         * (at least up to ver. 4349) */                
898
980
                        
899
 
                        glBegin(GL_POINTS);
 
981
                        bglBegin(GL_POINTS);
900
982
                        
901
983
                        bezt= ei->icu->bezt;
902
984
                        a= ei->icu->totvert;
917
999
                                                while(b<31) {
918
1000
                                                        if(val & (1<<b)) {      
919
1001
                                                                v1[1]= b+1;
920
 
                                                                glVertex3fv(v1);
 
1002
                                                                bglVertex3fv(v1);
921
1003
                                                        }
922
1004
                                                        b++;
923
1005
                                                }
928
1010
                                        if(ei->flag & IPO_EDIT) {
929
1011
                                                if(ei->icu->ipo==IPO_BEZ) {
930
1012
                                                        if( (bezt->f1 & 1) == sel )     
931
 
                                                                glVertex3fv(bezt->vec[0]);
 
1013
                                                                bglVertex3fv(bezt->vec[0]);
932
1014
                                                        if( (bezt->f3 & 1) == sel )     
933
 
                                                                glVertex3fv(bezt->vec[2]);
 
1015
                                                                bglVertex3fv(bezt->vec[2]);
934
1016
                                                }
935
1017
                                                if( (bezt->f2 & 1) == sel )     
936
 
                                                        glVertex3fv(bezt->vec[1]);
 
1018
                                                        bglVertex3fv(bezt->vec[1]);
937
1019
                                                
938
1020
                                        }
939
1021
                                        else {
940
 
                                                glVertex3fv(bezt->vec[1]);
 
1022
                                                bglVertex3fv(bezt->vec[1]);
941
1023
                                        }
942
1024
                                }
943
1025
                                
944
1026
                                bezt++;
945
1027
                        }
946
1028
 
947
 
                        glEnd();
 
1029
                        bglEnd();
948
1030
                }
949
1031
        }
950
1032
        
1557
1639
{
1558
1640
        extern int totipo_vis;  // editipo.c
1559
1641
        uiBlock *block;
1560
 
        float min, max;
1561
1642
        
1562
1643
        block= uiNewBlock(&curarea->uiblocks, "ipo_panel_properties", UI_EMBOSS, UI_HELV, curarea->win);
1563
1644
        uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
1567
1648
 
1568
1649
        boundbox_ipo_visible(G.sipo);   // should not be needed... transform/draw calls should update
1569
1650
        
1570
 
        /* calculate a nice range for the button */
1571
 
        min= MIN2(G.sipo->tot.xmin, G.sipo->tot.ymin)-100.0;
1572
 
        min= MIN2(min, -100);
1573
 
        max= MAX2(G.sipo->tot.xmax, G.sipo->tot.ymax)+100.0;
1574
 
        max= MAX2(max, 100);
1575
 
 
 
1651
        /* note ranges for buttons below are idiot... we need 2 ranges, one for sliding scale, one for real clip */
1576
1652
        if(G.sipo->ipo && G.sipo->ipo->curve.first && totipo_vis) {
1577
1653
                extern int totipo_vertsel;      // editipo.c
1578
1654
                uiDefBut(block, LABEL, 0, "Visible curves",             10, 200, 150, 19, NULL, 1.0, 0.0, 0, 0, "");
1579
1655
                
1580
 
                uiDefButF(block, NUM, B_MUL_IPO, "Xmin:",               10, 180, 150, 19, &G.sipo->tot.xmin, min, max, 100, 0, "");
1581
 
                uiDefButF(block, NUM, B_MUL_IPO, "Xmax:",               160, 180, 150, 19, &G.sipo->tot.xmax, min, max, 100, 0, "");
 
1656
                uiDefButF(block, NUM, B_MUL_IPO, "Xmin:",               10, 180, 150, 19, &G.sipo->tot.xmin, G.sipo->tot.xmin-1000.0, 18000.0, 100, 0, "");
 
1657
                uiDefButF(block, NUM, B_MUL_IPO, "Xmax:",               160, 180, 150, 19, &G.sipo->tot.xmax, G.sipo->tot.ymin-1000.0, 18000.0, 100, 0, "");
1582
1658
                
1583
 
                uiDefButF(block, NUM, B_MUL_IPO, "Ymin:",               10, 160, 150, 19, &G.sipo->tot.ymin, min, max, 100, 0, "");
1584
 
                uiDefButF(block, NUM, B_MUL_IPO, "Ymax:",               160, 160, 150, 19, &G.sipo->tot.ymax, min, max, 100, 0, "");
 
1659
                uiDefButF(block, NUM, B_MUL_IPO, "Ymin:",               10, 160, 150, 19, &G.sipo->tot.ymin, G.sipo->tot.ymin-1000.0, 5000.0, 100, 0, "");
 
1660
                uiDefButF(block, NUM, B_MUL_IPO, "Ymax:",               160, 160, 150, 19, &G.sipo->tot.ymax, G.sipo->tot.ymin-1000.0, 5000.0, 100, 0, "");
1585
1661
 
1586
1662
                /* SPEED BUTTON */
1587
1663
                if(totipo_vertsel) {
1591
1667
        }
1592
1668
 
1593
1669
        /* this one also does keypositions */
1594
 
        if(G.sipo->ipo) ipo_editvertex_buts(block, G.sipo, min, max);
 
1670
        if(G.sipo->ipo) ipo_editvertex_buts(block, G.sipo, -10000, 18000);
1595
1671
}
1596
1672
 
1597
1673
static void ipo_blockhandlers(ScrArea *sa)
1631
1707
        uiFreeBlocksWin(&sa->uiblocks, sa->win);        /* for panel handler to work */
1632
1708
        
1633
1709
        v2d->hor.xmax+=IPOBUTX;
1634
 
        calc_scrollrcts(G.v2d, sa->winx, sa->winy);
 
1710
        calc_scrollrcts(sa, G.v2d, sa->winx, sa->winy);
1635
1711
 
1636
1712
        BIF_GetThemeColor3fv(TH_BACK, col);
1637
1713
        glClearColor(col[0], col[1], col[2], 0.0); 
1824
1900
                }
1825
1901
                else {
1826
1902
                        getmouseco_areawin(mval);
1827
 
                        fac= 0.001*(mval[0]-mvalo[0]);
1828
 
                        dx= fac*(G.v2d->cur.xmax-G.v2d->cur.xmin);
1829
 
                        fac= 0.001*(mval[1]-mvalo[1]);
1830
 
                        dy= fac*(G.v2d->cur.ymax-G.v2d->cur.ymin);
 
1903
                        if(U.viewzoom==USER_ZOOM_SCALE) {
 
1904
                                float dist;
 
1905
                                
 
1906
                                dist = (G.v2d->mask.xmax - G.v2d->mask.xmin)/2.0;
 
1907
                                dx= 1.0-(fabs(mvalo[0]-dist)+2.0)/(fabs(mval[0]-dist)+2.0);
 
1908
                                dx*= 0.5*(G.v2d->cur.xmax-G.v2d->cur.xmin);
 
1909
 
 
1910
                                dist = (G.v2d->mask.ymax - G.v2d->mask.ymin)/2.0;
 
1911
                                dy= 1.0-(fabs(mvalo[1]-dist)+2.0)/(fabs(mval[1]-dist)+2.0);
 
1912
                                dy*= 0.5*(G.v2d->cur.ymax-G.v2d->cur.ymin);
 
1913
        
 
1914
                        }
 
1915
                        else {
 
1916
                                fac= 0.01*(mval[0]-mvalo[0]);
 
1917
                                dx= fac*(G.v2d->cur.xmax-G.v2d->cur.xmin);
 
1918
                                fac= 0.01*(mval[1]-mvalo[1]);
 
1919
                                dy= fac*(G.v2d->cur.ymax-G.v2d->cur.ymin);
 
1920
                                
 
1921
                                if(U.viewzoom==USER_ZOOM_CONT) {
 
1922
                                        dx/= 20.0;
 
1923
                                        dy/= 20.0;
 
1924
                                }
 
1925
                        }
1831
1926
                }
1832
1927
                if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1]) {
1833
1928
                        
 
1929
                        if(U.viewzoom!=USER_ZOOM_CONT) {
 
1930
                                mvalo[0]= mval[0];
 
1931
                                mvalo[1]= mval[1];
 
1932
                        }
 
1933
                        
1834
1934
                        G.v2d->cur.xmin+= dx;
1835
1935
                        G.v2d->cur.xmax-= dx;
1836
 
                        if(curarea->spacetype!=SPACE_SEQ && curarea->spacetype!=SPACE_SOUND && curarea->spacetype!=SPACE_NLA && curarea->spacetype!=SPACE_ACTION) {
 
1936
                        
 
1937
                        if ELEM5(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME);
 
1938
                        else {
1837
1939
                                G.v2d->cur.ymin+= dy;
1838
1940
                                G.v2d->cur.ymax-= dy;
1839
1941
                        }
1875
1977
{
1876
1978
        /* return 1 when something was done */
1877
1979
        float facx=0.0, facy=0.0, dx, dy, left=1.0, right=1.0;
1878
 
        short mval[2], mvalo[2], leftret=1;
 
1980
        short mval[2], mvalo[2], leftret=1, mousebut;
1879
1981
        
1880
1982
        /* init */
1881
1983
        scrarea_do_windraw(curarea);
1886
1988
         * or if the mousewheel is being used.
1887
1989
         * Return if zooming was done.
1888
1990
         */
1889
 
         
1890
 
         
 
1991
        
 
1992
        /* check for left mouse / right mouse button select */
 
1993
        if (U.flag & USER_LMOUSESELECT) mousebut = R_MOUSE;
 
1994
                else mousebut = L_MOUSE;
 
1995
        
1891
1996
        if ( (G.qual & LR_CTRLKEY) || (event==WHEELUPMOUSE) || (event==WHEELDOWNMOUSE) ) {
1892
 
                /* patch for buttonswin, standard scroll no zoom */
1893
 
                if(curarea->spacetype==SPACE_BUTS && (G.qual & LR_CTRLKEY)==0);
 
1997
                /* patch for oops & buttonswin, standard scroll no zoom */
 
1998
                if(curarea->spacetype==SPACE_OOPS) {
 
1999
                        SpaceOops *soops= curarea->spacedata.first;
 
2000
                        if(soops->type==SO_OUTLINER);
 
2001
                        else if (view2dzoom(event)) {
 
2002
                                curarea->head_swap= 0;
 
2003
                                return 0;
 
2004
                        }
 
2005
                }
 
2006
                else if(curarea->spacetype==SPACE_BUTS && (G.qual & LR_CTRLKEY)==0);
1894
2007
                else if (view2dzoom(event)) {
1895
2008
                        curarea->head_swap= 0;
1896
2009
                        return 0;
1900
2013
        /* test where mouse is */
1901
2014
        getmouseco_areawin(mvalo);
1902
2015
        
1903
 
        if ELEM6(curarea->spacetype, SPACE_IPO, SPACE_SEQ, SPACE_OOPS, SPACE_SOUND, SPACE_ACTION, SPACE_NLA) 
 
2016
        if ELEM7(curarea->spacetype, SPACE_IPO, SPACE_SEQ, SPACE_OOPS, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME) 
1904
2017
                {
1905
2018
                        if( BLI_in_rcti(&G.v2d->mask, (int)mvalo[0], (int)mvalo[1]) ) {
1906
2019
                                facx= (G.v2d->cur.xmax-G.v2d->cur.xmin)/(float)(G.v2d->mask.xmax-G.v2d->mask.xmin);
1908
2021
                        }
1909
2022
                        else if(IN_2D_VERT_SCROLL((int)mvalo)) {
1910
2023
                                facy= -(G.v2d->tot.ymax-G.v2d->tot.ymin)/(float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
1911
 
                                if(get_mbut()&L_MOUSE) {
 
2024
                                if(get_mbut() & mousebut) {
1912
2025
                                        /* which part of scrollbar should move? */
1913
2026
                                        if(mvalo[1]< (vertymin+vertymax)/2 ) right= 0.0;
1914
2027
                                        else left= 0.0;
1917
2030
                        }
1918
2031
                        else if(IN_2D_HORIZ_SCROLL((int)mvalo)) {
1919
2032
                                facx= -(G.v2d->tot.xmax-G.v2d->tot.xmin)/(float)(G.v2d->mask.xmax-G.v2d->mask.xmin);
1920
 
                                if(get_mbut()&L_MOUSE) {
 
2033
                                if(get_mbut() & mousebut) {
1921
2034
                                        /* which part of scrollbar should move? */
1922
2035
                                        if(mvalo[0]< (horxmin+horxmax)/2 ) right= 0.0;
1923
2036
                                        else left= 0.0;
1930
2043
                        facy= (G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)(curarea->winy);         
1931
2044
                }
1932
2045
                
1933
 
                
1934
 
                /* no y move in audio */
1935
 
                if(curarea->spacetype==SPACE_SOUND) facy= 0.0;
1936
 
                
1937
 
                if(get_mbut()&L_MOUSE && leftret) return 0;
 
2046
                /* no x move in outliner */
 
2047
                if(curarea->spacetype==SPACE_OOPS && G.v2d->scroll) facx= 0.0;
 
2048
                
 
2049
                /* no y move in audio & time */
 
2050
                if ELEM(curarea->spacetype, SPACE_SOUND, SPACE_TIME) facy= 0.0;
 
2051
                
 
2052
                if(get_mbut() & mousebut && leftret) return 0;
1938
2053
                if(facx==0.0 && facy==0.0) return 1;
1939
2054
                
1940
2055
    while( (get_mbut()&(L_MOUSE|M_MOUSE)) || 
1950
2065
                        if(event==WHEELDOWNMOUSE) {     
1951
2066
                                facx= -facx; facy= -facy;
1952
2067
                        }
1953
 
                        
1954
2068
                        switch (G.qual & (LR_CTRLKEY|LR_SHIFTKEY|LR_ALTKEY)) {
1955
2069
                        case (LR_SHIFTKEY):
1956
2070
                                dx = 0.0;
1961
2075
                                dy = 0.0;
1962
2076
                                break;
1963
2077
                        default:
1964
 
                                if(curarea->spacetype==SPACE_BUTS) {
 
2078
                                if(curarea->spacetype==SPACE_OOPS) {
 
2079
                                        dx= 0.0;
 
2080
                                        dy= facy*20;
 
2081
                                }
 
2082
                                else if(curarea->spacetype==SPACE_BUTS) {
1965
2083
                                        if(G.buts->align==BUT_HORIZONTAL) {
1966
2084
                                                dx= facx*30; dy= 0.0;
1967
2085
                                        } else {
2018
2136
        /* this was IGLuint, but it's a useless typedef... */
2019
2137
        GLuint buffer[MAXPICKBUF];
2020
2138
        int a, b;
2021
 
        int code, hits;
 
2139
        int hits;
 
2140
        unsigned int code;
2022
2141
        short mval[2];
2023
2142
        
2024
2143
        G.f |= G_PICKSEL;