aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shapes/shapes.pro
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-09-22 22:48:25 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-01-25 16:23:08 +0000
commitbf5f171db212b7e57493f31f41e05e2d68ade791 (patch)
tree5b9b1c0796c5910e8a1cb918fd685bffc0a2d8ec /examples/quick/shapes/shapes.pro
parentbf74a908cb0591c2adc024a6f93d566c7348c125 (diff)
QQuickShape: override contains(QPointF); demonstrate in examples
QQuickItem::contains() only checks the Item's bounding box by default. In the case of Shapes, that can be comically imprecise, but it's fast. So we add a containsMode property to control whether we will do that (the default) or actually check each of the QPainterPaths within to see whether they contain the point (FillContains). FillContains could be optimized later: use QRegion perhaps, or download the rendered texture from the GPU and test whether the pixel at the point is transparent. It may also be appropriate to add a StrokeContains option. The main motivation is to detect mouse (or touch) interaction within a shaped area. QQuickSinglePointHandler::wantsEventPoint() already checks whether its parent Item contains the event point. So if a Shape has a TapHandler for example, it will respond only within the visible bounds of the Shape rather than within the entire rectangular bounding box as long as containsMode is set to FillContains. Examples quick/shapes/content/tapableTriangle.qml and tiger.qml are modified to react when a press occurs inside, and the former is fixed to be able to run standalone via the qml runtime. The latter has an offset issue when run standalone but is OK within the shape gallery example. As a drive-by optimization, QQuickShapePrivate's variables are re-ordered by type so that the compiler can place the bools and enums into bitfields; and to facilitate reordering, the initialization is done C++11-style, in the header. [ChangeLog][QtQuick][Shape] A containsMode property is added. If it is set to FillContains, then Shape.contains() returns true only within the visible bounds, so its Pointer Handlers also respond only within those bounds. Change-Id: I31c85a9b08aa6945c58dc07febfe89ffef21274b Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Diffstat (limited to 'examples/quick/shapes/shapes.pro')
-rw-r--r--examples/quick/shapes/shapes.pro2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/quick/shapes/shapes.pro b/examples/quick/shapes/shapes.pro
index c28359b13c..ff6fa422fb 100644
--- a/examples/quick/shapes/shapes.pro
+++ b/examples/quick/shapes/shapes.pro
@@ -9,7 +9,7 @@ OTHER_FILES += content/main.qml \
content/sampling.qml \
content/clippedtigers.qml \
content/tiger.qml \
- content/item1.qml \
+ content/tapableTriangle.qml \
content/item2.qml \
content/item3.qml \
content/item4.qml \