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:
parent
3cdd0358b3
commit
f25aca5c65
@ -618,52 +618,52 @@ QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constrain
|
|||||||
QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height,
|
QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height,
|
||||||
qreal rowDescent, Qt::Alignment align) const
|
qreal rowDescent, Qt::Alignment align) const
|
||||||
{
|
{
|
||||||
QGridLayoutBox vBox = box(Qt::Vertical);
|
const qreal cellWidth = width;
|
||||||
if (!(align & Qt::AlignBaseline) || vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
|
const qreal cellHeight = height;
|
||||||
qreal cellWidth = width;
|
|
||||||
qreal cellHeight = height;
|
|
||||||
|
|
||||||
|
QSizeF size = effectiveMaxSize(QSizeF(-1,-1));
|
||||||
QSizeF size = effectiveMaxSize(QSizeF(-1,-1));
|
if (hasDynamicConstraint()) {
|
||||||
if (hasDynamicConstraint()) {
|
if (dynamicConstraintOrientation() == Qt::Vertical) {
|
||||||
if (dynamicConstraintOrientation() == Qt::Vertical) {
|
if (size.width() > cellWidth)
|
||||||
if (size.width() > cellWidth)
|
size = effectiveMaxSize(QSizeF(cellWidth, -1));
|
||||||
size = effectiveMaxSize(QSizeF(cellWidth, -1));
|
} else if (size.height() > cellHeight) {
|
||||||
} else if (size.height() > cellHeight) {
|
size = effectiveMaxSize(QSizeF(-1, cellHeight));
|
||||||
size = effectiveMaxSize(QSizeF(-1, cellHeight));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
size = size.boundedTo(QSizeF(cellWidth, cellHeight));
|
|
||||||
width = size.width();
|
|
||||||
height = size.height();
|
|
||||||
|
|
||||||
switch (align & Qt::AlignHorizontal_Mask) {
|
|
||||||
case Qt::AlignHCenter:
|
|
||||||
x += (cellWidth - width)/2;
|
|
||||||
break;
|
|
||||||
case Qt::AlignRight:
|
|
||||||
x += cellWidth - width;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (align & Qt::AlignVertical_Mask) {
|
|
||||||
case Qt::AlignVCenter:
|
|
||||||
y += (cellHeight - height)/2;
|
|
||||||
break;
|
|
||||||
case Qt::AlignBottom:
|
|
||||||
y += cellHeight - height;
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
size = size.boundedTo(QSizeF(cellWidth, cellHeight));
|
||||||
|
width = size.width();
|
||||||
|
height = size.height();
|
||||||
|
|
||||||
|
switch (align & Qt::AlignHorizontal_Mask) {
|
||||||
|
case Qt::AlignHCenter:
|
||||||
|
x += (cellWidth - width)/2;
|
||||||
|
break;
|
||||||
|
case Qt::AlignRight:
|
||||||
|
x += cellWidth - width;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (align & Qt::AlignVertical_Mask) {
|
||||||
|
case Qt::AlignVCenter:
|
||||||
|
y += (cellHeight - height)/2;
|
||||||
|
break;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGridLayoutItem::transpose()
|
void QGridLayoutItem::transpose()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user