6#include <QtCore/qcoreapplication.h>
7#include <QtCore/private/qnumeric_p.h>
8#include <QtCore/qstack.h>
9#include <QtCore/qmath.h>
10#include <QtQml/qqmlinfo.h>
69 m_preferredHeight(-1),
70 m_maximumWidth(
std::numeric_limits<
qreal>::infinity()),
71 m_maximumHeight(
std::numeric_limits<
qreal>::infinity()),
81 m_isFillWidthSet(
false),
82 m_isFillHeightSet(
false),
83 m_isMinimumWidthSet(
false),
84 m_isMinimumHeightSet(
false),
85 m_isMaximumWidthSet(
false),
86 m_isMaximumHeightSet(
false),
87 m_changesNotificationEnabled(true),
88 m_isMarginsSet(
false),
89 m_isLeftMarginSet(
false),
90 m_isTopMarginSet(
false),
91 m_isRightMarginSet(
false),
92 m_isBottomMarginSet(
false),
93 m_isAlignmentSet(
false),
94 m_horizontalStretch(-1),
120 m_isMinimumWidthSet =
width >= 0;
121 if (m_minimumWidth ==
width)
124 m_minimumWidth =
width;
148 m_isMinimumHeightSet =
height >= 0;
149 if (m_minimumHeight ==
height)
173 m_preferredWidth =
width;
194 m_preferredHeight =
height;
218 m_isMaximumWidthSet =
width >= 0;
219 if (m_maximumWidth ==
width)
222 m_maximumWidth =
width;
245 m_isMaximumHeightSet =
height >= 0;
246 if (m_maximumHeight ==
height)
256 bool emitWidthChanged =
false;
257 bool emitHeightChanged =
false;
258 if (!m_isMinimumWidthSet && m_minimumWidth != sz.
width()) {
259 m_minimumWidth = sz.
width();
260 emitWidthChanged =
true;
262 if (!m_isMinimumHeightSet && m_minimumHeight != sz.
height()) {
263 m_minimumHeight = sz.
height();
264 emitHeightChanged =
true;
268 if (emitWidthChanged || emitHeightChanged) {
270 if (emitWidthChanged)
272 if (emitHeightChanged)
279 bool emitWidthChanged =
false;
280 bool emitHeightChanged =
false;
281 if (!m_isMaximumWidthSet && m_maximumWidth != sz.
width()) {
282 m_maximumWidth = sz.
width();
283 emitWidthChanged =
true;
285 if (!m_isMaximumHeightSet && m_maximumHeight != sz.
height()) {
286 m_maximumHeight = sz.
height();
287 emitHeightChanged =
true;
291 if (emitWidthChanged || emitHeightChanged) {
293 if (emitWidthChanged)
295 if (emitHeightChanged)
312 m_isFillWidthSet =
true;
313 if (m_fillWidth !=
fill) {
332 m_isFillHeightSet =
true;
333 if (m_fillHeight !=
fill) {
354 if (
row >= 0 &&
row != m_row) {
408 m_isAlignmentSet =
true;
409 if (align != m_alignment) {
446 if (factor != m_horizontalStretch) {
447 m_horizontalStretch = factor;
483 if (factor != m_verticalStretch) {
484 m_verticalStretch = factor;
524 m_isMarginsSet =
true;
525 if (
m == m_defaultMargins)
528 m_defaultMargins =
m;
530 if (!m_isLeftMarginSet && m_margins.
left() !=
m)
532 if (!m_isTopMarginSet && m_margins.
top() !=
m)
534 if (!m_isRightMarginSet && m_margins.
right() !=
m)
536 if (!m_isBottomMarginSet && m_margins.
bottom() !=
m)
555 m_isLeftMarginSet =
true;
564 const bool changed = m_isLeftMarginSet && (m_defaultMargins != m_margins.
left());
565 m_isLeftMarginSet =
false;
586 m_isTopMarginSet =
true;
595 const bool changed = m_isTopMarginSet && (m_defaultMargins != m_margins.
top());
596 m_isTopMarginSet =
false;
617 m_isRightMarginSet =
true;
626 const bool changed = m_isRightMarginSet && (m_defaultMargins != m_margins.
right());
627 m_isRightMarginSet =
false;
648 m_isBottomMarginSet =
true;
657 const bool changed = m_isBottomMarginSet && (m_defaultMargins != m_margins.
bottom());
658 m_isBottomMarginSet =
false;
678 if (
span != m_rowSpan) {
698 if (
span != m_columnSpan) {
714 result = std::numeric_limits<qreal>::infinity();
719void QQuickLayoutAttached::invalidateItem()
721 qCDebug(lcQuickLayouts) <<
"QQuickLayoutAttached::invalidateItem";
732 return qobject_cast<QQuickLayout *>(parentItem);
754 info->setMinimumImplicitSize(min);
755 info->setMaximumImplicitSize(max);
761 , m_inUpdatePolish(
false)
762 , m_polishInsideUpdatePolish(0)
775 d_func()->m_isReady =
false;
789 qCDebug(lcQuickLayouts) <<
"updatePolish() ENTERING" <<
this;
790 m_inUpdatePolish =
true;
800 m_inUpdatePolish =
false;
801 qCDebug(lcQuickLayouts) <<
"updatePolish() LEAVING" <<
this;
807 d->m_disableRearrange =
true;
809 d->m_disableRearrange =
false;
831 qCDebug(lcQuickLayouts) <<
"QQuickLayout::invalidate()" <<
this;
833 d->m_dirtyArrangement =
true;
835 if (!qobject_cast<QQuickLayout *>(
parentItem())) {
837 if (m_inUpdatePolish)
838 ++m_polishInsideUpdatePolish;
840 m_polishInsideUpdatePolish = 0;
842 if (m_polishInsideUpdatePolish <= 2) {
845 qCDebug(lcQuickLayouts) <<
"QQuickLayout::invalidate(), polish()";
848 qmlWarning(
this).nospace() <<
"Layout polish loop detected for " <<
this
849 <<
". Aborting after two iterations.";
867 qmlWarning(
item) <<
"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead.";
875 qCDebug(lcQuickLayouts) <<
"ENTER QQuickLayout::ensureLayoutItemsUpdated()" <<
this << options;
889 if (
QQuickLayout *lay = qobject_cast<QQuickLayout*>(itm)) {
890 lay->ensureLayoutItemsUpdated(options);
897 priv->applySizeHints();
898 qCDebug(lcQuickLayouts) <<
"LEAVE QQuickLayout::ensureLayoutItemsUpdated()" <<
this;
909 d->m_hasItemChangeListeners =
true;
928 if (
d->m_disableRearrange || !
isReady())
931 qCDebug(lcQuickLayouts) <<
"QQuickLayout::geometryChange" << newGeometry << oldGeometry;
946 return d_func()->m_isReady;
959 if (d_func()->m_hasItemChangeListeners) {
968 layout->deactivateRecur();
970 d_func()->m_hasItemChangeListeners =
false;
976 return d_func()->m_dirty;
981 return d_func()->m_dirtyArrangement;
986 return d_func()->isMirrored();
1021 d_func()->m_dirtyArrangement =
false;
1041 if (minimum >= 0 && maximum >= 0 && minimum > maximum)
1044 if (preferred >= 0) {
1045 if (minimum >= 0 && preferred < minimum) {
1046 preferred = minimum;
1047 }
else if (maximum >= 0 && preferred > maximum) {
1048 preferred = maximum;
1052 if (minimum >= 0 && descent > minimum)
1075 current = fallbackHint;
1137 cachedSizeHints[
i] =
QSizeF();
1145 static Getters horGetters = {
1149 static Getters verGetters = {
1159 getter = verGetters.call[
i];
1181 combineSize(maxS,
QSizeF(std::numeric_limits<qreal>::infinity(), std::numeric_limits<qreal>::infinity()));
1197 prefWidth =
qCeil(
item->implicitWidth());
1199 prefHeight =
qCeil(
item->implicitHeight());
1202 if (useFallbackToWidthOrHeight && !prefS.
isValid()) {
1218 if (cachedSize < 0) {
1219 if (attachedSize < 0)
1220 attachedSize =
size;
1222 cachedSize = attachedSize;
1225 updatePreferredSizes(prefWidth,
info->m_fallbackWidth,
item->width());
1226 updatePreferredSizes(prefHeight,
info->m_fallbackHeight,
item->height());
1242 minS += extraMargins;
1243 prefS += extraMargins;
1244 maxS += extraMargins;
1245 descentS += extraMargins;
1248 *attachedInfo =
info;
1258 bool fillExtent =
false;
1262 isSet =
info->isFillWidthSet();
1263 if (isSet) fillExtent =
info->fillWidth();
1265 isSet =
info->isFillHeightSet();
1266 if (isSet) fillExtent =
info->fillHeight();
1269 if (!isSet && qobject_cast<QQuickLayout*>(
item))
1292 auto b2s = [](
bool b) {
1293 static const char *strBool[] = {
"false",
"true"};
1299 buf += formatLine(
"// Effective calculated values:");
1302 buf += formatLine(
"sizeHint.min : [%1, %2]").arg(f2s(min.width()), 5).arg(min.height(), 5);
1304 buf += formatLine(
"sizeHint.pref: [%1, %2]").arg(pref.
width(), 5).arg(pref.
height(), 5);
1306 buf += formatLine(
"sizeHint.max : [%1, %2]").arg(f2s(max.
width()), 5).arg(f2s(max.
height()), 5);
1311 childLayout->dumpLayoutTreeRecursive(
level,
buf);
1315 if (
item->implicitWidth() > 0)
1316 buf += formatLine(
"implicitWidth: %1").arg(f2s(
item->implicitWidth()));
1317 if (
item->implicitHeight() > 0)
1318 buf += formatLine(
"implicitHeight: %1").arg(f2s(
item->implicitHeight()));
1328 buf += formatLine(
"Layout.minimumWidth: %1").arg(f2s(min.width()));
1330 buf += formatLine(
"Layout.minimumHeight: %1").arg(f2s(min.height()));
1331 if (pref.
width() >= 0)
1332 buf += formatLine(
"Layout.preferredWidth: %1").arg(f2s(pref.
width()));
1334 buf += formatLine(
"Layout.preferredHeight: %1").arg(f2s(pref.
height()));
1336 buf += formatLine(
"Layout.maximumWidth: %1").arg(f2s(max.
width()));
1338 buf += formatLine(
"Layout.maximumHeight: %1").arg(f2s(max.
height()));
1340 if (
info->isFillWidthSet())
1341 buf += formatLine(
"Layout.fillWidth: %1").arg(b2s(
info->fillWidth()));
1342 if (
info->isFillHeightSet())
1343 buf += formatLine(
"Layout.fillHeight: %1").arg(b2s(
info->fillHeight()));
1346 buf += formatLine(
"}");
1350 buf += formatLine(
"}");
1355#include "moc_qquicklayout_p.cpp"
void invalidate() override
Resets cached information.
QSize sizeHint() const override
\reimp
bool setStretchFactor(QWidget *w, int stretch)
Sets the stretch factor for widget to stretch and returns true if widget is found in this layout (not...
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
static constexpr Policy Preferred
static constexpr Policy Fixed
bool setAlignment(QWidget *w, Qt::Alignment alignment)
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not inclu...
constexpr qreal right() const noexcept
Returns the right margin.
constexpr qreal left() const noexcept
Returns the left margin.
constexpr qreal top() const noexcept
Returns the top margin.
constexpr void setLeft(qreal aleft) noexcept
Sets the left margin to aleft (which must be finite).
constexpr void setRight(qreal aright) noexcept
Sets the right margin to aright (which must be finite).
constexpr void setBottom(qreal abottom) noexcept
Sets the bottom margin to abottom (which must be finite).
constexpr void setTop(qreal atop) noexcept
Sets the top margin to atop (which must be finite).
constexpr qreal bottom() const noexcept
Returns the bottom margin.
QObject * parent() const
Returns a pointer to the parent object.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Qt::Orientations activeDirections() const
void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types)
void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
static QQuickItemPrivate * get(QQuickItem *item)
bool isTransparentForPositioner() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void baselineOffsetChanged(qreal)
QList< QQuickItem * > childItems() const
Returns the children of this item.
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
qreal width
This property holds the width of this item.
QQuickItem * parentItem() const
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
qreal height
This property holds the height of this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
void polish()
Schedules a polish event for this item.
void setImplicitSize(qreal, qreal)
void bottomMarginChanged()
void setMaximumWidth(qreal width)
\qmlattachedproperty real Layout::maximumWidth
void setBottomMargin(qreal m)
\qmlattachedproperty real Layout::bottomMargin
void setMaximumImplicitSize(const QSizeF &sz)
void setMinimumImplicitSize(const QSizeF &sz)
void preferredWidthChanged()
void setMinimumHeight(qreal height)
\qmlattachedproperty real Layout::minimumHeight
void setFillWidth(bool fill)
\qmlattachedproperty bool Layout::fillWidth
void setColumnSpan(int span)
\qmlattachedproperty int Layout::columnSpan
void setFillHeight(bool fill)
\qmlattachedproperty bool Layout::fillHeight
void setRow(int row)
\qmlattachedproperty int Layout::row
void setLeftMargin(qreal m)
\qmlattachedproperty real Layout::leftMargin
void setMaximumHeight(qreal height)
\qmlattachedproperty real Layout::maximumHeight
void setMinimumWidth(qreal width)
\qmlattachedproperty real Layout::minimumWidth
void setRowSpan(int span)
\qmlattachedproperty int Layout::rowSpan
void setMargins(qreal m)
\qmlattachedproperty real Layout::margins
void minimumWidthChanged()
void preferredHeightChanged()
void setVerticalStretchFactor(int stretchFactor)
\qmlattachedproperty int Layout::verticalStretchFactor
void setPreferredHeight(qreal width)
\qmlattachedproperty real Layout::preferredHeight
void maximumWidthChanged()
void rightMarginChanged()
void maximumHeightChanged()
void setAlignment(Qt::Alignment align)
\qmlattachedproperty Qt.Alignment Layout::alignment
qreal sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const
void setPreferredWidth(qreal width)
\qmlattachedproperty real Layout::preferredWidth
void minimumHeightChanged()
void setColumn(int column)
\qmlattachedproperty int Layout::column
void horizontalStretchFactorChanged()
void setTopMargin(qreal m)
\qmlattachedproperty real Layout::topMargin
void setHorizontalStretchFactor(int stretchFactor)
\qmlattachedproperty int Layout::horizontalStretchFactor
void setRightMargin(qreal m)
\qmlattachedproperty real Layout::rightMargin
void verticalStretchFactorChanged()
void applySizeHints() const
bool invalidatedArrangement() const
static QLayoutPolicy::Policy effectiveSizePolicy_helper(QQuickItem *item, Qt::Orientation orientation, QQuickLayoutAttached *info)
Q_INVOKABLE void _q_dumpLayoutTree() const
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void itemSiblingOrderChanged(QQuickItem *item) override
void itemImplicitHeightChanged(QQuickItem *item) override
void itemDestroyed(QQuickItem *item) override
void maybeSubscribeToBaseLineOffsetChanges(QQuickItem *item)
static void effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSizeHints, QQuickLayoutAttached **info, bool useFallbackToWidthOrHeight)
friend class QQuickLayoutAttached
void updatePolish() override
This function should perform any layout as required for this item.
virtual void rearrange(const QSizeF &)
QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent=nullptr)
void itemVisibilityChanged(QQuickItem *item) override
virtual void invalidate(QQuickItem *childItem=nullptr)
void dumpLayoutTreeRecursive(int level, QString &buf) const
static QQuickLayoutAttached * qmlAttachedProperties(QObject *object)
bool shouldIgnoreItem(QQuickItem *child) const
virtual void updateLayoutItems()=0
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
virtual QQuickItem * itemAt(int index) const =0
void checkAnchors(QQuickItem *item) const
void ensureLayoutItemsUpdated(EnsureLayoutItemsUpdatedOptions options={}) const
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void invalidateSenderItem()
void itemImplicitWidthChanged(QQuickItem *item) override
virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const =0
virtual int itemCount() const =0
void deactivateRecur()
QQuickLayout::deactivateRecur.
\inmodule QtCore\reentrant
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr qreal & rwidth() noexcept
Returns a reference to the width.
constexpr bool isValid() const noexcept
Returns true if both the width and height are equal to or greater than 0; otherwise returns false.
constexpr void setHeight(qreal h) noexcept
Sets the height to the given finite height.
constexpr qreal & rheight() noexcept
Returns a reference to the height.
constexpr void setWidth(qreal w) noexcept
Sets the width to the given finite width.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qreal &descent)
static void boundSize(QSizeF &result, const QSizeF &size)
static void combineSize(QSizeF &result, const QSizeF &size)
static void expandSize(QSizeF &result, const QSizeF &size)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
static Q_DECL_CONST_FUNCTION bool qt_is_nan(double d)
GLboolean GLboolean GLboolean b
GLenum GLuint GLint level
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
#define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Disconnect Signal of Sender from Method of Receiver.
#define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Connect Signal of Sender to Method of Receiver.
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickAnchors * anchors(QQuickItem *item)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
static void combineHints(qreal ¤t, qreal fallbackHint)
static void combineImplicitHints(QQuickLayoutAttached *info, Qt::SizeHint which, QSizeF *size)
qreal(QQuickLayoutAttached::* SizeGetter)() const
static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qreal &descent)
static QQuickItemPrivate::ChangeTypes changeTypes
static void boundSize(QSizeF &result, const QSizeF &size)
static void combineSize(QSizeF &result, const QSizeF &fallbackSize)
static void expandSize(QSizeF &result, const QSizeF &size)
QQuickLayoutAttached * attachedLayoutObject(QQuickItem *item, bool create=true)
#define qPrintable(string)
QLatin1StringView QLatin1String
QVideoFrameFormat::PixelFormat fmt
QFileInfo info(fileName)
[8]
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent