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 <private/qquicktext_p.h>
24#include <private/qquicktranslate_p.h>
25#include <private/qquickimage_p.h>
26
27QT_BEGIN_NAMESPACE
28
29struct NodeInfo
30{
31 QString nodeId;
32 QString typeName;
33 QTransform transform;
34 qreal opacity;
35 bool isDefaultTransform;
36 bool isDefaultOpacity;
37 bool isVisible;
38 bool isDisplayed; // TODO: Map to display enum in QtSvg
39};
40
41struct ImageNodeInfo : NodeInfo
42{
43 QImage image;
44 QRectF rect;
45 QString externalFileReference;
46};
47
48struct StrokeStyle
49{
50 Qt::PenCapStyle lineCapStyle = Qt::SquareCap;
51 Qt::PenJoinStyle lineJoinStyle = Qt::MiterJoin;
52 qreal miterLimit = 4;
53 qreal dashOffset = 0;
54 QList<qreal> dashArray;
55 QColor color = QColorConstants::Transparent;
56 qreal width = 1.0;
57
58 static StrokeStyle fromPen(const QPen &p)
59 {
60 StrokeStyle style;
61 style.lineCapStyle = p.capStyle();
62 style.lineJoinStyle = p.joinStyle() == Qt::SvgMiterJoin ? Qt::MiterJoin : p.joinStyle(); //TODO support SvgMiterJoin
63 style.miterLimit = p.miterLimit();
64 style.dashOffset = p.dashOffset();
65 style.dashArray = p.dashPattern();
66 style.width = p.widthF();
67
68 return style;
69 }
70};
71
72struct PathNodeInfo : NodeInfo
73{
74 QPainterPath painterPath;
75 Qt::FillRule fillRule = Qt::FillRule::WindingFill;
76 QColor fillColor;
77 StrokeStyle strokeStyle;
78 QGradient grad;
79 QTransform fillTransform;
80};
81
82struct TextNodeInfo : NodeInfo
83{
84 bool isTextArea;
85 bool needsRichText;
86 QPointF position;
87 QSizeF size;
88 QString text;
89 QFont font;
90 Qt::Alignment alignment;
91 QColor fillColor;
92 QColor strokeColor;
93};
94
95enum class StructureNodeStage
96{
97 Start,
98 End
99};
100
101struct UseNodeInfo : NodeInfo
102{
103 QPointF startPos;
104 StructureNodeStage stage;
105};
106
107struct StructureNodeInfo : NodeInfo
108{
109 StructureNodeStage stage;
110 bool forceSeparatePaths;
111 QRectF viewBox;
112 QSize size;
113 bool isPathContainer;
114};
115
116
117QT_END_NAMESPACE
118
119#endif //QQUICKNODEINFO_P_H
120

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