summaryrefslogtreecommitdiffstats
path: root/src/layouts
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-09-09 11:34:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 15:18:25 +0200
commit36d1c9834c5e1951e6ec8ed70793e74441109a88 (patch)
tree995440818a7e27ac94de41adfa363b7cac8fcc64 /src/layouts
parent068a7d6b07e55b142ad649213ac4a9233c521190 (diff)
Add baseline support for Qt Quick Layouts
Change-Id: Ieb5f1a2c9fa81bdb6ff587ef84e97b2233f2e289 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/layouts')
-rw-r--r--src/layouts/qgridlayoutengine.cpp9
-rw-r--r--src/layouts/qquickgridlayoutengine.cpp8
-rw-r--r--src/layouts/qquicklinearlayout.cpp16
-rw-r--r--src/layouts/qquicklinearlayout_p.h2
4 files changed, 21 insertions, 14 deletions
diff --git a/src/layouts/qgridlayoutengine.cpp b/src/layouts/qgridlayoutengine.cpp
index bba1efbd0..e6b21e51b 100644
--- a/src/layouts/qgridlayoutengine.cpp
+++ b/src/layouts/qgridlayoutengine.cpp
@@ -610,8 +610,11 @@ QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constrain
}
result.q_minimumDescent = sizeHint(Qt::MinimumDescent, constraintSize).height();
- if (result.q_minimumDescent >= 0.0)
+ if (result.q_minimumDescent != -1.0) {
+ const qreal minSizeHint = sizeHint(Qt::MinimumSize, constraintSize).height();
+ result.q_minimumDescent -= (minSizeHint - result.q_minimumSize);
result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent;
+ }
}
if (policy & QLayoutPolicy::IgnoreFlag)
result.q_preferredSize = result.q_minimumSize;
@@ -622,10 +625,8 @@ QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constrain
QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height,
qreal rowDescent, Qt::Alignment align) const
{
- rowDescent = -1.0; // ### This disables the descent
-
QGridLayoutBox vBox = box(Qt::Vertical);
- if (vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
+ if (!(align & Qt::AlignBaseline) || vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
qreal cellWidth = width;
qreal cellHeight = height;
diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp
index 7f65d0d5b..b6c0a2448 100644
--- a/src/layouts/qquickgridlayoutengine.cpp
+++ b/src/layouts/qquickgridlayoutengine.cpp
@@ -250,14 +250,18 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c
}
}
- //--- GATHER DESCENT
- // ### Not implemented
// Normalize again after the implicit hints have been gathered
expandSize(prefS, minS);
boundSize(prefS, maxS);
+ //--- GATHER DESCENT
+ // Minimum descent is only applicable for the effective minimum height,
+ // so we gather the descent last.
+ const qreal minimumDescent = minS.height() - item->baselineOffset();
+ descentS.setHeight(minimumDescent);
+
if (attachedInfo)
*attachedInfo = info;
}
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp
index 7639d337d..530241d42 100644
--- a/src/layouts/qquicklinearlayout.cpp
+++ b/src/layouts/qquicklinearlayout.cpp
@@ -265,8 +265,8 @@ QQuickGridLayoutBase::~QQuickGridLayoutBase()
QQuickItem *item = itemAt(i);
QObject::disconnect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
- QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
- QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(invalidateSenderItem()));
+ QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(invalidateSenderItem()));
}
}
@@ -390,8 +390,9 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v
QQuickItem *item = value.item;
QObject::connect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
QObject::connect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
- QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
- QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(invalidateSenderItem()));
+ QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(invalidateSenderItem()));
+ QObject::connect(item, SIGNAL(baselineOffsetChanged(qreal)), this, SLOT(invalidateSenderItem()));
if (isReady() && isVisible())
updateLayoutItems();
@@ -400,8 +401,9 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v
QQuickItem *item = value.item;
QObject::disconnect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
- QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
- QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(invalidateSenderItem()));
+ QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(invalidateSenderItem()));
+ QObject::disconnect(item, SIGNAL(baselineOffsetChanged(qreal)), this, SLOT(invalidateSenderItem()));
if (isReady() && isVisible())
updateLayoutItems();
}
@@ -465,7 +467,7 @@ void QQuickGridLayoutBase::onItemDestroyed()
}
}
-void QQuickGridLayoutBase::onItemImplicitSizeChanged()
+void QQuickGridLayoutBase::invalidateSenderItem()
{
if (!isReady())
return;
diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h
index ed8bf8f96..1b5a3a182 100644
--- a/src/layouts/qquicklinearlayout_p.h
+++ b/src/layouts/qquicklinearlayout_p.h
@@ -94,7 +94,7 @@ signals:
protected slots:
void onItemVisibleChanged();
void onItemDestroyed();
- void onItemImplicitSizeChanged();
+ void invalidateSenderItem();
private:
void removeGridItem(QGridLayoutItem *gridItem);