155
166
*step= rem*pow(10.0, (float)*macht);
169
if(rem==10.0) (*macht)++; // prevents printing 1.0 2.0 3.0 etc
162
173
void calc_ipogrid()
175
float space, pixels, secondiv=1.0;
166
177
/* rule: gridstep is minimal IPOSTEP pixels */
167
178
/* how large is IPOSTEP pixels? */
169
180
if(G.v2d==0) return;
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)) {
187
secondiv= 0.01 * (float)G.scene->r.frs_sec;
171
191
space= G.v2d->cur.xmax - G.v2d->cur.xmin;
172
192
pixels= G.v2d->mask.xmax-G.v2d->mask.xmin;
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;
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;
180
201
if(ipomachtx<-2) ipomachtx= -2;
185
206
ipogrid_dy= IPOSTEP*space/pixels;
186
207
step_to_grid(&ipogrid_dy, &ipomachty);
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;
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;
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;
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;
487
dx= (cur->ymax-cur->ymin)/(cur->xmax-cur->xmin);
488
dy= ((float)winy)/((float)winx);
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;
495
else if( dy > 1.0) do_x= 0; else do_x= 1;
456
498
v2d->oldwinx= winx;
457
499
v2d->oldwiny= winy;
459
dx= (cur->ymax-cur->ymin)/(cur->xmax-cur->xmin);
460
dy= ((float)winy)/((float)winx);
463
if( dy > 1.0) do_x= 0; else do_x= 1;
468
503
/* portrait window: correct for x */
553
void calc_scrollrcts(View2D *v2d, int winx, int winy)
588
void calc_scrollrcts(ScrArea *sa, View2D *v2d, int winx, int winy)
555
590
v2d->mask.xmin= v2d->mask.ymin= 0;
556
591
v2d->mask.xmax= winx;
557
592
v2d->mask.ymax= winy;
559
if(curarea->spacetype==SPACE_ACTION) {
594
if(sa->spacetype==SPACE_ACTION) {
560
595
v2d->mask.xmin+= ACTWIDTH;
561
596
v2d->hor.xmin+=ACTWIDTH;
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;
567
else if(curarea->spacetype==SPACE_IPO) {
602
else if(sa->spacetype==SPACE_IPO) {
568
603
v2d->mask.xmax-= IPOBUTX;
570
605
if(v2d->mask.xmax<IPOBUTX)
678
/* used for drawing timeline */
679
void draw_view2d_numbers_horiz(int drawframes)
681
float fac, fac2, dfac, val;
683
/* the numbers: convert ipogrid_startx and -dx to scroll coordinates */
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);
688
dfac= (ipogrid_dx)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
689
dfac= dfac*(G.v2d->mask.xmax-G.v2d->mask.xmin);
691
BIF_ThemeColor(TH_TEXT);
693
while(fac < G.v2d->mask.xmax) {
697
scroll_prstr(fac, 2.0+(float)(G.v2d->mask.ymin), val, 'h', 0);
700
fac2= val/(float)G.scene->r.frs_sec;
701
scroll_prstr(fac, 2.0+(float)(G.v2d->mask.ymin), fac2, 'h', 0);
643
710
void drawscroll(int disptype)
688
755
val= ipogrid_startx;
689
756
while(fac < hor.xmax) {
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);
695
763
scroll_prstr(fac, 3.0+(float)(hor.ymin), tim+G.scene->r.frs_sec*fac2/100.0, 'h', disptype);
697
else if(curarea->spacetype==SPACE_SOUND) {
765
else if (curarea->spacetype==SPACE_SOUND) {
698
766
SpaceSound *ssound= curarea->spacedata.first;
700
768
if(ssound->flag & SND_DRAWFRAMES) {
706
774
scroll_prstr(fac, 3.0+(float)(hor.ymin), fac2, 'h', disptype);
777
else if (curarea->spacetype==SPACE_TIME) {
778
SpaceTime *stime= curarea->spacedata.first;
780
if(stime->flag & TIME_DRAWFRAMES) {
782
scroll_prstr(fac, 3.0+(float)(hor.ymin), val, 'h', disptype);
785
fac2= val/(float)G.scene->r.frs_sec;
786
scroll_prstr(fac, 3.0+(float)(hor.ymin), fac2, 'h', disptype);
710
790
scroll_prstr(fac, 3.0+(float)(hor.ymin), val, 'h', disptype);
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) {
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);
895
// this fake button defines selection of curves
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]);
935
1017
if( (bezt->f2 & 1) == sel )
936
glVertex3fv(bezt->vec[1]);
1018
bglVertex3fv(bezt->vec[1]);
940
glVertex3fv(bezt->vec[1]);
1022
bglVertex3fv(bezt->vec[1]);
1568
1649
boundbox_ipo_visible(G.sipo); // should not be needed... transform/draw calls should update
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);
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, "");
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, "");
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, "");
1586
1662
/* SPEED BUTTON */
1587
1663
if(totipo_vertsel) {
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) {
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);
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);
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);
1921
if(U.viewzoom==USER_ZOOM_CONT) {
1832
1927
if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1]) {
1929
if(U.viewzoom!=USER_ZOOM_CONT) {
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) {
1937
if ELEM5(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME);
1837
1939
G.v2d->cur.ymin+= dy;
1838
1940
G.v2d->cur.ymax-= dy;
1886
1988
* or if the mousewheel is being used.
1887
1989
* Return if zooming was done.
1992
/* check for left mouse / right mouse button select */
1993
if (U.flag & USER_LMOUSESELECT) mousebut = R_MOUSE;
1994
else mousebut = L_MOUSE;
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;
2006
else if(curarea->spacetype==SPACE_BUTS && (G.qual & LR_CTRLKEY)==0);
1894
2007
else if (view2dzoom(event)) {
1895
2008
curarea->head_swap= 0;
1900
2013
/* test where mouse is */
1901
2014
getmouseco_areawin(mvalo);
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)
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);
1930
2043
facy= (G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)(curarea->winy);
1934
/* no y move in audio */
1935
if(curarea->spacetype==SPACE_SOUND) facy= 0.0;
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;
2049
/* no y move in audio & time */
2050
if ELEM(curarea->spacetype, SPACE_SOUND, SPACE_TIME) facy= 0.0;
2052
if(get_mbut() & mousebut && leftret) return 0;
1938
2053
if(facx==0.0 && facy==0.0) return 1;
1940
2055
while( (get_mbut()&(L_MOUSE|M_MOUSE)) ||