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 QQUICKPOSITIONERS_P_P_H |
41 | #define QQUICKPOSITIONERS_P_P_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/private/qtquickglobal_p.h> |
55 | |
56 | QT_REQUIRE_CONFIG(quick_positioners); |
57 | |
58 | #include "qquickpositioners_p.h" |
59 | #include "qquickimplicitsizeitem_p_p.h" |
60 | |
61 | #include <private/qlazilyallocated_p.h> |
62 | |
63 | #include <QtCore/qobject.h> |
64 | #include <QtCore/qstring.h> |
65 | #include <QtCore/qtimer.h> |
66 | |
67 | QT_BEGIN_NAMESPACE |
68 | |
69 | class QQuickItemViewTransitioner; |
70 | |
71 | class QQuickBasePositionerPrivate : public QQuickImplicitSizeItemPrivate, public QQuickItemChangeListener |
72 | { |
73 | Q_DECLARE_PUBLIC(QQuickBasePositioner) |
74 | |
75 | public: |
76 | struct { |
77 | (); |
78 | |
79 | qreal ; |
80 | qreal ; |
81 | qreal ; |
82 | qreal ; |
83 | qreal ; |
84 | bool : 1; |
85 | bool : 1; |
86 | bool : 1; |
87 | bool : 1; |
88 | }; |
89 | QLazilyAllocated<ExtraData> ; |
90 | |
91 | QQuickBasePositionerPrivate() |
92 | : spacing(0), type(QQuickBasePositioner::None) |
93 | , transitioner(0), positioningDirty(false) |
94 | , doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight) |
95 | |
96 | { |
97 | } |
98 | |
99 | void init(QQuickBasePositioner::PositionerType at) |
100 | { |
101 | type = at; |
102 | } |
103 | |
104 | qreal spacing; |
105 | |
106 | QQuickBasePositioner::PositionerType type; |
107 | QQuickItemViewTransitioner *transitioner; |
108 | |
109 | void watchChanges(QQuickItem *other); |
110 | void unwatchChanges(QQuickItem* other); |
111 | void setPositioningDirty() { |
112 | Q_Q(QQuickBasePositioner); |
113 | if (!positioningDirty) { |
114 | positioningDirty = true; |
115 | q->polish(); |
116 | } |
117 | } |
118 | |
119 | bool positioningDirty : 1; |
120 | bool doingPositioning : 1; |
121 | bool anchorConflict : 1; |
122 | |
123 | Qt::LayoutDirection layoutDirection; |
124 | |
125 | void mirrorChange() override { |
126 | effectiveLayoutDirectionChange(); |
127 | } |
128 | bool isLeftToRight() const { |
129 | if (type == QQuickBasePositioner::Vertical) |
130 | return true; |
131 | else |
132 | return effectiveLayoutMirror ? layoutDirection == Qt::RightToLeft : layoutDirection == Qt::LeftToRight; |
133 | } |
134 | |
135 | void itemSiblingOrderChanged(QQuickItem* other) override |
136 | { |
137 | Q_UNUSED(other); |
138 | setPositioningDirty(); |
139 | } |
140 | |
141 | void itemGeometryChanged(QQuickItem *, QQuickGeometryChange change, const QRectF &) override |
142 | { |
143 | if (change.sizeChange()) |
144 | setPositioningDirty(); |
145 | } |
146 | |
147 | void itemVisibilityChanged(QQuickItem *) override |
148 | { |
149 | setPositioningDirty(); |
150 | } |
151 | |
152 | void itemDestroyed(QQuickItem *item) override |
153 | { |
154 | Q_Q(QQuickBasePositioner); |
155 | int index = q->positionedItems.find(v: QQuickBasePositioner::PositionedItem(item)); |
156 | if (index >= 0) |
157 | q->removePositionedItem(items: &q->positionedItems, index); |
158 | } |
159 | |
160 | static Qt::LayoutDirection getLayoutDirection(const QQuickBasePositioner *positioner) |
161 | { |
162 | return positioner->d_func()->layoutDirection; |
163 | } |
164 | |
165 | static Qt::LayoutDirection getEffectiveLayoutDirection(const QQuickBasePositioner *positioner) |
166 | { |
167 | if (positioner->d_func()->effectiveLayoutMirror) |
168 | return positioner->d_func()->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; |
169 | else |
170 | return positioner->d_func()->layoutDirection; |
171 | } |
172 | |
173 | virtual void effectiveLayoutDirectionChange() |
174 | { |
175 | } |
176 | |
177 | inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; } |
178 | void setTopPadding(qreal value, bool reset = false); |
179 | void setLeftPadding(qreal value, bool reset = false); |
180 | void setRightPadding(qreal value, bool reset = false); |
181 | void setBottomPadding(qreal value, bool reset = false); |
182 | }; |
183 | |
184 | QT_END_NAMESPACE |
185 | |
186 | #endif // QQUICKPOSITIONERS_P_P_H |
187 | |