GestureBuilder Class (Qt)
Objects of this type hold the touch strokes information needed to replay gesture(objectOrName, touches). An instance of this class is returned by readGesture(gesture-file). Strokes are defined by screen coordinates points, pressure and touch size.
int GestureBuilder.areaWidth
The width of the area in which this gesture is defined. This will be the device or emulator screen width.
int GestureBuilder.areaHeight
The height of the area in which this gesture is defined. This will be the device or emulator screen height.
All GestureBuilder methods listed in the Gesture creation and Gesture manipulation section, return the GestureBuilder object itself, unless specified differently.
Gesture creation
This section lists the methods for manually creating a GestureBuilder object.
GestureBuilder(width, height, unit)
GestureBuilder(xml)
Two constructor functions for creating a GestureBuilder object. The width
and height
are the target screen size. The unit
can be either 0 or 1, meaning respectively in pixels or millimeters. The constants GestureBuilder.Pixel
and GestureBuilder.MilliMeter
can be used as well.
The second constructor function constructs a GestureBuilder object by passing a string containing XML, which should be in the same format as the recorded gesture files.
Object GestureBuilder.addStroke(x, y)
Object GestureBuilder.addStroke(startTime, x, y)
Object GestureBuilder.addStroke(startTime, x, y, pressure)
Object GestureBuilder.addStroke(startTime, x, y, pressure, size)
Starts a new stroke. The whole movement of one finger or pen from touch down to releasing the screen is called a stroke. The touch down coordinate is (x
, y
). For the non-first stroke, a time offset can be specified in milliseconds using the startTime
argument. Strokes cannot be disjointed in time, at least one finger or pen has to be down during the whole gesture. The maximum simultaneous touches is device dependent (See QTouchDevice::maximumTouchPoints()
).
Finally, the pressure
and size
are relative measure values for respectively pen or finger pressure and size. These should be between 0.0 and 1.0 and when omitted defaults to 0.25.
Object GestureBuilder.curveTo(duration, controlX, controlY, endX, endy)
Object GestureBuilder.curveTo(duration, control1X, control1Y, control2X, control2Y, endX, endy)
Adds a bézier curve movement to the latest added stroke in duration
milliseconds. The curve starts with the end coordinate of the last added movement or, if none added to the stroke, the stroke touch down coordinate. The end coordinate is specified with endX
and endY
. One or two so called control points can be used.
Object GestureBuilder.lineTo(duration, endX, endy)
Adds a line movement to the latest added stroke in duration
milliseconds. The line starts with the end coordinate of the last added movement or, if none added to the stroke, the stroke touch down coordinate. The end coordinate is specified with endX
and endY
.
Object GestureBuilder.build()
Creates the gesture from the added strokes and movements. After calling this method, no strokes or movements can be added.
Gesture manipulation
Object GestureBuilder.accelerate(factor)
Changes stroke speed given a factor. A factor between 0.0 and 1.0 slows down the gesture, above 1.0 will speed it up.
Object GestureBuilder.rotate(degrees)
Object GestureBuilder.rotate(degrees, originX, originY)
Rotates the strokes. The degrees
is the agle in degrees in a counter clockwise direction. The originX
and originY
define the origin of the rotate operation. If omitted, the area center is taken as origin.
Object GestureBuilder.scale(scale)
Object GestureBuilder.scale(scaleX, scaleY)
Object GestureBuilder.scale(scaleX, scaleY, originX, originY)
Changes the size of the strokes. The scaleX
is the scale factor in the horizontal direction and scaleY
in the vertical direction. The originX
and originY
define the origin of the scale operation. If omitted, the area center is taken as origin. When also scaleY
is omitted, then the scaling is homogeneous in both directions.
Object GestureBuilder.translate(x, y)
Moves the strokes. The x
and y
specifies the movement. A positive value for x
moves the strokes to the right and a positive value for y
moves the strokes downwards.
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.