wrong aspect ratio scaling fixed

This commit is contained in:
Uwe Rathmann 2023-01-23 10:59:01 +01:00
parent 9882dc61ee
commit fff0389262

View File

@ -102,32 +102,34 @@ QskBoxShapeMetrics QskBoxShapeMetrics::toAbsolute( const QSizeF& size ) const no
{ {
auto& radius = absoluted.m_radii[ i ]; auto& radius = absoluted.m_radii[ i ];
const qreal rx = qskAbsoluted( size.width(), radius.width() ); qreal rx = qskAbsoluted( size.width(), radius.width() );
const qreal ry = qskAbsoluted( size.height(), radius.height() ); qreal ry = qskAbsoluted( size.height(), radius.height() );
switch ( m_aspectRatioMode ) if ( rx <= 0.0 || ry <= 0.0 )
{ {
case Qt::IgnoreAspectRatio: radius.rwidth() = radius.rheight() = 0.0;
}
else
{ {
if ( m_aspectRatioMode != Qt::IgnoreAspectRatio )
{
if ( ( m_aspectRatioMode == Qt::KeepAspectRatioByExpanding ) &&
( radius.width() >= radius.height() ) )
{
rx = ry * radius.width() / radius.height();
}
else
{
ry = rx * radius.height() / radius.width();
}
}
radius.rwidth() = rx; radius.rwidth() = rx;
radius.rheight() = ry; radius.rheight() = ry;
break;
}
case Qt::KeepAspectRatio:
{
radius.rwidth() = std::min( rx, ry );
radius.rheight() = std::min( rx, ry );
break;
}
case Qt::KeepAspectRatioByExpanding:
{
radius.rwidth() = std::max( rx, ry );
radius.rheight() = std::max( rx, ry );
break;
}
} }
} }
} }
absoluted.m_sizeMode = Qt::AbsoluteSize; absoluted.m_sizeMode = Qt::AbsoluteSize;
return absoluted; return absoluted;