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

Cannot affect position of containmentMask item

    XMLWordPrintable

Details

    Description

      After discussing potential solutions to QTBUG-82678, we thought that using containmentMask to extend the interactive area of a SplitView handle could be a nice solution. However, it doesn't work:

      import QtQuick
      import QtQuick.Controls
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          SplitView {
              id: control
              anchors.fill: parent
              orientation: Qt.Horizontal
              handle: Rectangle {
                  implicitWidth: control.orientation === Qt.Horizontal ? 6 : control.width
                  implicitHeight: control.orientation === Qt.Horizontal ? control.height : 6
                  color: SplitHandle.pressed ? control.palette.mid
                      : (SplitHandle.hovered ? control.palette.midlight : control.palette.button)
      
                  containmentMask: Item {
                      x: control.orientation === Qt.Horizontal ? -width / 2 : 0
                      y: control.orientation === Qt.Horizontal ? 0 : -height / 2
                      width: control.orientation === Qt.Horizontal ? 30 : control.width
                      height: control.orientation === Qt.Horizontal ? control.height : 30
                  }
              }
              Rectangle {
                  implicitWidth: 200
                  SplitView.maximumWidth: 400
                  color: "lightblue"
                  Label {
                      text: "View 1"
                      anchors.centerIn: parent
                  }
              }
              Rectangle {
                  id: centerItem
                  SplitView.minimumWidth: 50
                  SplitView.fillWidth: true
                  color: "lightgray"
                  Label {
                      text: "View 2"
                      anchors.centerIn: parent
                  }
              }
              Rectangle {
                  implicitWidth: 200
                  color: "lightgreen"
                  Label {
                      text: "View 3"
                      anchors.centerIn: parent
                  }
              }
          }
      }
      

      Simpler, Qt Quick-only example:

      import QtQuick
      
      Window {
          id: window
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              id: control
              width: 10
              height: 100
              color: tapHandler.pressed ? Qt.darker("#444") : (hoverHandler.hovered ? Qt.lighter("#444") : "#444")
              anchors.centerIn: parent
      
              TapHandler {
                  id: tapHandler
              }
              HoverHandler {
                  id: hoverHandler
              }
      
              containmentMask: Item {
                  x: (control.width - width) / 2
                  width: 30
                  height: control.height
              }
          }
      
          Rectangle {
              color: "transparent"
              border.color: "darkorange"
              x: control.x + control.containmentMask.x
              y: control.y + control.containmentMask.y
              width: control.containmentMask.width
              height: control.containmentMask.height
          }
      }
      

      The position of the containmentMask does not seem to be taken into account; it is always positioned at {0, 0}.

      Fixing this should be behaviourally compatible.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes