asteroid icon indicating copy to clipboard operation
asteroid copied to clipboard

Feature Request: Add support for rotating inputs.

Open MagneFire opened this issue 3 years ago • 1 comments

We have upcoming support for watches that have a rotating input (Fossil Gen 4, Skagen Falster 2).

Even though some aspects of the UI have support for this rotating input (app drawer when using a vertical list and settings (but has a focus issue)) proper support should be added that would allow for scrolling to the quicksettings through the apps.

Additionally for the app drawer, it might make sense to disable snapping when a crown scroll is detected as otherwise it results in jumpy behavior.

MagneFire avatar Oct 31 '21 15:10 MagneFire

Okay. So after a few tries it seems that we can handle the rotating input correctly using the following code snippet:

import QtQuick 2.15
import org.asteroid.controls 1.0
import org.asteroid.utils 1.0

Item {
    id: root
    anchors.fill: parent

    Spinner {
        id: r
        anchors.fill: parent
        height: Dims.h(60)
        model: 60
        highlightMoveDuration: 0
        highlightMoveVelocity: -1
        onCurrentIndexChanged: {
            if (currentIndex < 0) {
                currentIndex = 0
            } else if (currentIndex > model-1) {
                currentIndex = model-1
            }
            console.log(currentIndex)
        }
        WheelHandler {
            property: "currentIndex"
            target: r
            rotationScale: 1/-15
            // Reset the rotation to zero to avoid jumping from the zero index.
            onRotationChanged: if (rotation < 0) rotation = 0
        }

        delegate: SpinnerDelegate { text: index }
    }
}

A few things to note are:

  • the 1/-15 affects the rotation direction and scale. Previously it would jump three entries when only one was desired.
  • It keeps track of some internal counter. This may go out of bounds for the target ListView. We need to check these bounds.
  • The Animations are reduced/disabled to give it a more snappy feeling.

MagneFire avatar Feb 25 '22 21:02 MagneFire