diff options
Diffstat (limited to 'source/blender/src/drawseq.c')
-rw-r--r-- | source/blender/src/drawseq.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index 1c2e7e413a2..e554b91dd52 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -916,6 +916,64 @@ void seq_reset_imageofs(SpaceSeq *sseq) sseq->xof = sseq->yof = sseq->zoom = 0; } +void seq_home(void) +{ + SpaceSeq *sseq= curarea->spacedata.first; + + if (!sseq->mainb) { + G.v2d->cur= G.v2d->tot; + test_view2d(G.v2d, curarea->winx, curarea->winy); + view2d_do_locks(curarea, V2D_LOCK_COPY); + } else { + float zoomX, zoomY; + int width, height, imgwidth, imgheight; + + width = curarea->winx; + height = curarea->winy; + + seq_reset_imageofs(sseq); + + imgwidth= (G.scene->r.size*G.scene->r.xsch)/100; + imgheight= (G.scene->r.size*G.scene->r.ysch)/100; + + /* Apply aspect, dosnt need to be that accurate */ + imgwidth= (int)(imgwidth * ((float)G.scene->r.xasp / (float)G.scene->r.yasp)); + + if (((imgwidth >= width) || (imgheight >= height)) && + ((width > 0) && (height > 0))) { + + /* Find the zoom value that will fit the image in the image space */ + zoomX = ((float)width) / ((float)imgwidth); + zoomY = ((float)height) / ((float)imgheight); + sseq->zoom= (zoomX < zoomY) ? zoomX : zoomY; + + sseq->zoom = 1.0f / power_of_2(1/ MIN2(zoomX, zoomY) ); + } + else { + sseq->zoom= 1.0f; + } + } + scrarea_queue_winredraw(curarea); +} + +void seq_viewzoom(unsigned short event, int invert) +{ + SpaceSeq *sseq= curarea->spacedata.first; + + if(event==PAD1) + sseq->zoom= 1.0; + else if(event==PAD2) + sseq->zoom= (invert)? 2.0: 0.5; + else if(event==PAD4) + sseq->zoom= (invert)? 4.0: 0.25; + else if(event==PAD8) + sseq->zoom= (invert)? 8.0: 0.125; + + /* ensure pixel exact locations for draw */ + sseq->xof= (int)sseq->xof; + sseq->yof= (int)sseq->yof; +} + void seq_viewmove(SpaceSeq *sseq) { ScrArea *sa; |