aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shapes/content/tapableTriangle.qml
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of Qt.labs.handlers import, merge into QtQuick 2.12Shawn Rutledge2018-07-171-3/+2
| | | | | | | ... and clean up imports in examples, snippets and tests accordingly. Change-Id: I5bbe63afd2614cdc2c1ec7d179c9acd6bc03b167 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* rename containsMask to containmentMaskShawn Rutledge2018-02-271-1/+1
| | | | | | | | | It was pointed out that containsMask sounds like it ought to be a boolean property. Change-Id: I2b56823b60d64f9903b0d5108c6428e691c09ed0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
* demonstrate containsMask in the tapableTriangle Shape exampleShawn Rutledge2018-01-261-2/+3
| | | | | | | | | | This isn't an improvement in behvior, it just shows that a Shape can be used as a mask on some other Item. But Shape.containsMode is still important so that when the outer Rectangle's contains() calls Shape.contains(), the latter will do the right thing. Change-Id: I1bd127784e708f30561945a4958e4d5f0c1c0b85 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
* QQuickShape: override contains(QPointF); demonstrate in examplesShawn Rutledge2018-01-251-0/+101
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>