19#include <private/qtquickglobal_p.h>
26#include <QtCore/QStringList>
28#include <private/qobject_p.h>
34 Q_DECLARE_PUBLIC(QQuickPath)
37 static QQuickPathPrivate* get(QQuickPath *path) {
return path->d_func(); }
38 static const QQuickPathPrivate* get(
const QQuickPath *path) {
return path->d_func(); }
41 : componentComplete(
true), isShapePath(
false), simplify(
false)
42 , processPending(
false), asynchronous(
false), useCustomPath(
false)
45 enum class ProcessPathPolicy {
49 void appendPathElement(QQuickPathElement *pathElement,
50 ProcessPathPolicy processPathPolicy = ProcessPathPolicy::Process)
52 if (pathElement && componentComplete) {
53 enablePathElement(pathElement);
54 _pathElements.append(pathElement);
55 if (processPathPolicy == ProcessPathPolicy::Process)
56 q_func()->processPath();
58 _pathElements.append(pathElement);
62 void removeLastPathElement()
64 QQuickPathElement *pathElement = _pathElements.takeLast();
65 if (pathElement && componentComplete) {
66 disablePathElement(pathElement);
67 q_func()->processPath();
71 void replacePathElement(qsizetype position, QQuickPathElement *pathElement)
73 if (position >= _pathElements.length())
74 _pathElements.resize(position + 1,
nullptr);
76 if (!componentComplete) {
77 _pathElements[position] = pathElement;
83 QQuickPathElement *oldElement = _pathElements.at(position);
84 if (oldElement == pathElement)
88 disablePathElement(oldElement);
93 enablePathElement(pathElement);
97 _pathElements[position] = pathElement;
100 q_func()->processPath();
103 enum class DeleteElementPolicy {
107 void clearPathElements(DeleteElementPolicy deleteElementPolicy
108 = QQuickPathPrivate::DeleteElementPolicy::DontDelete)
111 q->disconnectPathElements();
112 if (deleteElementPolicy == DeleteElementPolicy::Delete)
113 qDeleteAll(_pathElements);
114 _pathElements.clear();
123 QList<QQuickPathElement*> _pathElements;
124 mutable QVector<QPointF> _pointCache;
125 QList<QQuickPath::AttributePoint> _attributePoints;
126 QStringList _attributes;
127 QList<QQuickCurve*> _pathCurves;
128 QList<QQuickPathText*> _pathTexts;
129 mutable QQuickCachedBezier prevBez;
130 QQmlNullableValue<qreal> startX;
131 QQmlNullableValue<qreal> startY;
132 qreal pathLength = 0;
133 QSizeF scale = QSizeF(1, 1);
135 bool componentComplete : 1;
136 bool isShapePath : 1;
138 bool processPending : 1;
139 bool asynchronous : 1;
140 bool useCustomPath : 1;
143 void enablePathElement(QQuickPathElement *pathElement);
144 void disablePathElement(QQuickPathElement *pathElement);
QT_REQUIRE_CONFIG(animation)
QDebug operator<<(QDebug debug, const QQuickCurve *curve)
static qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d)
static QQuickPathPrivate * privatePath(QObject *object)
static int segmentCount(const QPainterPath &path, qreal pathLength)
QPointF positionForCurve(const QQuickPathData &data, const QPointF &prevPoint)
\qmltype PathLine \nativetype QQuickPathLine \inqmlmodule QtQuick
QPointF previousPathPosition(const QPainterPath &path)
\qmltype PathCurve \nativetype QQuickPathCatmullRomCurve \inqmlmodule QtQuick
static QBezier nextBezier(const QPainterPath &path, int *current, qreal *bezLength, bool reverse=false)
static void scalePath(QPainterPath &path, const QSizeF &scale)
QT_REQUIRE_CONFIG(quick_path)
QList< QQuickCurve * > curves