Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109373

DragHandler and PinchHandler: meaning of axis persistentValue is wrong

    XMLWordPrintable

Details

    • 8813d9a22 (dev), fa3e60f18 (6.5)

    Description

      Docs currently have

       \c persistentValue is the same as \l {QtQuick::DragHandler::persistentTranslation}{persistentTranslation.x}.

      But that's not very useful if we are going to make QQuickDragAxis responsible for setting target properties: the axis object will set exactly the persistentValue on the target item property, NOT the delta.  If it wants to store a delta instead, we'd name it that way; but in fact, the axis object does not know how to apply the delta to the target property, which is why QQuickDragAxis::updateValue takes activeValue and accumulatedValue as separate arguments.  The handler has to provide the accumulatedValue, which will end up being the same as the target item's property value.  In the case of scale, it's multiplied by the delta, whereas for other properties it's added.  The axis doesn't know whether to multiply or add, that's why the handler has to provide the result.

      Also, it's more consistent to be able to document minimumValue <= persistentValue <= maximumValue.

      The reason this happened is that I started working with PinchHandler.scale and rotation first, with tests in which the Item's starting properties are the defaults (scale 1 and rotation 0).  But when we apply the same pattern to DragHandler, tests quickly make it clear that we must not neglect the case when the item's starting property value is different than the default.  An item might be in a specific place already before you start dragging it; so persistentTranslation is the delta to be applied, to move it according to how far you dragged, whereas the xAxis and yAxis objects are concerned with enforcing that the position itself is kept between min and max.  It's not the delta that is bounded, but the result of applying it.

      In fact, PinchHandler also needs autotests that work with items that are already rotated, scaled and/or translated before the pinch starts.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-109373
          # Subject Branch Project Status CR V

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change