diff options
author | Damien Plisson <damien.plisson@yahoo.fr> | 2010-01-11 14:14:36 +0300 |
---|---|---|
committer | Damien Plisson <damien.plisson@yahoo.fr> | 2010-01-11 14:14:36 +0300 |
commit | 4a011a99cb9f45e0d76b134d72c2c2ab150ba006 (patch) | |
tree | 6141ccea3ff99236c32e31f479ef5ba36835a629 /source/blender/editors/interface/view2d_ops.c | |
parent | ebb9286fd65d3cb1aae001080dbdb7102e7b49bf (diff) |
Multitouch trackpad 2 fingers gestures implementation
- 2 fingers scroll (MOUSEPAN / GHOST_kTrackpadEventScroll event) pans/scrolls the view
- 2 fingers pinch (MOUSEZOOM / GHOST_kTrackpadEventMagnify event) zooms the view
And in 3D view:
- alt + 2 fingers scroll rotates the view
- 2 fingers rotation (MOUSEROTATE / GHOST_kTrackpadEventRotate) orbits the view.
The implementation uses a new GHOST event type: GHOST_kEventTrackpad, that is then dispatched as Blender MOUSEPAN, MOUSEZOOM
or MOUSEROTATE events.
This is currently fully implemented for OSX (GHOST Cocoa fires the new events), with auto-detection of the source peripheral, so that a regular mouse still sends MOUSEWHEEL events.
Diffstat (limited to 'source/blender/editors/interface/view2d_ops.c')
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 57882b7dd0d..bd325eb79eb 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -199,6 +199,16 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) /* set initial settings */ vpd->startx= vpd->lastx= event->x; vpd->starty= vpd->lasty= event->y; + + if (event->type == MOUSEPAN) { + RNA_int_set(op->ptr, "deltax", event->prevx - event->x); + RNA_int_set(op->ptr, "deltay", event->prevy - event->y); + + view_pan_apply(C, op); + view_pan_exit(C, op); + return OPERATOR_FINISHED; + } + RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 0); @@ -789,6 +799,26 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) vzd= op->customdata; v2d= vzd->v2d; + if (event->type == MOUSEZOOM) { + float dx, dy, fac; + + vzd->lastx= event->prevx; + vzd->lasty= event->prevy; + + /* As we have only 1D information (magnify value), feed both axes + with magnify information that is stored in x axis */ + fac= 0.01f * (event->x - event->prevx); + dx= fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f; + dy= fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f; + + RNA_float_set(op->ptr, "deltax", dx); + RNA_float_set(op->ptr, "deltay", dy); + + view_zoomdrag_apply(C, op); + view_zoomdrag_exit(C, op); + return OPERATOR_FINISHED; + } + /* set initial settings */ vzd->lastx= event->x; vzd->lasty= event->y; @@ -1467,6 +1497,8 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0); @@ -1489,6 +1521,7 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) /* zoom - drag */ WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0); /* borderzoom - drag */ WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); @@ -1499,9 +1532,11 @@ void UI_view2d_keymap(wmKeyConfig *keyconf) /* Alternative keymap for buttons listview */ keymap= WM_keymap_find(keyconf, "View2D Buttons List", 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_pan", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "VIEW2D_OT_zoom", MOUSEZOOM, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0); |