zoom operator.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 22 Apr 2011 14:47:35 +0000 (14:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 22 Apr 2011 14:47:35 +0000 (14:47 +0000)
- continue zoom now uses the same options as dolly (hoz/vert & invert).
- remove event mouse coord hack to bypass touchpad zoom invert, instead pass invert as an argument.

release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/space_view3d/view3d_edit.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/render/intern/source/rayshade.c

index 13ff09d7f23110d9b15e32d109cdce0ec6234903..7ae2efb369694b203c7bf3a860b5cb2cc30769ed 100644 (file)
@@ -800,9 +800,9 @@ class USERPREF_PT_input(InputKeyMapPanel):
 
         sub.label(text="Zoom Style:")
         sub.row().prop(inputs, "view_zoom_method", text="")
-        if inputs.view_zoom_method == 'DOLLY':
+        if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
             sub.row().prop(inputs, "view_zoom_axis", expand=True)
-            sub.prop(inputs, "invert_mouse_wheel_zoom")
+            sub.prop(inputs, "invert_mouse_zoom")
 
         #sub.prop(inputs, "use_mouse_mmb_paste")
 
index 67576c188afe5b9d338484b4e1d500ad69a2e0ca..2b971a84af62baa2b47c8d7c2eeb30318bbeef94 100644 (file)
@@ -1075,16 +1075,28 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
 }
 
 
-static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom)
+static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, const short zoom_invert)
 {
        float zfac=1.0;
 
        if(viewzoom==USER_ZOOM_CONT) {
                double time= PIL_check_seconds_timer();
                float time_step= (float)(time - vod->timer_lastdraw);
+               float fac;
+
+               if (U.uiflag & USER_ZOOM_HORIZ) {
+                       fac= (float)(x - vod->origx);
+               }
+               else {
+                       fac= (float)(y - vod->origy);
+               }
+
+               if(zoom_invert) {
+                       fac= -fac;
+               }
 
                // oldstyle zoom
-               zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y) / 20.0f) * time_step);
+               zfac = 1.0f + ((fac / 20.0f) * time_step);
                vod->timer_lastdraw= time;
        }
        else if(viewzoom==USER_ZOOM_SCALE) {
@@ -1102,7 +1114,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom)
        else {  /* USER_ZOOM_DOLLY */
                float len1, len2;
                
-               if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) {
+               if (U.uiflag & USER_ZOOM_HORIZ) {
                        len1 = (vod->ar->winrct.xmax - x) + 5;
                        len2 = (vod->ar->winrct.xmax - vod->origx) + 5;
                }
@@ -1110,14 +1122,15 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom)
                        len1 = (vod->ar->winrct.ymax - y) + 5;
                        len2 = (vod->ar->winrct.ymax - vod->origy) + 5;
                }
-               if (U.uiflag & USER_ZOOM_INVERT)
+               if (zoom_invert) {
                        SWAP(float, len1, len2);
+               }
                
                zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist;
        }
 
        if(zfac != 1.0f && zfac*vod->rv3d->dist > 0.001f * vod->grid &&
-                               zfac * vod->rv3d->dist < 10.0f * vod->far)
+                       zfac * vod->rv3d->dist < 10.0f * vod->far)
                view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy);
 
 
@@ -1179,7 +1192,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
        }
 
        if(event_code==VIEW_APPLY) {
-               viewzoom_apply(vod, event->x, event->y, U.viewzoom);
+               viewzoom_apply(vod, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0);
        }
        else if (event_code==VIEW_CONFIRM) {
                request_depth_update(vod->rv3d);
@@ -1272,18 +1285,16 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
                vod= op->customdata;
 
                if (event->type == MOUSEZOOM) {
-                       if (U.uiflag & USER_ZOOM_INVERT) /* Bypass Zoom invert flag */
-                               SWAP(int, event->x, event->prevx);
+                       /* Bypass Zoom invert flag for track pads (pass FALSE always) */
 
-                       if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) {
+                       if (U.uiflag & USER_ZOOM_HORIZ) {
                                vod->origx = vod->oldx = event->x;
-                               viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY);
+                               viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE);
                        }
                        else {
-                               
                                /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */
                                vod->origy = vod->oldy = vod->origy + event->x - event->prevx;
-                               viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY);
+                               viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE);
                        }
                        request_depth_update(vod->rv3d);
                        
index 1eff1c3c640adb26047d45395b1aad4b7122f4db..1be67a4501b1443ded4755a8ee4c031525102375 100644 (file)
@@ -476,7 +476,7 @@ extern UserDef U; /* from blenkernel blender.c */
 #define USER_MENUFIXEDORDER            (1 << 23)
 #define USER_CONTINUOUS_MOUSE  (1 << 24)
 #define USER_ZOOM_INVERT               (1 << 25)
-#define USER_ZOOM_DOLLY_HORIZ  (1 << 26)
+#define USER_ZOOM_HORIZ                (1 << 26) /* for CONTINUE and DOLLY zoom */
 #define USER_SPLASH_DISABLE            (1 << 27)
 #define USER_HIDE_RECENT               (1 << 28)
 #define USER_SHOW_THUMBNAILS   (1 << 29)
index c21feead18f0665eae0d624756b76cb6e2c76331..a914d87549000717668890f8580d920867e019f5 100644 (file)
@@ -2651,8 +2651,8 @@ static void rna_def_userdef_input(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}};
        
        static EnumPropertyItem view_zoom_axes[] = {
-               {0,                                             "VERTICAL", 0, "Vertical", "Zooms in and out based on vertical mouse movement"},
-               {USER_ZOOM_DOLLY_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zooms in and out based on horizontal mouse movement"},
+               {0, "VERTICAL", 0, "Vertical", "Zooms in and out based on vertical mouse movement"},
+               {USER_ZOOM_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zooms in and out based on horizontal mouse movement"},
                {0, NULL, 0, NULL, NULL}};
                
        srna= RNA_def_struct(brna, "UserPreferencesInput", NULL);
@@ -2676,7 +2676,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, view_zoom_axes);
        RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
        
-       prop= RNA_def_property(srna, "invert_mouse_wheel_zoom", PROP_BOOLEAN, PROP_NONE);
+       prop= RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
        RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");
        
index 4147fc4cdd88e03e53649fd8009546c5a793863e..b57fe5a8c3bc50bdee00df107f1b27a8a1d930d9 100644 (file)
@@ -445,7 +445,7 @@ void makeraytree(Render *re)
        re->i.infostr= "Raytree.. preparing";
        re->stats_draw(re->sdh, &re->i);
 
-       /* disable options not yet suported by octree,
+       /* disable options not yet supported by octree,
           they might actually never be supported (unless people really need it) */
        if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE)
                re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS);