Don't ignore horizontal alignment for items with baseline alignments

Horizontal alignment were ignored when an item had baseline alignment
specified.

Change-Id: I2df526dc830952cdc26e1973d4787e9457c94edd
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Jan Arve Saether 2014-02-11 13:22:16 +01:00 committed by The Qt Project
parent 3cdd0358b3
commit f25aca5c65

View File

@ -618,11 +618,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
{
QGridLayoutBox vBox = box(Qt::Vertical);
if (!(align & Qt::AlignBaseline) || vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
qreal cellWidth = width;
qreal cellHeight = height;
const qreal cellWidth = width;
const qreal cellHeight = height;
QSizeF size = effectiveMaxSize(QSizeF(-1,-1));
if (hasDynamicConstraint()) {
@ -647,6 +644,7 @@ QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal heig
default:
break;
}
switch (align & Qt::AlignVertical_Mask) {
case Qt::AlignVCenter:
y += (cellHeight - height)/2;
@ -654,16 +652,18 @@ QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal heig
case Qt::AlignBottom:
y += cellHeight - height;
break;
case Qt::AlignBaseline: {
width = qMin(effectiveMaxSize(QSizeF(-1,-1)).width(), width);
QGridLayoutBox vBox = box(Qt::Vertical);
const qreal descent = vBox.q_minimumDescent;
const qreal ascent = vBox.q_minimumSize - descent;
y += (cellHeight - rowDescent - ascent);
height = ascent + descent;
break; }
default:
break;
}
return QRectF(x, y, width, height);
} else {
width = qMin(effectiveMaxSize(QSizeF(-1,-1)).width(), width);
qreal descent = vBox.q_minimumDescent;
qreal ascent = vBox.q_minimumSize - descent;
return QRectF(x, y + height - rowDescent - ascent, width, ascent + descent);
}
}
void QGridLayoutItem::transpose()