From 4a011a99cb9f45e0d76b134d72c2c2ab150ba006 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Mon, 11 Jan 2010 11:14:36 +0000 Subject: 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. --- source/blender/editors/space_text/space_text.c | 1 + source/blender/editors/space_text/text_ops.c | 53 +++++++++++++++++--------- 2 files changed, 35 insertions(+), 19 deletions(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 292249bb0e8..c7601ef692e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -313,6 +313,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select", 1); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 0504db51a72..e5a1e772523 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1720,25 +1720,6 @@ static int scroll_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - SpaceText *st= CTX_wm_space_text(C); - TextScroll *tsc; - - if(RNA_property_is_set(op->ptr, "lines")) - return scroll_exec(C, op); - - tsc= MEM_callocN(sizeof(TextScroll), "TextScroll"); - tsc->first= 1; - op->customdata= tsc; - - st->flags|= ST_SCROLL_SELECT; - - WM_event_add_modal_handler(C, op); - - return OPERATOR_RUNNING_MODAL; -} - static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event) { SpaceText *st= CTX_wm_space_text(C); @@ -1816,6 +1797,40 @@ static int scroll_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } +static int scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + SpaceText *st= CTX_wm_space_text(C); + TextScroll *tsc; + + if(RNA_property_is_set(op->ptr, "lines")) + return scroll_exec(C, op); + + tsc= MEM_callocN(sizeof(TextScroll), "TextScroll"); + tsc->first= 1; + op->customdata= tsc; + + st->flags|= ST_SCROLL_SELECT; + + if (event->type == MOUSEPAN) { + text_update_character_width(st); + + tsc->hold[0] = event->prevx; + tsc->hold[1] = event->prevy; + /* Sensitivity of scroll set to 4pix per line/char */ + event->mval[0] = event->prevx + (event->x - event->prevx)*st->cwidth/4; + event->mval[1] = event->prevy + (event->y - event->prevy)*st->lheight/4; + tsc->first = 0; + tsc->scrollbar = 0; + scroll_apply(C, op, event); + scroll_exit(C, op); + return OPERATOR_FINISHED; + } + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + void TEXT_OT_scroll(wmOperatorType *ot) { /* identifiers */ -- cgit v1.2.3