FR: Viewport improvements

Hi everybody. I’d like to suggest some improvements to the Viewport class regarding touch gestures. These issues have been mentioned many times but since I see no feature request I thought it’d be good to collect them into one. The first point is the most important but also the most difficult to implement while the others are relatively minor (but still quite bothersome!).

  1. Swiping on a viewport which contains GUI elements should have the same behaviour as in iOS and Android. If the user begins a swipe movement over a button, the user expects to scroll the viewport and not to click the button. This applies to pretty much all GUI elements. Currently, getting things to work this way in JUCE requires a considerable amount of custom code. And getting elements such as comboBoxes, sliders and treeViews to work well is specially fiddly, one reason being that they react to and require a mouseDown event.

  2. When the user drags to scroll and causes inertia, if the user then touches to stop the scrolling, the inertia is not reset and the scrolling continues when the touch is released.

  3. At the beginning of a scrolling gesture the viewport “jumps”, apparently by the minimum amount of pixels by which a drag is recognized as such. It should instead start moving smoothly.

  4. Multi-touch could be improved by making the scrolling follow only the finger which initiates the gesture and disregarding of the other fingers. The dragging is currently interrupted when the user touches the screen with a second finger. EDIT: This has been fixed :slightly_smiling_face:

  5. It would be nice if the view would scroll slightly past the bounds and then bounce back instead of simply stopping when the limits are reached. Users are used to this behaviour.

  6. If one is scrolling a ValueTree by dragging and leaves the bounds of the tree, the gesture is at some point interrupted and the tree jumps back to the position it had at the beginning of the drag gesture. EDIT: I’ve discovered that it can also cause the app to crash. This can be “fixed” by increasing the value used in the function addOffscreenItemBuffer in juce_TreeView.cpp

  7. Also regarding ValueTrees, dragging to scroll in one direction and then in the other doesn’t work properly. The view often moves for an instant but then stops. This can be reproduced in the ValueTreesDemo. Simply add tree.getViewport()->setScrollOnDragEnabled (true); and then scroll up and down left of the tree items. EDIT: Please disregard this last point. This seems to be working properly after all. It was either fixed or (most probably) due to some misconfiguration on my part.

Here are some threads where these issues have been mentioned:

3 Likes

Point 6 has also been fixed :grinning: Thanks @ed95