1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtQuick module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef DESIGNERSUPPORT_H 41 #define DESIGNERSUPPORT_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists purely as an 48 // implementation detail. This header file may change from version to 49 // version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 54 #include <QtQuick/qtquickglobal.h> 55 #include <QtCore/QtGlobal> 56 #include <QtCore/QHash> 57 #include <QtCore/QRectF> 58 59 QT_BEGIN_NAMESPACE 60 61 class QQuickItem; 62 class QSGLayer; 63 class QImage; 64 class QTransform; 65 class QQmlContext; 66 class QQuickView; 67 class QObject; 68 class QQuickWindow; 69 70 class Q_QUICK_EXPORT QQuickDesignerSupport 71 { 72 public: 73 typedef QByteArray PropertyName; 74 typedef QList<PropertyName> PropertyNameList; 75 typedef QByteArray TypeName; 76 77 enum DirtyType { 78 TransformOrigin = 0x00000001, 79 Transform = 0x00000002, 80 BasicTransform = 0x00000004, 81 Position = 0x00000008, 82 Size = 0x00000010, 83 84 ZValue = 0x00000020, 85 Content = 0x00000040, 86 Smooth = 0x00000080, 87 OpacityValue = 0x00000100, 88 ChildrenChanged = 0x00000200, 89 ChildrenStackingChanged = 0x00000400, 90 ParentChanged = 0x00000800, 91 92 Clip = 0x00001000, 93 Window = 0x00002000, 94 95 EffectReference = 0x00008000, 96 Visible = 0x00010000, 97 HideReference = 0x00020000, 98 99 TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position | Size | Window, 100 ComplexTransformUpdateMask = Transform | Window, 101 ContentUpdateMask = Size | Content | Smooth | Window, 102 ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Window, 103 AllMask = TransformUpdateMask | ContentUpdateMask | ChildrenUpdateMask 104 }; 105 106 107 QQuickDesignerSupport(); 108 ~QQuickDesignerSupport(); 109 110 void refFromEffectItem(QQuickItem *referencedItem, bool hide = true); 111 void derefFromEffectItem(QQuickItem *referencedItem, bool unhide = true); 112 113 QImage renderImageForItem(QQuickItem *referencedItem, const QRectF &boundingRect, const QSize &imageSize); 114 115 static bool isDirty(QQuickItem *referencedItem, DirtyType dirtyType); 116 static void addDirty(QQuickItem *referencedItem, DirtyType dirtyType); 117 static void resetDirty(QQuickItem *referencedItem); 118 119 static QTransform windowTransform(QQuickItem *referencedItem); 120 static QTransform parentTransform(QQuickItem *referencedItem); 121 122 static bool isAnchoredTo(QQuickItem *fromItem, QQuickItem *toItem); 123 static bool areChildrenAnchoredTo(QQuickItem *fromItem, QQuickItem *toItem); 124 static bool hasAnchor(QQuickItem *item, const QString &name); 125 static QQuickItem *anchorFillTargetItem(QQuickItem *item); 126 static QQuickItem *anchorCenterInTargetItem(QQuickItem *item); 127 static QPair<QString, QObject*> anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context); 128 static void resetAnchor(QQuickItem *item, const QString &name); 129 static void emitComponentCompleteSignalForAttachedProperty(QObject *item); 130 131 static QList<QObject*> statesForItem(QQuickItem *item); 132 133 static bool isComponentComplete(QQuickItem *item); 134 135 static int borderWidth(QQuickItem *item); 136 137 static void refreshExpressions(QQmlContext *context); 138 139 static void setRootItem(QQuickView *view, QQuickItem *item); 140 141 static bool isValidWidth(QQuickItem *item); 142 static bool isValidHeight(QQuickItem *item); 143 144 static void updateDirtyNode(QQuickItem *item); 145 146 static void activateDesignerWindowManager(); 147 static void activateDesignerMode(); 148 149 static void disableComponentComplete(); 150 static void enableComponentComplete(); 151 152 static void createOpenGLContext(QQuickWindow *window); 153 154 static void polishItems(QQuickWindow *window); 155 156 private: 157 QHash<QQuickItem*, QSGLayer*> m_itemTextureHash; 158 }; 159 160 class Q_QUICK_EXPORT ComponentCompleteDisabler 161 { 162 public: 163 ComponentCompleteDisabler(); 164 165 ~ComponentCompleteDisabler(); 166 }; 167 168 typedef QQuickDesignerSupport DesignerSupport; 169 170 QT_END_NAMESPACE 171 172 #endif // DESIGNERSUPPORT_H 173