Bugfix for http://projects.blender.org/tracker/?func=detail&atid=125&aid=3767&group_id=9
authorCampbell Barton <ideasman42@gmail.com>
Thu, 19 Jan 2006 01:15:17 +0000 (01:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 19 Jan 2006 01:15:17 +0000 (01:15 +0000)
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.

source/blender/src/editoops.c
source/blender/src/header_oops.c

index 2b4a3e869f8548c5a0ca510047cc8d1df06ee1a3..8b1f96e35690e25d35f32337e89e5f0cf11123ff 100644 (file)
@@ -335,6 +335,7 @@ void transform_oops(int mode, int context)
                        if(val) {
                                switch(event) {
                                case ESCKEY:
+                               case RIGHTMOUSE:
                                case LEFTMOUSE:
                                case SPACEKEY:
                                case RETKEY:
@@ -358,7 +359,7 @@ void transform_oops(int mode, int context)
                }
        }
        
-       if(event==ESCKEY) {
+       if(event==ESCKEY || event==RIGHTMOUSE) {
                tv= transmain;
                for(a=0; a<tot; a++, tv++) {
                        tv->loc[0]= tv->oldloc[0];
index 6316d6d6bac4786fd4ad00af7eeee0aabb5efb1b..e7b168bbd64dc6a36e91ab99b3319d6f57fe3bad 100644 (file)
@@ -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;
        }
 }