diff options
author | Jarno Malmari <ext-jarno.malmari@nokia.com> | 2010-12-07 16:00:35 +0200 |
---|---|---|
committer | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2010-12-08 18:09:20 +0200 |
commit | 27570779a428f25c2d310e3fba245863a169d928 (patch) | |
tree | 81e8539dc40bd2cf380b757e29c407f9a6c8d4a8 | |
parent | 46fea17d494761ec6b40b424c2f3be88781df31a (diff) |
Fixes: Input widget relocator detects if widget is not completely shown due to clipping.
RevBy: Michael Hasselmann
Details: This is for nested pannable viewports. Previous QGraphicsItem::isObscured()
calls didn't really do anything useful. They require graphicswidgets to have
opaqueArea() implemented and don't use clipping in any way.
-rw-r--r-- | src/corelib/core/minputwidgetrelocator.cpp | 16 | ||||
-rw-r--r-- | src/corelib/core/minputwidgetrelocator.h | 3 |
2 files changed, 8 insertions, 11 deletions
diff --git a/src/corelib/core/minputwidgetrelocator.cpp b/src/corelib/core/minputwidgetrelocator.cpp index c7bf614a..8d2e2f75 100644 --- a/src/corelib/core/minputwidgetrelocator.cpp +++ b/src/corelib/core/minputwidgetrelocator.cpp @@ -326,19 +326,15 @@ bool MInputWidgetRelocator::needsRelocation(const QGraphicsWidget *inputWidget, const QRect rect(rootElement->mapRectFromItem(inputWidget, localRect).toRect()); return !allowedRect.contains(rect) - || isObscured(inputWidget, localRect); + || !isWidgetRectFullyVisible(inputWidget, localRect); } -bool MInputWidgetRelocator::isObscured(const QGraphicsWidget *widget, - const QRect &localRect) const +bool MInputWidgetRelocator::isWidgetRectFullyVisible(const QGraphicsWidget *widget, + const QRect &localRect) const { - // We need to know if widget is even partially obscured. Therefore split the - // local rect into pieces. - const QRect localTopRect(localRect.topLeft(), QSize(1, 1)); - const QRect localBottomRect(localRect.bottomLeft(), QSize(1, 1)); - - return widget->isObscured(localTopRect) - || widget->isObscured(localBottomRect); + // Widget can be clipped by a nested pannable viewport. + return !widget->isClipped() + || widget->clipPath().contains(localRect); } void MInputWidgetRelocator::centerContextWidgetToAnchorPoint(MScrollChain *newChain, diff --git a/src/corelib/core/minputwidgetrelocator.h b/src/corelib/core/minputwidgetrelocator.h index 475138dd..158ca9b6 100644 --- a/src/corelib/core/minputwidgetrelocator.h +++ b/src/corelib/core/minputwidgetrelocator.h @@ -130,7 +130,8 @@ private: bool needsRelocation(const QGraphicsWidget *inputWidget, const QRect &localRect); - bool isObscured(const QGraphicsWidget *widget, const QRect &localRect) const; + bool isWidgetRectFullyVisible(const QGraphicsWidget *widget, + const QRect &localRect) const; void centerContextWidgetToAnchorPoint(MScrollChain *newChain, const QPoint &anchorPoint, |