UI: popovers scroll now changes offset directly
authorCampbell Barton <ideasman42@gmail.com>
Thu, 21 Mar 2019 00:37:44 +0000 (11:37 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 21 Mar 2019 00:37:44 +0000 (11:37 +1100)
Mouse wheel on menus changes the selected item item which doesn't work
well for popovers since buttons aren't always stacked vertically.

Resolves T62777

source/blender/editors/interface/interface_handlers.c

index c7a02e0..d07dba8 100644 (file)
@@ -8922,10 +8922,38 @@ static int ui_handle_menu_event(
                                        retval = WM_UI_HANDLER_BREAK;
                                        break;
 
-                               case UPARROWKEY:
-                               case DOWNARROWKEY:
                                case WHEELUPMOUSE:
                                case WHEELDOWNMOUSE:
+                               {
+                                       if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {
+                                               /* pass */
+                                       }
+                                       else if (!ui_block_is_menu(block)) {
+                                               int my_scroll = INT_MAX;
+                                               if (event->type == WHEELUPMOUSE) {
+                                                       if (block->flag & UI_BLOCK_CLIPTOP) {
+                                                               my_scroll = block->rect.ymax + (UI_UNIT_Y * 1.5);
+                                                       }
+                                               }
+                                               else if (event->type == WHEELDOWNMOUSE) {
+                                                       if (block->flag & UI_BLOCK_CLIPBOTTOM) {
+                                                               my_scroll = block->rect.ymin - (UI_UNIT_Y * 1.5);
+                                                       }
+                                               }
+                                               if (my_scroll != INT_MAX) {
+                                                       if (but) {
+                                                               but->active->cancel = true;
+                                                               button_activate_exit(C, but, but->active, false, false);
+                                                       }
+                                                       ui_menu_scroll_to_y(ar, block, my_scroll);
+                                                       WM_event_add_mousemove(C);
+                                               }
+                                               break;
+                                       }
+                                       ATTR_FALLTHROUGH;
+                               }
+                               case UPARROWKEY:
+                               case DOWNARROWKEY:
                                case MOUSEPAN:
                                        /* arrowkeys: only handle for block_loop blocks */
                                        if (IS_EVENT_MOD(event, shift, ctrl, alt, oskey)) {