[Bf-blender-cvs] [dfc576426b3] master: Allow Trackpad Ctrl-Pan to Cycle Enum Values

Yevgeny Makarov noreply at git.blender.org
Thu Oct 29 17:04:00 CET 2020


Commit: dfc576426b3999b219d8663384f66139d337649b
Author: Yevgeny Makarov
Date:   Thu Oct 29 09:01:45 2020 -0700
Branches: master
https://developer.blender.org/rBdfc576426b3999b219d8663384f66139d337649b

Allow Trackpad Ctrl-Pan to Cycle Enum Values

Allow Trackpad Ctrl-Pan to cycle enum values. Also allows cycling in more button types.

Differential Revision: https://developer.blender.org/D8535

Reviewed by Brecht Van Lommel

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 4451199bb7c..ac31148340a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4550,10 +4550,22 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
       button_activate_state(C, but, BUTTON_STATE_EXIT);
       return WM_UI_HANDLER_BREAK;
     }
-    if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
-      /* Support alt+wheel on expanded enum rows */
+    if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+      /* Support ctrl-wheel to cycle values on expanded enum rows. */
       if (but->type == UI_BTYPE_ROW) {
-        const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1;
+        int type = event->type;
+        int val = event->val;
+
+        /* Convert pan to scroll-wheel. */
+        if (type == MOUSEPAN) {
+          ui_pan_to_scroll(event, &type, &val);
+
+          if (type == MOUSEPAN) {
+            return WM_UI_HANDLER_BREAK;
+          }
+        }
+
+        const int direction = (type == WHEELDOWNMOUSE) ? -1 : 1;
         uiBut *but_select = ui_but_find_select_in_enum(but, direction);
         if (but_select) {
           uiBut *but_other = (direction == -1) ? but_select->next : but_select->prev;
@@ -5648,8 +5660,20 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
       return WM_UI_HANDLER_BREAK;
     }
     if (ui_but_supports_cycling(but)) {
-      if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
-        const int direction = (event->type == WHEELDOWNMOUSE) ? 1 : -1;
+      if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+        int type = event->type;
+        int val = event->val;
+
+        /* Convert pan to scroll-wheel. */
+        if (type == MOUSEPAN) {
+          ui_pan_to_scroll(event, &type, &val);
+
+          if (type == MOUSEPAN) {
+            return WM_UI_HANDLER_BREAK;
+          }
+        }
+
+        const int direction = (type == WHEELDOWNMOUSE) ? 1 : -1;
 
         data->value = ui_but_menu_step(but, direction);



More information about the Bf-blender-cvs mailing list