From 1dfb6404b78396988fedf5ad2bd111c6af13cf12 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 8 Feb 2013 12:12:57 +0000 Subject: [PATCH] Release todo: added userpref for Mac users having "Natural Scroll" set. As per discussion and analysis of all trackpad usage, we now follow this convention: - Blender follows system setting for trackpad direction preference. - If you set your system to "natural" scroll, we need to invert a couple of cases in Blender we do "natural" already. Like: - view rotate (the inversed option just never feels ok) - scroll active items in list or pulldown menu (up/down is absolute) - ALT+scroll values in buttons (up/down is absolute) The new User Preference setting "Trackpad Natural" handles this. For 2.66 we only have trackpad handling for OS X... so this isn't affecting trackpad usage in Windows and Linux, which stick to be mapped to Scroll Wheel still. (Note: viewrotate now is "natural" always, changing how it worked in the past weeks). --- release/datafiles/matcaps/license.txt | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 7 +++++++ source/blender/editors/interface/interface_handlers.c | 8 +++++++- source/blender/editors/space_view3d/view3d_edit.c | 8 ++++++-- source/blender/makesdna/DNA_userdef_types.h | 3 ++- source/blender/makesrna/intern/rna_userdef.c | 6 +++++- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/release/datafiles/matcaps/license.txt b/release/datafiles/matcaps/license.txt index 2670a62e311..358c8dcd832 100644 --- a/release/datafiles/matcaps/license.txt +++ b/release/datafiles/matcaps/license.txt @@ -1,3 +1,3 @@ These matcap images are licensed as GNU GPL 2 or later, like the rest of Blender's code. -Thanks to Kent Trammell, Aidy Burrows, John Herreno , Terry Wallwork for making the pictures. +Thanks to Kent Trammell, Aidy Burrows, John Herreno , Terry Wallwork and David Silverman for making the pictures. diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 2a2db40310c..32eb1a593eb 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -963,6 +963,8 @@ class USERPREF_PT_input(Panel, InputKeyMapPanel): return (userpref.active_section == 'INPUT') def draw_input_prefs(self, inputs, layout): + import sys + # General settings row = layout.row() col = row.column() @@ -1015,6 +1017,11 @@ class USERPREF_PT_input(Panel, InputKeyMapPanel): sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction") #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines") + if sys.platform == "darwin": + sub = col.column() + sub.label(text="Trackpad:") + sub.prop(inputs, "use_trackpad_natural") + col.separator() sub = col.column() sub.label(text="NDOF Device:") diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 648857170ed..edd5b901ca1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -237,8 +237,14 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) lastdy += dy; if (ABS(lastdy) > (int)UI_UNIT_Y) { + int dy = event->prevy - event->y; + + if (U.uiflag2 & USER_TRACKPAD_NATURAL) + dy = -dy; + *val = KM_PRESS; - if (event->prevy - event->y > 0) + + if (dy > 0) *type = WHEELUPMOUSE; else *type = WHEELDOWNMOUSE; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 562d1ec4b64..5c2e75776e4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -921,8 +921,12 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) } if (event->type == MOUSEPAN) { - /* invert it, trackpad scroll then follows how you mapped it globally */ - viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); + /* Rotate direction we keep always same */ + if (U.uiflag2 & USER_TRACKPAD_NATURAL) + viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); + else + viewrotate_apply(vod, event->prevx, event->prevy); + ED_view3d_depth_tag_update(rv3d); viewops_data_free(C, op); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 861d44b214e..2d8d808198d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -568,7 +568,8 @@ typedef enum eUserpref_UI_Flag { /* uiflag2 */ typedef enum eUserpref_UI_Flag2 { USER_KEEP_SESSION = (1 << 0), - USER_REGION_OVERLAP = (1 << 1) + USER_REGION_OVERLAP = (1 << 1), + USER_TRACKPAD_NATURAL = (1 << 2) } eUserpref_UI_Flag2; /* Auto-Keying mode */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0def5988315..2b2f1a2469b 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3549,7 +3549,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) "Draw tool/property regions over the main region, when using Triple Buffer"); RNA_def_property_update(prop, 0, "rna_userdef_dpi_update"); - #ifdef WITH_CYCLES prop = RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); @@ -3755,6 +3754,11 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_range(prop, 0, 32); RNA_def_property_ui_text(prop, "Wheel Scroll Lines", "Number of lines scrolled at a time with the mouse wheel"); + prop = RNA_def_property(srna, "use_trackpad_natural", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag2", USER_TRACKPAD_NATURAL); + RNA_def_property_ui_text(prop, "Trackpad Natural", + "If your system uses 'natural' scrolling, this option keeps consistent trackpad usage throughout the UI"); + prop = RNA_def_property(srna, "active_keyconfig", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "keyconfigstr"); RNA_def_property_ui_text(prop, "Key Config", "The name of the active key configuration");