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/space_image | |
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/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 2 |
2 files changed, 33 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 827b2ddeac2..cef92153725 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -214,8 +214,21 @@ static int view_pan_exec(bContext *C, wmOperator *op) static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) { - view_pan_init(C, op, event); - return OPERATOR_RUNNING_MODAL; + if (event->type == MOUSEPAN) { + SpaceImage *sima= CTX_wm_space_image(C); + float offset[2]; + + offset[0]= (event->x - event->prevx)/sima->zoom; + offset[1]= (event->y - event->prevy)/sima->zoom; + RNA_float_set_array(op->ptr, "offset", offset); + + view_pan_exec(C, op); + return OPERATOR_FINISHED; + } + else { + view_pan_init(C, op, event); + return OPERATOR_RUNNING_MODAL; + } } static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) @@ -331,8 +344,22 @@ static int view_zoom_exec(bContext *C, wmOperator *op) static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { - view_zoom_init(C, op, event); - return OPERATOR_RUNNING_MODAL; + if (event->type == MOUSEZOOM) { + SpaceImage *sima= CTX_wm_space_image(C); + ARegion *ar= CTX_wm_region(C); + float factor; + + factor= 1.0 + (event->x-event->prevx+event->y-event->prevy)/300.0f; + RNA_float_set(op->ptr, "factor", factor); + sima_zoom_set(sima, ar, sima->zoom*factor); + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; + } + else { + view_zoom_init(C, op, event); + return OPERATOR_RUNNING_MODAL; + } } static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 4622962bac5..6c325d9722f 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -219,12 +219,14 @@ void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MOUSEZOOM, 0, 0, 0); RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f); RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f); |