Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickpath_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKPATH_P_H
6#define QQUICKPATH_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtquickglobal_p.h>
20
22
23#include "qquickpath_p.h"
24
25#include <qqml.h>
26#include <QtCore/QStringList>
27
28#include <private/qobject_p.h>
29
31
32class Q_QUICK_EXPORT QQuickPathPrivate : public QObjectPrivate
33{
34 Q_DECLARE_PUBLIC(QQuickPath)
35
36public:
37 static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); }
38 static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); }
39
40 QQuickPathPrivate()
41 : componentComplete(true), isShapePath(false), simplify(false)
42 , processPending(false), asynchronous(false), useCustomPath(false)
43 {}
44
45 enum class ProcessPathPolicy {
46 DontProcess,
47 Process
48 };
49 void appendPathElement(QQuickPathElement *pathElement,
50 ProcessPathPolicy processPathPolicy = ProcessPathPolicy::Process)
51 {
52 if (pathElement && componentComplete) {
53 enablePathElement(pathElement);
54 _pathElements.append(pathElement);
55 if (processPathPolicy == ProcessPathPolicy::Process)
56 q_func()->processPath();
57 } else {
58 _pathElements.append(pathElement);
59 }
60 }
61
62 void removeLastPathElement()
63 {
64 QQuickPathElement *pathElement = _pathElements.takeLast();
65 if (pathElement && componentComplete) {
66 disablePathElement(pathElement);
67 q_func()->processPath();
68 }
69 }
70
71 void replacePathElement(qsizetype position, QQuickPathElement *pathElement)
72 {
73 if (position >= _pathElements.length())
74 _pathElements.resize(position + 1, nullptr);
75
76 if (!componentComplete) {
77 _pathElements[position] = pathElement;
78 return;
79 }
80
81 bool changed = false;
82
83 QQuickPathElement *oldElement = _pathElements.at(position);
84 if (oldElement == pathElement)
85 return;
86
87 if (oldElement) {
88 disablePathElement(oldElement);
89 changed = true;
90 }
91
92 if (pathElement) {
93 enablePathElement(pathElement);
94 changed = true;
95 }
96
97 _pathElements[position] = pathElement;
98
99 if (changed)
100 q_func()->processPath();
101 }
102
103 enum class DeleteElementPolicy {
104 DontDelete,
105 Delete
106 };
107 void clearPathElements(DeleteElementPolicy deleteElementPolicy
108 = QQuickPathPrivate::DeleteElementPolicy::DontDelete)
109 {
110 Q_Q(QQuickPath);
111 q->disconnectPathElements();
112 if (deleteElementPolicy == DeleteElementPolicy::Delete)
113 qDeleteAll(_pathElements);
114 _pathElements.clear();
115 _pathCurves.clear();
116 _pointCache.clear();
117 _pathTexts.clear();
118 _path.clear();
119 emit q->changed();
120 }
121
122 QPainterPath _path;
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);
134 bool closed = false;
135 bool componentComplete : 1;
136 bool isShapePath : 1;
137 bool simplify : 1;
138 bool processPending : 1;
139 bool asynchronous : 1;
140 bool useCustomPath : 1;
141
142private:
143 void enablePathElement(QQuickPathElement *pathElement);
144 void disablePathElement(QQuickPathElement *pathElement);
145};
146
147QT_END_NAMESPACE
148
149#endif
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