diff options
author | Andy Shaw <andy.shaw@digia.com> | 2014-04-03 12:41:00 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-14 15:07:34 +0200 |
commit | 67f6c0bc3052a5c14d4b556c25e376fe97c7973e (patch) | |
tree | 5288ae50737103ce6db2c0847ba982c0be3b7d9a /src/controls | |
parent | efbaa82fc79f3bee5486c12acf21e71cfaaed093 (diff) | |
download | qtquickcontrols-67f6c0bc3052a5c14d4b556c25e376fe97c7973e.tar.gz qtquickcontrols-67f6c0bc3052a5c14d4b556c25e376fe97c7973e.tar.bz2 qtquickcontrols-67f6c0bc3052a5c14d4b556c25e376fe97c7973e.zip |
Scroll the parent mouse areas when reaching the bounds of a ScrollView
Change-Id: I18da235e81fa7547b78b623257226dd4a745b518
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/Private/qquickwheelarea.cpp | 36 | ||||
-rw-r--r-- | src/controls/Private/qquickwheelarea_p.h | 5 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/controls/Private/qquickwheelarea.cpp b/src/controls/Private/qquickwheelarea.cpp index e276247b..5fb3e4a6 100644 --- a/src/controls/Private/qquickwheelarea.cpp +++ b/src/controls/Private/qquickwheelarea.cpp @@ -77,6 +77,26 @@ QQuickWheelArea::~QQuickWheelArea() } +bool QQuickWheelArea::isAtXEnd() const +{ + return qFuzzyCompare(m_horizontalMaximumValue, m_horizontalValue); +} + +bool QQuickWheelArea::isAtXBeginning() const +{ + return qFuzzyCompare(m_horizontalMinimumValue, m_horizontalValue); +} + +bool QQuickWheelArea::isAtYEnd() const +{ + return qFuzzyCompare(m_verticalMaximumValue, m_verticalValue); +} + +bool QQuickWheelArea::isAtYBeginning() const +{ + return qFuzzyCompare(m_verticalMinimumValue, m_verticalValue); +} + void QQuickWheelArea::wheelEvent(QWheelEvent *we) { if (we->phase() == Qt::ScrollBegin) @@ -95,7 +115,21 @@ void QQuickWheelArea::wheelEvent(QWheelEvent *we) setVerticalDelta(numDegrees.y() / 15.0 * m_scrollSpeed); } - we->accept(); + // This allows other parent WheelArea's to handle scrolling + // For example this allows for ScrollView inside of another ScrollView to work correctly + // Once this scrollbar can't scroll anymore, ie it reaches the limits, + // it will ignore the scroll event so the parent WheelArea can start scrolling + if ((numPixels.x() != 0 || numDegrees.x() != 0) && + m_horizontalMinimumValue <= m_horizontalMaximumValue && + (isAtXBeginning() || isAtXEnd())) { + we->ignore(); + } else if ((numPixels.y() != 0 || numDegrees.y() != 0) && + m_verticalMinimumValue <= m_verticalMaximumValue && + (isAtYBeginning() || isAtYEnd())) { + we->ignore(); + } else { + we->accept(); + } } void QQuickWheelArea::setHorizontalMinimumValue(qreal value) diff --git a/src/controls/Private/qquickwheelarea_p.h b/src/controls/Private/qquickwheelarea_p.h index ebaa1453..7f9f2b7e 100644 --- a/src/controls/Private/qquickwheelarea_p.h +++ b/src/controls/Private/qquickwheelarea_p.h @@ -97,6 +97,11 @@ public: void wheelEvent(QWheelEvent *event); + bool isAtXEnd() const; + bool isAtXBeginning() const; + bool isAtYEnd() const; + bool isAtYBeginning() const; + Q_SIGNALS: void verticalValueChanged(); void horizontalValueChanged(); |