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)
313 m_isFillWidthSet =
true;
315 if (oldFillWidth !=
fill) {
334 m_isFillHeightSet =
true;
336 if (oldFillHeight !=
fill) {
356 if (
row >= 0 &&
row != m_row) {
410 m_isAlignmentSet =
true;
411 if (align != m_alignment) {
448 if (factor != m_horizontalStretch) {
449 m_horizontalStretch = factor;
485 if (factor != m_verticalStretch) {
486 m_verticalStretch = factor;
526 m_isMarginsSet =
true;
527 if (
m == m_defaultMargins)
530 m_defaultMargins =
m;
532 if (!m_isLeftMarginSet && m_margins.
left() !=
m)
534 if (!m_isTopMarginSet && m_margins.
top() !=
m)
536 if (!m_isRightMarginSet && m_margins.
right() !=
m)
538 if (!m_isBottomMarginSet && m_margins.
bottom() !=
m)
557 m_isLeftMarginSet =
true;
566 const bool changed = m_isLeftMarginSet && (m_defaultMargins != m_margins.
left());
567 m_isLeftMarginSet =
false;
588 m_isTopMarginSet =
true;
597 const bool changed = m_isTopMarginSet && (m_defaultMargins != m_margins.
top());
598 m_isTopMarginSet =
false;
619 m_isRightMarginSet =
true;
628 const bool changed = m_isRightMarginSet && (m_defaultMargins != m_margins.
right());
629 m_isRightMarginSet =
false;
650 m_isBottomMarginSet =
true;
659 const bool changed = m_isBottomMarginSet && (m_defaultMargins != m_margins.
bottom());
660 m_isBottomMarginSet =
false;
680 if (
span != m_rowSpan) {
700 if (
span != m_columnSpan) {
716 result = std::numeric_limits<qreal>::infinity();
721void QQuickLayoutAttached::invalidateItem()
723 qCDebug(lcQuickLayouts) <<
"QQuickLayoutAttached::invalidateItem";
734 return qobject_cast<QQuickLayout *>(parentItem);
756 info->setMinimumImplicitSize(min);
757 info->setMaximumImplicitSize(max);
758 that->setImplicitSize(pref.
width(), pref.
height());
763 , m_inUpdatePolish(
false)
764 , m_polishInsideUpdatePolish(0)
777 d_func()->m_isReady =
false;
791 qCDebug(lcQuickLayouts) <<
"updatePolish() ENTERING" <<
this;
792 m_inUpdatePolish =
true;
802 m_inUpdatePolish =
false;
803 qCDebug(lcQuickLayouts) <<
"updatePolish() LEAVING" <<
this;
809 d->m_disableRearrange =
true;
811 d->m_disableRearrange =
false;
833 qCDebug(lcQuickLayouts) <<
"QQuickLayout::invalidate()" <<
this;
835 d->m_dirtyArrangement =
true;
837 if (!qobject_cast<QQuickLayout *>(
parentItem())) {
840 if (m_inUpdatePolish) {
841 if (++m_polishInsideUpdatePolish > 2)
844 qCDebug(lcQuickLayouts) <<
"Layout polish loop detected for " <<
this
845 <<
". The polish request will still be scheduled.";
847 m_polishInsideUpdatePolish = 0;
855 bool ignoreItem = !childPrivate->explicitVisible;
856 if (!ignoreItem && childPrivate->isTransparentForPositioner())
865 qmlWarning(
item) <<
"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead.";
873 qCDebug(lcQuickLayouts) <<
"ENTER QQuickLayout::ensureLayoutItemsUpdated()" <<
this << options;
887 if (
QQuickLayout *lay = qobject_cast<QQuickLayout*>(itm)) {
888 lay->ensureLayoutItemsUpdated(options);
895 priv->applySizeHints();
896 qCDebug(lcQuickLayouts) <<
"LEAVE QQuickLayout::ensureLayoutItemsUpdated()" <<
this;
907 d->m_hasItemChangeListeners =
true;
929 qCDebug(lcQuickLayouts) <<
"QQuickLayout::geometryChange" << newGeometry << oldGeometry;
944 return d_func()->m_isReady;
957 if (d_func()->m_hasItemChangeListeners) {
966 layout->deactivateRecur();
968 d_func()->m_hasItemChangeListeners =
false;
974 return d_func()->m_dirty;
979 return d_func()->m_dirtyArrangement;
984 return d_func()->isMirrored();
1019 d_func()->m_dirtyArrangement =
false;
1039 if (minimum >= 0 && maximum >= 0 && minimum > maximum)
1042 if (preferred >= 0) {
1043 if (minimum >= 0 && preferred < minimum) {
1044 preferred = minimum;
1045 }
else if (maximum >= 0 && preferred > maximum) {
1046 preferred = maximum;
1050 if (minimum >= 0 && descent > minimum)
1073 current = fallbackHint;
1135 cachedSizeHints[
i] =
QSizeF();
1143 static Getters horGetters = {
1147 static Getters verGetters = {
1157 getter = verGetters.call[
i];
1179 combineSize(maxS,
QSizeF(std::numeric_limits<qreal>::infinity(), std::numeric_limits<qreal>::infinity()));
1192 qreal &prefWidth = prefS.rwidth();
1193 qreal &prefHeight = prefS.rheight();
1195 prefWidth =
qCeil(
item->implicitWidth());
1197 prefHeight =
qCeil(
item->implicitHeight());
1200 if (useFallbackToWidthOrHeight && !prefS.isValid()) {
1216 if (cachedSize < 0) {
1217 if (attachedSize < 0)
1218 attachedSize =
size;
1220 cachedSize = attachedSize;
1223 updatePreferredSizes(prefWidth,
info->m_fallbackWidth,
item->width());
1224 updatePreferredSizes(prefHeight,
info->m_fallbackHeight,
item->height());
1235 descentS.setHeight(minimumDescent);
1240 minS += extraMargins;
1241 prefS += extraMargins;
1242 maxS += extraMargins;
1243 descentS += extraMargins;
1246 *attachedInfo =
info;
1256 bool fillExtent([&]{
1260 policy = (orientation ==
Qt::Horizontal) ? sizePolicy.horizontalPolicy() : sizePolicy.verticalPolicy();
1268 isSet =
info->isFillWidthSet();
1269 if (isSet) fillExtent =
info->fillWidth();
1271 isSet =
info->isFillHeightSet();
1272 if (isSet) fillExtent =
info->fillHeight();
1275 if (!isSet && qobject_cast<QQuickLayout*>(
item))
1298 auto b2s = [](
bool b) {
1299 static const char *strBool[] = {
"false",
"true"};
1305 buf += formatLine(
"// Effective calculated values:");
1308 buf += formatLine(
"sizeHint.min : [%1, %2]").arg(f2s(min.width()), 5).arg(min.height(), 5);
1310 buf += formatLine(
"sizeHint.pref: [%1, %2]").arg(pref.
width(), 5).arg(pref.
height(), 5);
1312 buf += formatLine(
"sizeHint.max : [%1, %2]").arg(f2s(max.
width()), 5).arg(f2s(max.
height()), 5);
1317 childLayout->dumpLayoutTreeRecursive(
level,
buf);
1321 if (
item->implicitWidth() > 0)
1322 buf += formatLine(
"implicitWidth: %1").arg(f2s(
item->implicitWidth()));
1323 if (
item->implicitHeight() > 0)
1324 buf += formatLine(
"implicitHeight: %1").arg(f2s(
item->implicitHeight()));
1334 buf += formatLine(
"Layout.minimumWidth: %1").arg(f2s(min.width()));
1336 buf += formatLine(
"Layout.minimumHeight: %1").arg(f2s(min.height()));
1337 if (pref.
width() >= 0)
1338 buf += formatLine(
"Layout.preferredWidth: %1").arg(f2s(pref.
width()));
1340 buf += formatLine(
"Layout.preferredHeight: %1").arg(f2s(pref.
height()));
1342 buf += formatLine(
"Layout.maximumWidth: %1").arg(f2s(max.
width()));
1344 buf += formatLine(
"Layout.maximumHeight: %1").arg(f2s(max.
height()));
1346 if (
info->isFillWidthSet())
1347 buf += formatLine(
"Layout.fillWidth: %1").arg(b2s(
info->fillWidth()));
1348 if (
info->isFillHeightSet())
1349 buf += formatLine(
"Layout.fillHeight: %1").arg(b2s(
info->fillHeight()));
1352 buf += formatLine(
"}");
1356 buf += formatLine(
"}");
1361#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...
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
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
static QQuickItemPrivate * get(QQuickItem *item)
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 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 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.
@ AA_QtQuickUseDefaultSizePolicy
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
\inmodule QtCore \reentrant