diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-01-19 04:15:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-01-19 04:15:17 +0300 |
commit | 4a32e0380b4ac15955043554302742333329850b (patch) | |
tree | 22146e011c09f88cc7694efcc0d012949b302309 /source/blender/src/header_oops.c | |
parent | 9ea630196c45cf15e3e292f391d0c69bef529eb2 (diff) |
Bugfix for http://projects.blender.org/tracker/?func=detail&atid=125&aid=3767&group_id=9
View All/View Selected - only took into account values from 1 axis. - Workaround because test_view2d needs to act that way for other functions.
Easy one :) Right mouse mutton cancels transform. - Must move to Theeth's new code one day.
Diffstat (limited to 'source/blender/src/header_oops.c')
-rw-r--r-- | source/blender/src/header_oops.c | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/source/blender/src/header_oops.c b/source/blender/src/header_oops.c index 6316d6d6bac..e7b168bbd64 100644 --- a/source/blender/src/header_oops.c +++ b/source/blender/src/header_oops.c @@ -80,26 +80,55 @@ void do_oops_buttons(short event) { float dx, dy; + /* used for maximize hack */ + int win_width, win_height; + float aspect_win, aspect_oops, oops_width, oops_height, oops_x_mid, oops_y_mid; + + if(curarea->win==0) return; - - switch(event) { - case B_OOPSHOME: - init_v2d_oops(curarea, curarea->spacedata.first); // forces min/max to be reset - boundbox_oops(0); - G.v2d->cur= G.v2d->tot; - dx= 0.15*(G.v2d->cur.xmax-G.v2d->cur.xmin); - dy= 0.15*(G.v2d->cur.ymax-G.v2d->cur.ymin); - G.v2d->cur.xmin-= dx; - G.v2d->cur.xmax+= dx; - G.v2d->cur.ymin-= dy; - G.v2d->cur.ymax+= dy; - test_view2d(G.v2d, curarea->winx, curarea->winy); - scrarea_queue_winredraw(curarea); - break; - case B_OOPSVIEWSEL: + if (event == B_NEWOOPS) { + scrarea_queue_winredraw(curarea); + scrarea_queue_headredraw(curarea); + G.soops->lockpoin= 0; + } else { /* must be either B_OOPSHOME or B_OOPSVIEWSEL */ init_v2d_oops(curarea, curarea->spacedata.first); // forces min/max to be reset - boundbox_oops(1); + if (event == B_OOPSHOME) { + boundbox_oops(0); /* Test all oops blocks */ + } else { + boundbox_oops(1); /* Test only selected oops blocks */ + } + + + /* Hack to work with test_view2d in drawipo.c + Modify the bounding box so it is maximized to the window aspect + so viewing all oops blocks isnt limited to hoz/vert only. + Cant modify drawipo.c because many other functions use this hos/vert operation - Campbell*/ + + win_width= curarea->winrct.xmax - curarea->winrct.xmin; + win_height= curarea->winrct.ymax - curarea->winrct.ymin; + + oops_width = G.v2d->tot.xmax - G.v2d->tot.xmin; + oops_height = G.v2d->tot.ymax - G.v2d->tot.ymin; + + oops_x_mid = (G.v2d->tot.xmax + G.v2d->tot.xmin)*0.5; + oops_y_mid = (G.v2d->tot.ymax + G.v2d->tot.ymin)*0.5; + /* wide windows will be above 1, skinny below 1 */ + aspect_win= (float)win_width / (float)win_height; + aspect_oops = (float)oops_width / (float)oops_height; + if (aspect_win>aspect_oops) {/* the window is wider then the oops bounds, increase the oops width */ + G.v2d->tot.xmin = oops_x_mid - ((oops_x_mid-G.v2d->tot.xmin) * (aspect_win/aspect_oops) ); /* scale the min */ + G.v2d->tot.xmax = oops_x_mid + ((G.v2d->tot.xmax-oops_x_mid) * (aspect_win/aspect_oops) );/* scale the max */ + } else { /* the window is skinnier then the oops bounds, increase the oops height */ + G.v2d->tot.ymin = oops_y_mid - ((oops_y_mid-G.v2d->tot.ymin) * (aspect_oops/aspect_win) ); /* scale the min */ + G.v2d->tot.ymax = oops_y_mid + ((G.v2d->tot.ymax-oops_y_mid) * (aspect_oops/aspect_win) );/* scale the max */ + } + + /* maybe we should restore the correct values? - do next of its needed */ + /* end hack */ + + + G.v2d->cur= G.v2d->tot; dx= 0.15*(G.v2d->cur.xmax-G.v2d->cur.xmin); dy= 0.15*(G.v2d->cur.ymax-G.v2d->cur.ymin); @@ -109,13 +138,6 @@ void do_oops_buttons(short event) G.v2d->cur.ymax+= dy; test_view2d(G.v2d, curarea->winx, curarea->winy); scrarea_queue_winredraw(curarea); - break; - - case B_NEWOOPS: - scrarea_queue_winredraw(curarea); - scrarea_queue_headredraw(curarea); - G.soops->lockpoin= 0; - break; } } |