Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Plisson <damien.plisson@yahoo.fr>2010-01-11 14:14:36 +0300
committerDamien Plisson <damien.plisson@yahoo.fr>2010-01-11 14:14:36 +0300
commit4a011a99cb9f45e0d76b134d72c2c2ab150ba006 (patch)
tree6141ccea3ff99236c32e31f479ef5ba36835a629 /source/blender/editors/space_text
parentebb9286fd65d3cb1aae001080dbdb7102e7b49bf (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_text')
-rw-r--r--source/blender/editors/space_text/space_text.c1
-rw-r--r--source/blender/editors/space_text/text_ops.c53
2 files changed, 35 insertions, 19 deletions
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 */