1// Copyright (C) 2024 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
4#ifndef QQUICKNODEINFO_P_H
5#define QQUICKNODEINFO_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QString>
19#include <QPainter>
20#include <QPainterPath>
21#include <QMatrix4x4>
22#include <QQuickItem>
23#include <QtGui/private/qfixed_p.h>
24
25#include "qquickanimatedproperty_p.h"
26
27QT_BEGIN_NAMESPACE
28
29struct NodeInfo
30{
31 QString nodeId;
32 QString typeName;
33 QQuickAnimatedProperty transform = QQuickAnimatedProperty(QVariant::fromValue(value: QTransform{}));
34 QQuickAnimatedProperty opacity = QQuickAnimatedProperty(QVariant::fromValue(value: 1.0));
35 bool isDefaultTransform = true;
36 bool isDefaultOpacity = true;
37 bool isVisible = true;
38 bool isDisplayed = true; // TODO: Map to display enum in QtSvg
39 QQuickAnimatedProperty visibility = QQuickAnimatedProperty(QVariant::fromValue(value: true));
40 int visibilityEndTime = -1;
41 int layerNum = -1;
42 int transformReferenceLayerNum = -1;
43};
44
45struct ImageNodeInfo : NodeInfo
46{
47 QImage image;
48 QRectF rect;
49 QString externalFileReference;
50};
51
52struct StrokeStyle
53{
54 Qt::PenCapStyle lineCapStyle = Qt::SquareCap;
55 Qt::PenJoinStyle lineJoinStyle = Qt::MiterJoin;
56 int miterLimit = 4;
57 qreal dashOffset = 0;
58 QList<qreal> dashArray;
59 QQuickAnimatedProperty color = QQuickAnimatedProperty(QVariant::fromValue(value: QColorConstants::Transparent));
60 QQuickAnimatedProperty opacity = QQuickAnimatedProperty(QVariant::fromValue(value: qreal(1.0)));
61 qreal width = 1.0;
62
63 static StrokeStyle fromPen(const QPen &p)
64 {
65 StrokeStyle style;
66 style.lineCapStyle = p.capStyle();
67 style.lineJoinStyle = p.joinStyle() == Qt::SvgMiterJoin ? Qt::MiterJoin : p.joinStyle(); //TODO support SvgMiterJoin
68 style.miterLimit = qRound(d: p.miterLimit());
69 style.dashOffset = p.dashOffset();
70 style.dashArray = p.dashPattern();
71 style.width = p.widthF();
72
73 return style;
74 }
75};
76
77struct PathTrimInfo
78{
79 bool enabled = false;
80 QQuickAnimatedProperty start = QQuickAnimatedProperty(QVariant::fromValue(value: 0.0));
81 QQuickAnimatedProperty end = QQuickAnimatedProperty(QVariant::fromValue(value: 1.0));
82 QQuickAnimatedProperty offset = QQuickAnimatedProperty(QVariant::fromValue(value: 0.0));
83};
84
85struct PathNodeInfo : NodeInfo
86{
87 QPainterPath painterPath;
88 Qt::FillRule fillRule = Qt::FillRule::WindingFill;
89 QQuickAnimatedProperty fillColor = QQuickAnimatedProperty(QVariant::fromValue(value: QColor{}));
90 QQuickAnimatedProperty fillOpacity = QQuickAnimatedProperty(QVariant::fromValue(value: qreal(1.0)));
91 StrokeStyle strokeStyle;
92 QGradient grad;
93 QTransform fillTransform;
94 PathTrimInfo trim;
95};
96
97struct TextNodeInfo : NodeInfo
98{
99 bool isTextArea;
100 bool needsRichText;
101 QPointF position;
102 QSizeF size;
103 QString text;
104 QFont font;
105 Qt::Alignment alignment;
106 QQuickAnimatedProperty fillColor = QQuickAnimatedProperty(QVariant::fromValue(value: QColor{}));
107 QQuickAnimatedProperty fillOpacity = QQuickAnimatedProperty(QVariant::fromValue(value: qreal(1.0)));
108 QQuickAnimatedProperty strokeColor = QQuickAnimatedProperty(QVariant::fromValue(value: QColor{}));
109 QQuickAnimatedProperty strokeOpacity = QQuickAnimatedProperty(QVariant::fromValue(value: qreal(1.0)));
110};
111
112struct AnimateColorNodeInfo : NodeInfo
113{
114};
115
116enum class StructureNodeStage
117{
118 Start,
119 End
120};
121
122struct UseNodeInfo : NodeInfo
123{
124 QPointF startPos;
125 StructureNodeStage stage;
126};
127
128struct StructureNodeInfo : NodeInfo
129{
130 StructureNodeStage stage = StructureNodeStage::Start;
131 bool forceSeparatePaths = false;
132 QRectF viewBox;
133 QSize size;
134 bool isPathContainer = false;
135};
136
137
138QT_END_NAMESPACE
139
140#endif //QQUICKNODEINFO_P_H
141

source code of qtdeclarative/src/quickvectorimage/generator/qquicknodeinfo_p.h