1// Copyright (C) 2021 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 DESIGNERSUPPORT_H
5#define DESIGNERSUPPORT_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 <QtQuick/qtquickglobal.h>
19#include <QtCore/QtGlobal>
20#include <QtCore/QHash>
21#include <QtCore/QRectF>
22#include <QtCore/private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQuickItem;
27class QSGLayer;
28class QImage;
29class QTransform;
30class QQmlContext;
31class QQuickView;
32class QObject;
33class QQuickWindow;
34
35class Q_QUICK_EXPORT QQuickDesignerSupport
36{
37public:
38 typedef QByteArray PropertyName;
39 typedef QList<PropertyName> PropertyNameList;
40 typedef QByteArray TypeName;
41
42 enum DirtyType {
43 TransformOrigin = 0x00000001,
44 Transform = 0x00000002,
45 BasicTransform = 0x00000004,
46 Position = 0x00000008,
47 Size = 0x00000010,
48
49 ZValue = 0x00000020,
50 Content = 0x00000040,
51 Smooth = 0x00000080,
52 OpacityValue = 0x00000100,
53 ChildrenChanged = 0x00000200,
54 ChildrenStackingChanged = 0x00000400,
55 ParentChanged = 0x00000800,
56
57 Clip = 0x00001000,
58 Window = 0x00002000,
59
60 EffectReference = 0x00008000,
61 Visible = 0x00010000,
62 HideReference = 0x00020000,
63
64 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position | Size | Window,
65 ComplexTransformUpdateMask = Transform | Window,
66 ContentUpdateMask = Size | Content | Smooth | Window,
67 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Window,
68 AllMask = TransformUpdateMask | ContentUpdateMask | ChildrenUpdateMask
69 };
70
71
72 QQuickDesignerSupport();
73 ~QQuickDesignerSupport();
74
75 void refFromEffectItem(QQuickItem *referencedItem, bool hide = true);
76 void derefFromEffectItem(QQuickItem *referencedItem, bool unhide = true);
77
78 QImage renderImageForItem(QQuickItem *referencedItem, const QRectF &boundingRect, const QSize &imageSize);
79
80 static bool isDirty(QQuickItem *referencedItem, DirtyType dirtyType);
81 static void addDirty(QQuickItem *referencedItem, DirtyType dirtyType);
82 static void resetDirty(QQuickItem *referencedItem);
83
84 static QTransform windowTransform(QQuickItem *referencedItem);
85 static QTransform parentTransform(QQuickItem *referencedItem);
86
87 static bool isAnchoredTo(QQuickItem *fromItem, QQuickItem *toItem);
88 static bool areChildrenAnchoredTo(QQuickItem *fromItem, QQuickItem *toItem);
89 static bool hasAnchor(QQuickItem *item, const QString &name);
90 static QQuickItem *anchorFillTargetItem(QQuickItem *item);
91 static QQuickItem *anchorCenterInTargetItem(QQuickItem *item);
92 static QPair<QString, QObject*> anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context);
93 static void resetAnchor(QQuickItem *item, const QString &name);
94 static void emitComponentCompleteSignalForAttachedProperty(QObject *item);
95
96 static QList<QObject*> statesForItem(QQuickItem *item);
97
98 static bool isComponentComplete(QQuickItem *item);
99
100 static int borderWidth(QQuickItem *item);
101
102 static void refreshExpressions(QQmlContext *context);
103
104 static void setRootItem(QQuickView *view, QQuickItem *item);
105
106 static bool isValidWidth(QQuickItem *item);
107 static bool isValidHeight(QQuickItem *item);
108
109 static void updateDirtyNode(QQuickItem *item);
110
111 static void activateDesignerMode();
112
113 static void disableComponentComplete();
114 static void enableComponentComplete();
115
116 static void polishItems(QQuickWindow *window);
117
118private:
119 QHash<QQuickItem*, QSGLayer*> m_itemTextureHash;
120};
121
122class Q_QUICK_EXPORT ComponentCompleteDisabler
123{
124public:
125 ComponentCompleteDisabler();
126
127 ~ComponentCompleteDisabler();
128};
129
130typedef QQuickDesignerSupport DesignerSupport;
131
132QT_END_NAMESPACE
133
134#endif // DESIGNERSUPPORT_H
135

source code of qtdeclarative/src/quick/designer/qquickdesignersupport_p.h