zoom operator.

- 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.
This commit is contained in:
Campbell Barton
2011-04-22 14:47:35 +00:00
parent 05c7db95b6
commit ee9ea98e48
5 changed files with 30 additions and 19 deletions

View File

@@ -800,9 +800,9 @@ class USERPREF_PT_input(InputKeyMapPanel):
sub.label(text="Zoom Style:") sub.label(text="Zoom Style:")
sub.row().prop(inputs, "view_zoom_method", text="") 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.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") #sub.prop(inputs, "use_mouse_mmb_paste")

View 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; float zfac=1.0;
if(viewzoom==USER_ZOOM_CONT) { if(viewzoom==USER_ZOOM_CONT) {
double time= PIL_check_seconds_timer(); double time= PIL_check_seconds_timer();
float time_step= (float)(time - vod->timer_lastdraw); 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 // 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; vod->timer_lastdraw= time;
} }
else if(viewzoom==USER_ZOOM_SCALE) { 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 */ else { /* USER_ZOOM_DOLLY */
float len1, len2; float len1, len2;
if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) { if (U.uiflag & USER_ZOOM_HORIZ) {
len1 = (vod->ar->winrct.xmax - x) + 5; len1 = (vod->ar->winrct.xmax - x) + 5;
len2 = (vod->ar->winrct.xmax - vod->origx) + 5; len2 = (vod->ar->winrct.xmax - vod->origx) + 5;
} }
@@ -1110,8 +1122,9 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom)
len1 = (vod->ar->winrct.ymax - y) + 5; len1 = (vod->ar->winrct.ymax - y) + 5;
len2 = (vod->ar->winrct.ymax - vod->origy) + 5; len2 = (vod->ar->winrct.ymax - vod->origy) + 5;
} }
if (U.uiflag & USER_ZOOM_INVERT) if (zoom_invert) {
SWAP(float, len1, len2); SWAP(float, len1, len2);
}
zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist; zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist;
} }
@@ -1179,7 +1192,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
} }
if(event_code==VIEW_APPLY) { 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) { else if (event_code==VIEW_CONFIRM) {
request_depth_update(vod->rv3d); request_depth_update(vod->rv3d);
@@ -1272,18 +1285,16 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
vod= op->customdata; vod= op->customdata;
if (event->type == MOUSEZOOM) { if (event->type == MOUSEZOOM) {
if (U.uiflag & USER_ZOOM_INVERT) /* Bypass Zoom invert flag */ /* Bypass Zoom invert flag for track pads (pass FALSE always) */
SWAP(int, event->x, event->prevx);
if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) { if (U.uiflag & USER_ZOOM_HORIZ) {
vod->origx = vod->oldx = event->x; 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 { else {
/* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */ /* 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; 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); request_depth_update(vod->rv3d);

View File

@@ -476,7 +476,7 @@ extern UserDef U; /* from blenkernel blender.c */
#define USER_MENUFIXEDORDER (1 << 23) #define USER_MENUFIXEDORDER (1 << 23)
#define USER_CONTINUOUS_MOUSE (1 << 24) #define USER_CONTINUOUS_MOUSE (1 << 24)
#define USER_ZOOM_INVERT (1 << 25) #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_SPLASH_DISABLE (1 << 27)
#define USER_HIDE_RECENT (1 << 28) #define USER_HIDE_RECENT (1 << 28)
#define USER_SHOW_THUMBNAILS (1 << 29) #define USER_SHOW_THUMBNAILS (1 << 29)

View File

@@ -2652,7 +2652,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
static EnumPropertyItem view_zoom_axes[] = { static EnumPropertyItem view_zoom_axes[] = {
{0, "VERTICAL", 0, "Vertical", "Zooms in and out based on vertical mouse movement"}, {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"}, {USER_ZOOM_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zooms in and out based on horizontal mouse movement"},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "UserPreferencesInput", 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_enum_items(prop, view_zoom_axes);
RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on"); 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_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"); RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");

View File

@@ -445,7 +445,7 @@ void makeraytree(Render *re)
re->i.infostr= "Raytree.. preparing"; re->i.infostr= "Raytree.. preparing";
re->stats_draw(re->sdh, &re->i); 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) */ they might actually never be supported (unless people really need it) */
if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE)
re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS); re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS);