using StrutSize instead og Minimum/Maximum metric hints
This commit is contained in:
parent
6c0f0810f1
commit
58de684902
|
@ -73,14 +73,12 @@ namespace
|
||||||
setGradient( Q::NeedleHead, color2 );
|
setGradient( Q::NeedleHead, color2 );
|
||||||
setBoxBorderColors( Q::NeedleHead, color4 );
|
setBoxBorderColors( Q::NeedleHead, color4 );
|
||||||
|
|
||||||
setMetric( Q::Needle | MinimumWidth, 4 );
|
setMetric( Q::Needle | Size, 4 );
|
||||||
setMetric( Q::Needle | Margin, 15 );
|
setMetric( Q::Needle | Margin, 15 );
|
||||||
setColor( Q::Needle, color4 );
|
setColor( Q::Needle, color4 );
|
||||||
|
|
||||||
// margins between numbers and ticks:
|
setSpacing( Q::Labels, 3 );
|
||||||
setMargin( Q::Labels, 3 );
|
setStrutSize( Q::Labels, 3, 25 );
|
||||||
setMetric( Q::Labels | MinimumWidth, 3 );
|
|
||||||
setMetric( Q::Labels | Size, 25 ); // ticks size
|
|
||||||
setColor( Q::Labels, color4 );
|
setColor( Q::Labels, color4 );
|
||||||
setFontRole( Q::Labels, QskSkin::SmallFont );
|
setFontRole( Q::Labels, QskSkin::SmallFont );
|
||||||
}
|
}
|
||||||
|
@ -124,14 +122,12 @@ namespace
|
||||||
QskGradient( QskGradient::Diagonal, color2, color1 ) );
|
QskGradient( QskGradient::Diagonal, color2, color1 ) );
|
||||||
// setBoxBorderColors( Q::NeedleHead, color4 );
|
// setBoxBorderColors( Q::NeedleHead, color4 );
|
||||||
|
|
||||||
setMetric( Q::Needle | MinimumWidth, 2 );
|
setMetric( Q::Needle | Size, 2 );
|
||||||
setMetric( Q::Needle | Margin, 10 );
|
setMetric( Q::Needle | Margin, 10 );
|
||||||
setColor( Q::Needle, color2 );
|
setColor( Q::Needle, color2 );
|
||||||
|
|
||||||
// margins between numbers and ticks:
|
setSpacing( Q::Labels, 4 );
|
||||||
setMargin( Q::Labels, 4 );
|
setStrutSize( Q::Labels, 2, 15 );
|
||||||
setMetric( Q::Labels | MinimumWidth, 2 );
|
|
||||||
setMetric( Q::Labels | Size, 15 ); // ticks size
|
|
||||||
setColor( Q::Labels, color4 );
|
setColor( Q::Labels, color4 );
|
||||||
setFontRole( Q::Labels, QskSkin::SmallFont );
|
setFontRole( Q::Labels, QskSkin::SmallFont );
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode(
|
||||||
ticksNode = new TicksNode();
|
ticksNode = new TicksNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor color = speedometer->color( Q::Labels );
|
const auto color = speedometer->color( Q::Labels );
|
||||||
ticksNode->setColor( color );
|
ticksNode->setColor( color );
|
||||||
|
|
||||||
const auto startAngle = speedometer->minimum();
|
const auto startAngle = speedometer->minimum();
|
||||||
|
@ -156,27 +156,28 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode(
|
||||||
QPointF center = QPointF( panelRect.x() + panelRect.width() / 2,
|
QPointF center = QPointF( panelRect.x() + panelRect.width() / 2,
|
||||||
panelRect.y() + panelRect.height() / 2 );
|
panelRect.y() + panelRect.height() / 2 );
|
||||||
|
|
||||||
auto radius = static_cast< float >( panelRect.width() / 2 );
|
const auto radius = static_cast< float >( panelRect.width() / 2 );
|
||||||
|
|
||||||
const auto numbersMargins = speedometer->marginHint( Q::Labels );
|
const auto spacing = speedometer->spacingHint( Q::Labels );
|
||||||
QFontMetricsF fontMetrics( speedometer->effectiveFont( Q::Labels ) );
|
QFontMetricsF fontMetrics( speedometer->effectiveFont( Q::Labels ) );
|
||||||
|
|
||||||
auto angle = startAngle;
|
auto angle = startAngle;
|
||||||
qreal length = speedometer->metric( Q::Labels | Size );
|
|
||||||
const auto labels = speedometer->labels();
|
const auto labels = speedometer->labels();
|
||||||
|
|
||||||
|
const auto tickSize = speedometer->strutSizeHint( Q::Labels );
|
||||||
|
const auto needleRadius = radius - tickSize.height();
|
||||||
|
|
||||||
// Create a series of tickmarks from minimum to maximum
|
// Create a series of tickmarks from minimum to maximum
|
||||||
for ( int i = 0; i < labelsCount; ++i, angle += step )
|
for ( int i = 0; i < labelsCount; ++i, angle += step )
|
||||||
{
|
{
|
||||||
qreal cosine = qCos( qDegreesToRadians( angle ) );
|
const qreal cos = qFastCos( qDegreesToRadians( angle ) );
|
||||||
qreal sine = qSin( qDegreesToRadians( angle ) );
|
const qreal sin = qFastSin( qDegreesToRadians( angle ) );
|
||||||
|
|
||||||
auto xStart = center.x() + radius * cosine;
|
const auto xStart = center.x() + radius * cos;
|
||||||
auto yStart = center.y() + radius * sine;
|
const auto yStart = center.y() + radius * sin;
|
||||||
|
|
||||||
// ### skin hint for each of highlighted / normal marks
|
const auto xEnd = center.x() + needleRadius * cos;
|
||||||
auto xEnd = center.x() + ( radius - length ) * cosine;
|
const auto yEnd = center.y() + needleRadius * sin;
|
||||||
auto yEnd = center.y() + ( radius - length ) * sine;
|
|
||||||
|
|
||||||
vertexData[ 0 ].set( xStart, yStart );
|
vertexData[ 0 ].set( xStart, yStart );
|
||||||
vertexData[ 1 ].set( xEnd, yEnd );
|
vertexData[ 1 ].set( xEnd, yEnd );
|
||||||
|
@ -188,13 +189,13 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode(
|
||||||
{
|
{
|
||||||
const QString& text = labels.at( i );
|
const QString& text = labels.at( i );
|
||||||
|
|
||||||
auto w = qskHorizontalAdvance( fontMetrics, text );
|
const auto w = qskHorizontalAdvance( fontMetrics, text );
|
||||||
auto h = fontMetrics.height();
|
const auto h = fontMetrics.height();
|
||||||
auto adjustX = ( -0.5 * cosine - 0.5 ) * w;
|
const auto adjustX = ( -0.5 * cos - 0.5 ) * w;
|
||||||
auto adjustY = ( -0.5 * sine - 0.5 ) * h;
|
const auto adjustY = ( -0.5 * sin - 0.5 ) * h;
|
||||||
|
|
||||||
auto numbersX = xEnd + ( -1 * numbersMargins.left() * cosine ) + adjustX;
|
const auto numbersX = xEnd - ( spacing * cos ) + adjustX;
|
||||||
auto numbersY = yEnd + ( -1 * numbersMargins.top() * sine ) + adjustY;
|
const auto numbersY = yEnd - ( spacing * sin ) + adjustY;
|
||||||
|
|
||||||
QRectF numbersRect( numbersX, numbersY, w, h );
|
QRectF numbersRect( numbersX, numbersY, w, h );
|
||||||
|
|
||||||
|
@ -221,8 +222,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lineWidth = speedometer->metric( Q::Labels | MinimumWidth );
|
geometry->setLineWidth( tickSize.width() );
|
||||||
geometry->setLineWidth( lineWidth );
|
|
||||||
geometry->markVertexDataDirty();
|
geometry->markVertexDataDirty();
|
||||||
|
|
||||||
ticksNode->markDirty( QSGNode::DirtyGeometry );
|
ticksNode->markDirty( QSGNode::DirtyGeometry );
|
||||||
|
@ -259,35 +259,34 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode(
|
||||||
|
|
||||||
panelRect = panelRect.marginsRemoved( margins );
|
panelRect = panelRect.marginsRemoved( margins );
|
||||||
|
|
||||||
auto radius = speedometer->metric( Q::NeedleHead | Size );
|
const auto radius = speedometer->metric( Q::NeedleHead | Size );
|
||||||
QPointF center = QPointF( panelRect.x() + panelRect.width() / 2,
|
const QPointF center = panelRect.center();
|
||||||
panelRect.y() + panelRect.height() / 2 );
|
|
||||||
|
const auto borderMetrics = speedometer->boxBorderMetricsHint( Q::NeedleHead );
|
||||||
|
const auto borderColors = speedometer->boxBorderColorsHint( Q::NeedleHead );
|
||||||
|
const auto gradient = speedometer->gradientHint( Q::NeedleHead );
|
||||||
|
|
||||||
QskBoxShapeMetrics shapeMetrics( radius, radius, radius, radius );
|
|
||||||
QskBoxBorderMetrics borderMetrics = speedometer->boxBorderMetricsHint( Q::NeedleHead );
|
|
||||||
QskBoxBorderColors borderColors = speedometer->boxBorderColorsHint( Q::NeedleHead );
|
|
||||||
QskGradient gradient = speedometer->gradientHint( Q::NeedleHead );
|
|
||||||
QRectF centerNodeRect( center.x() - radius, center.y() - radius, 2 * radius, 2 * radius );
|
QRectF centerNodeRect( center.x() - radius, center.y() - radius, 2 * radius, 2 * radius );
|
||||||
boxNode->setBoxData( centerNodeRect, shapeMetrics, borderMetrics, borderColors, gradient );
|
boxNode->setBoxData( centerNodeRect, radius, borderMetrics, borderColors, gradient );
|
||||||
|
|
||||||
QColor color = speedometer->color( Q::Needle );
|
QColor color = speedometer->color( Q::Needle );
|
||||||
needleNode->setColor( color );
|
needleNode->setColor( color );
|
||||||
|
|
||||||
auto panelRadius = static_cast< float >( panelRect.width() / 2 );
|
auto panelRadius = static_cast< float >( panelRect.width() / 2 );
|
||||||
|
|
||||||
auto needleWidth = speedometer->metric( Q::Needle | MinimumWidth );
|
const auto needleWidth = speedometer->metric( Q::Needle | Size );
|
||||||
auto needleMargin = speedometer->metric( Q::Needle | Margin );
|
const auto needleMargin = speedometer->metric( Q::Needle | Margin );
|
||||||
|
|
||||||
float xStart = center.x();
|
const float xStart = center.x();
|
||||||
float yStart = center.y();
|
const float yStart = center.y();
|
||||||
|
|
||||||
float angle = speedometer->value();
|
const float angle = speedometer->value();
|
||||||
qreal cosine = qCos( qDegreesToRadians( angle ) );
|
const qreal cosine = qCos( qDegreesToRadians( angle ) );
|
||||||
qreal sine = qSin( qDegreesToRadians( angle ) );
|
const qreal sine = qSin( qDegreesToRadians( angle ) );
|
||||||
|
|
||||||
float needleRadius = panelRadius - needleMargin;
|
const float needleRadius = panelRadius - needleMargin;
|
||||||
float xEnd = center.x() + needleRadius * cosine;
|
const float xEnd = center.x() + needleRadius * cosine;
|
||||||
float yEnd = center.y() + needleRadius * sine;
|
const float yEnd = center.y() + needleRadius * sine;
|
||||||
|
|
||||||
auto geometry = needleNode->geometry();
|
auto geometry = needleNode->geometry();
|
||||||
geometry->allocate( 2 );
|
geometry->allocate( 2 );
|
||||||
|
|
|
@ -135,14 +135,10 @@ class MySkin : public QskSkin
|
||||||
setBoxBorderColors( Q::Cursor, QColor( foregroundColor ).darker( 120 ) );
|
setBoxBorderColors( Q::Cursor, QColor( foregroundColor ).darker( 120 ) );
|
||||||
setBoxBorderMetrics( Q::Cursor, 1 );
|
setBoxBorderMetrics( Q::Cursor, 1 );
|
||||||
|
|
||||||
for( auto subControl : { Q::Panel, Q::Cursor } )
|
setStrutSize( Q::Panel, width, height );
|
||||||
{
|
|
||||||
setMetric( subControl | MinimumWidth, width );
|
|
||||||
setMetric( subControl | MinimumHeight, height );
|
|
||||||
//setPadding( subControl, +2 );
|
|
||||||
|
|
||||||
setBoxShape( subControl, radius );
|
setBoxShape( Q::Panel, radius );
|
||||||
}
|
setBoxShape( Q::Cursor, radius );
|
||||||
|
|
||||||
setPadding( Q::CheckedPanel, 10 );
|
setPadding( Q::CheckedPanel, 10 );
|
||||||
setPadding( Q::UncheckedPanel, 10 );
|
setPadding( Q::UncheckedPanel, 10 );
|
||||||
|
|
|
@ -200,8 +200,7 @@ QSizeF MyToggleButton::contentsSizeHint(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hint.rwidth() = metric( Panel | QskAspect::MinimumWidth );
|
hint = strutSizeHint( Panel );
|
||||||
hint.rheight() = metric( Panel | QskAspect::MinimumHeight );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hint;
|
return hint;
|
||||||
|
|
|
@ -321,9 +321,7 @@ void QskMaterialSkin::initPushButtonHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||||
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
|
||||||
|
|
||||||
setSpacing( Q::Panel, 4 );
|
setSpacing( Q::Panel, 4 );
|
||||||
|
|
||||||
const QskMargins margin( 4, 3 );
|
const QskMargins margin( 4, 3 );
|
||||||
|
@ -382,9 +380,8 @@ void QskMaterialSkin::initDialogButtonHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel | MinimumWidth, 30 );
|
setStrutSize( Q::Panel, 30, 16 );
|
||||||
setMetric( Q::Panel | MinimumHeight, 16 );
|
setSpacing( Q::Panel, 4 );
|
||||||
setMetric( Q::Panel | Spacing, 4 );
|
|
||||||
|
|
||||||
setMargin( Q::Panel, QskMargins( 4, 3 ) );
|
setMargin( Q::Panel, QskMargins( 4, 3 ) );
|
||||||
setPadding( Q::Panel, QskMargins( 10, 6 ) );
|
setPadding( Q::Panel, QskMargins( 10, 6 ) );
|
||||||
|
@ -515,8 +512,7 @@ void QskMaterialSkin::initTabButtonHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel | MinimumWidth, 30 );
|
setStrutSize( Q::Panel, 30, 16 );
|
||||||
setMetric( Q::Panel | MinimumHeight, 16 );
|
|
||||||
|
|
||||||
for ( const auto placement : { Left, Right, Top, Bottom } )
|
for ( const auto placement : { Left, Right, Top, Bottom } )
|
||||||
{
|
{
|
||||||
|
@ -662,8 +658,9 @@ void QskMaterialSkin::initScrollViewHints()
|
||||||
setPadding( subControl, 0 );
|
setPadding( subControl, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
setMetric( Q::HorizontalScrollHandle | MinimumWidth, qskDpiScaled( 40.0 ) );
|
const auto handleExtent = qskDpiScaled( 40.0 );
|
||||||
setMetric( Q::VerticalScrollHandle | MinimumHeight, qskDpiScaled( 40.0 ) );
|
setStrutSize( Q::HorizontalScrollHandle, handleExtent, 0.0 );
|
||||||
|
setStrutSize( Q::VerticalScrollHandle, 0.0, handleExtent );
|
||||||
|
|
||||||
for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } )
|
for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } )
|
||||||
{
|
{
|
||||||
|
@ -689,7 +686,6 @@ void QskMaterialSkin::initScrollViewHints()
|
||||||
|
|
||||||
void QskMaterialSkin::initListViewHints()
|
void QskMaterialSkin::initListViewHints()
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
|
||||||
using Q = QskListView;
|
using Q = QskListView;
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
|
@ -418,8 +418,7 @@ void QskSquiekSkin::initPushButtonHints()
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
|
|
||||||
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||||
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
|
||||||
|
|
||||||
setMargin( Q::Panel, 0 );
|
setMargin( Q::Panel, 0 );
|
||||||
setPadding( Q::Panel, 10 );
|
setPadding( Q::Panel, 10 );
|
||||||
|
@ -459,8 +458,7 @@ void QskSquiekSkin::initDialogButtonHints()
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
// panel
|
// panel
|
||||||
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
|
||||||
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
|
||||||
|
|
||||||
setPadding( Q::Panel, 10 );
|
setPadding( Q::Panel, 10 );
|
||||||
setMetric( Q::Panel | Spacing, 4 );
|
setMetric( Q::Panel | Spacing, 4 );
|
||||||
|
@ -498,8 +496,7 @@ void QskSquiekSkin::initTabButtonHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
setMetric( Q::Panel | MinimumWidth, 30 );
|
setStrutSize( Q::Panel, 30, 16 );
|
||||||
setMetric( Q::Panel | MinimumHeight, 16 );
|
|
||||||
|
|
||||||
for ( auto placement : { Top, Bottom } )
|
for ( auto placement : { Top, Bottom } )
|
||||||
{
|
{
|
||||||
|
@ -719,7 +716,8 @@ void QskSquiekSkin::initInputPredictionBar()
|
||||||
|
|
||||||
setButton( Q::ButtonPanel, Flat );
|
setButton( Q::ButtonPanel, Flat );
|
||||||
setButton( Q::ButtonPanel | QskPushButton::Pressed, Sunken );
|
setButton( Q::ButtonPanel | QskPushButton::Pressed, Sunken );
|
||||||
setMetric( Q::ButtonPanel | MinimumWidth, qskDpiScaled( 30.0 ) );
|
|
||||||
|
setStrutSize( Q::ButtonPanel, qskDpiScaled( 30.0 ), qskDpiScaled( 10.0 ) );
|
||||||
|
|
||||||
setColor( Q::ButtonText, pal.themeForeground );
|
setColor( Q::ButtonText, pal.themeForeground );
|
||||||
setColor( Q::ButtonText | QskPushButton::Disabled, pal.darker200 );
|
setColor( Q::ButtonText | QskPushButton::Disabled, pal.darker200 );
|
||||||
|
@ -779,15 +777,16 @@ void QskSquiekSkin::initScrollViewHints()
|
||||||
|
|
||||||
setButton( subControl, Raised, bw );
|
setButton( subControl, Raised, bw );
|
||||||
|
|
||||||
// placement ???
|
const auto extent = qskDpiScaled( 40.0 );
|
||||||
|
|
||||||
if ( subControl == Q::HorizontalScrollHandle )
|
if ( subControl == Q::HorizontalScrollHandle )
|
||||||
{
|
{
|
||||||
setMetric( subControl | MinimumWidth, qskDpiScaled( 40.0 ) );
|
setStrutSize( subControl, extent, 0.0 );
|
||||||
setButton( subControl | Q::HorizontalHandlePressed, Sunken, bw );
|
setButton( subControl | Q::HorizontalHandlePressed, Sunken, bw );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setMetric( subControl | MinimumHeight, qskDpiScaled( 40.0 ) );
|
setStrutSize( subControl, 0.0, extent );
|
||||||
setButton( subControl | Q::VerticalHandlePressed, Sunken, bw );
|
setButton( subControl | Q::VerticalHandlePressed, Sunken, bw );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,8 +840,8 @@ void QskSquiekSkin::initSubWindowHints()
|
||||||
|
|
||||||
setGradient( Q::TitleBar | Q::Focused, pal.highlighted );
|
setGradient( Q::TitleBar | Q::Focused, pal.highlighted );
|
||||||
setGradient( Q::TitleBar, pal.contrasted );
|
setGradient( Q::TitleBar, pal.contrasted );
|
||||||
setMetric( Q::TitleBar | Spacing, 5 );
|
setSpacing( Q::TitleBar, 5 );
|
||||||
setMetric( Q::TitleBar | MinimumHeight, 20 );
|
setStrutSize( Q::TitleBar, 0, 20 );
|
||||||
setBoxShape( Q::TitleBar, radius, radius, 0, 0, Qt::AbsoluteSize );
|
setBoxShape( Q::TitleBar, radius, radius, 0, 0, Qt::AbsoluteSize );
|
||||||
|
|
||||||
// TitleBarText
|
// TitleBarText
|
||||||
|
|
|
@ -69,12 +69,10 @@ QSK_NAMESPACE( QskAspect )
|
||||||
{
|
{
|
||||||
NoMetricPrimitive,
|
NoMetricPrimitive,
|
||||||
|
|
||||||
|
StrutSize,
|
||||||
|
|
||||||
Size,
|
Size,
|
||||||
Position,
|
Position,
|
||||||
MinimumWidth,
|
|
||||||
MinimumHeight,
|
|
||||||
MaximumWidth,
|
|
||||||
MaximumHeight,
|
|
||||||
|
|
||||||
Margin,
|
Margin,
|
||||||
Padding,
|
Padding,
|
||||||
|
|
|
@ -97,11 +97,7 @@ QSizeF QskBox::contentsSizeHint(
|
||||||
Qt::SizeHint which, const QSizeF& constraint ) const
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
{
|
{
|
||||||
if ( m_hasPanel && which == Qt::PreferredSize )
|
if ( m_hasPanel && which == Qt::PreferredSize )
|
||||||
{
|
return strutSizeHint( Panel );
|
||||||
return QSizeF(
|
|
||||||
metric( Panel | QskAspect::MinimumWidth ),
|
|
||||||
metric( Panel | QskAspect::MinimumHeight ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return Inherited::contentsSizeHint( which, constraint );
|
return Inherited::contentsSizeHint( which, constraint );
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,11 +103,9 @@ QSizeF QskPageIndicator::contentsSizeHint(
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
using namespace QskAspect;
|
const qreal sizeBullet = metric( Bullet | QskAspect::Size );
|
||||||
|
const qreal sizeCurrent = metric( Highlighted | QskAspect::Size );
|
||||||
const qreal sizeBullet = metric( Bullet | Size );
|
const qreal spacing = spacingHint( Panel );
|
||||||
const qreal sizeCurrent = metric( Highlighted | Size );
|
|
||||||
const qreal spacing = metric( Panel | Spacing );
|
|
||||||
|
|
||||||
const int n = m_data->count;
|
const int n = m_data->count;
|
||||||
|
|
||||||
|
@ -139,11 +137,8 @@ QSizeF QskPageIndicator::contentsSizeHint(
|
||||||
w = qMax( sizeCurrent, sizeBullet );
|
w = qMax( sizeCurrent, sizeBullet );
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSizeF minSize(
|
const auto hint = outerBoxSize( Panel, QSizeF( w, h ) );
|
||||||
metric( Panel | MinimumWidth ),
|
return hint.expandedTo( strutSizeHint( Panel ) );
|
||||||
metric( Panel | MinimumHeight ) );
|
|
||||||
|
|
||||||
return outerBoxSize( Panel, QSizeF( w, h ) ).expandedTo( minSize );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_QskPageIndicator.cpp"
|
#include "moc_QskPageIndicator.cpp"
|
||||||
|
|
|
@ -290,10 +290,7 @@ QSizeF QskPushButton::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) cons
|
||||||
size.rwidth() = qMax( size.width(), w );
|
size.rwidth() = qMax( size.width(), w );
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSizeF minSize( metric( Panel | QskAspect::MinimumWidth ),
|
size = size.expandedTo( strutSizeHint( Panel ) );
|
||||||
metric( Panel | QskAspect::MinimumHeight ) );
|
|
||||||
|
|
||||||
size = size.expandedTo( minSize );
|
|
||||||
size = outerBoxSize( Panel, size );
|
size = outerBoxSize( Panel, size );
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -229,9 +229,9 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||||
if ( !( orientation & scrollOrientations ) )
|
if ( !( orientation & scrollOrientations ) )
|
||||||
return QRectF();
|
return QRectF();
|
||||||
|
|
||||||
const QPointF pos = scrollView->scrollPos();
|
const auto pos = scrollView->scrollPos();
|
||||||
|
|
||||||
const QRectF vRect = subControlRect(
|
const auto vRect = subControlRect(
|
||||||
scrollView, contentsRect, QskScrollView::Viewport );
|
scrollView, contentsRect, QskScrollView::Viewport );
|
||||||
|
|
||||||
QRectF handleRect;
|
QRectF handleRect;
|
||||||
|
@ -248,11 +248,10 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||||
const qreal y1 = pos.y() / h;
|
const qreal y1 = pos.y() / h;
|
||||||
const qreal y2 = ( pos.y() + vRect.height() ) / h;
|
const qreal y2 = ( pos.y() + vRect.height() ) / h;
|
||||||
|
|
||||||
const qreal minHandleLength =
|
const auto strut = scrollView->strutSizeHint( Q::VerticalScrollHandle );
|
||||||
scrollView->metric( Q::VerticalScrollHandle | MinimumHeight );
|
|
||||||
|
|
||||||
qreal top, bottom;
|
qreal top, bottom;
|
||||||
qskAlignedHandle( y1, y2, sbRect.height(), minHandleLength, top, bottom );
|
qskAlignedHandle( y1, y2, sbRect.height(), strut.height(), top, bottom );
|
||||||
|
|
||||||
handleRect = sbRect;
|
handleRect = sbRect;
|
||||||
handleRect.setTop( sbRect.y() + top );
|
handleRect.setTop( sbRect.y() + top );
|
||||||
|
@ -271,11 +270,10 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||||
const qreal x1 = pos.x() / w;
|
const qreal x1 = pos.x() / w;
|
||||||
const qreal x2 = ( pos.x() + vRect.width() ) / w;
|
const qreal x2 = ( pos.x() + vRect.width() ) / w;
|
||||||
|
|
||||||
const qreal minHandleLength =
|
const auto strut = scrollView->strutSizeHint( Q::HorizontalScrollHandle );
|
||||||
scrollView->metric( Q::HorizontalScrollHandle | MinimumWidth );
|
|
||||||
|
|
||||||
qreal left, right;
|
qreal left, right;
|
||||||
qskAlignedHandle( x1, x2, sbRect.width(), minHandleLength, left, right );
|
qskAlignedHandle( x1, x2, sbRect.width(), strut.width(), left, right );
|
||||||
|
|
||||||
handleRect = sbRect;
|
handleRect = sbRect;
|
||||||
handleRect.setLeft( sbRect.x() + left );
|
handleRect.setLeft( sbRect.x() + left );
|
||||||
|
|
|
@ -195,6 +195,21 @@ qreal QskSkin::metric( QskAspect::Aspect aspect ) const
|
||||||
return m_data->hintTable.metric( aspect );
|
return m_data->hintTable.metric( aspect );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskSkin::setStrutSize( QskAspect::Aspect aspect, qreal width, qreal height )
|
||||||
|
{
|
||||||
|
setStrutSize( aspect, QSizeF( width, height ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskSkin::setStrutSize( QskAspect::Aspect aspect, const QSizeF& strut )
|
||||||
|
{
|
||||||
|
m_data->hintTable.setStrutSize( aspect, strut );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF QskSkin::strutSize( QskAspect::Aspect aspect ) const
|
||||||
|
{
|
||||||
|
return m_data->hintTable.strutSize( aspect );
|
||||||
|
}
|
||||||
|
|
||||||
void QskSkin::setMargin( QskAspect::Aspect aspect, const QskMargins& margins )
|
void QskSkin::setMargin( QskAspect::Aspect aspect, const QskMargins& margins )
|
||||||
{
|
{
|
||||||
m_data->hintTable.setMargin( aspect, margins );
|
m_data->hintTable.setMargin( aspect, margins );
|
||||||
|
|
|
@ -70,6 +70,10 @@ class QSK_EXPORT QskSkin : public QObject
|
||||||
void setMetric( QskAspect::Aspect, qreal metric );
|
void setMetric( QskAspect::Aspect, qreal metric );
|
||||||
qreal metric( QskAspect::Aspect ) const;
|
qreal metric( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
|
void setStrutSize( QskAspect::Aspect, const QSizeF& );
|
||||||
|
void setStrutSize( QskAspect::Aspect, qreal width, qreal height );
|
||||||
|
QSizeF strutSize( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
void setMargin( QskAspect::Aspect, const QskMargins& );
|
void setMargin( QskAspect::Aspect, const QskMargins& );
|
||||||
QskMargins margin( QskAspect::Aspect ) const;
|
QskMargins margin( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ class QSK_EXPORT QskSkinHintTable
|
||||||
void setMetric( QskAspect::Aspect, qreal metric );
|
void setMetric( QskAspect::Aspect, qreal metric );
|
||||||
qreal metric( QskAspect::Aspect ) const;
|
qreal metric( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
|
void setStrutSize( QskAspect::Aspect, const QSizeF& );
|
||||||
|
QSizeF strutSize( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
void setMargin( QskAspect::Aspect, const QskMargins& );
|
void setMargin( QskAspect::Aspect, const QskMargins& );
|
||||||
QskMargins margin( QskAspect::Aspect ) const;
|
QskMargins margin( QskAspect::Aspect ) const;
|
||||||
|
|
||||||
|
@ -175,6 +178,19 @@ inline qreal QskSkinHintTable::metric( QskAspect::Aspect aspect ) const
|
||||||
return hint( aspect | QskAspect::Metric ).toReal();
|
return hint( aspect | QskAspect::Metric ).toReal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void QskSkinHintTable::setStrutSize(
|
||||||
|
QskAspect::Aspect aspect, const QSizeF& size )
|
||||||
|
{
|
||||||
|
const auto aspectStrut = aspect | QskAspect::Metric | QskAspect::StrutSize;
|
||||||
|
setHint( aspectStrut, QVariant::fromValue( size ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QSizeF QskSkinHintTable::strutSize( QskAspect::Aspect aspect ) const
|
||||||
|
{
|
||||||
|
const auto aspectStrut = aspect | QskAspect::Metric | QskAspect::StrutSize;
|
||||||
|
return hint( aspectStrut ).value< QSizeF >();
|
||||||
|
}
|
||||||
|
|
||||||
inline void QskSkinHintTable::setMargin(
|
inline void QskSkinHintTable::setMargin(
|
||||||
QskAspect::Aspect aspect, const QskMargins& margins )
|
QskAspect::Aspect aspect, const QskMargins& margins )
|
||||||
{
|
{
|
||||||
|
|
|
@ -246,6 +246,24 @@ qreal QskSkinnable::metric( QskAspect::Aspect aspect, QskSkinHintStatus* status
|
||||||
return effectiveHint( aspect | QskAspect::Metric, status ).toReal();
|
return effectiveHint( aspect | QskAspect::Metric, status ).toReal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskSkinnable::setStrutSizeHint(
|
||||||
|
QskAspect::Aspect aspect, qreal width, qreal height )
|
||||||
|
{
|
||||||
|
setStrutSizeHint( aspect, QSizeF( width, height ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskSkinnable::setStrutSizeHint( const QskAspect::Aspect aspect, const QSizeF& strut )
|
||||||
|
{
|
||||||
|
m_data->hintTable.setStrutSize( aspect, strut );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF QskSkinnable::strutSizeHint(
|
||||||
|
const QskAspect::Aspect aspect, QskSkinHintStatus* status ) const
|
||||||
|
{
|
||||||
|
const auto asp = aspect | QskAspect::Metric | QskAspect::StrutSize;
|
||||||
|
return effectiveHint( asp, status ).value< QSizeF >();
|
||||||
|
}
|
||||||
|
|
||||||
void QskSkinnable::setMarginHint( QskAspect::Aspect aspect, qreal margins )
|
void QskSkinnable::setMarginHint( QskAspect::Aspect aspect, qreal margins )
|
||||||
{
|
{
|
||||||
m_data->hintTable.setMargin( aspect, QskMargins( margins ) );
|
m_data->hintTable.setMargin( aspect, QskMargins( margins ) );
|
||||||
|
|
|
@ -91,6 +91,10 @@ class QSK_EXPORT QskSkinnable
|
||||||
int flagHint( QskAspect::Aspect ) const;
|
int flagHint( QskAspect::Aspect ) const;
|
||||||
template< typename T > T flagHint( QskAspect::Aspect, T = T() ) const;
|
template< typename T > T flagHint( QskAspect::Aspect, T = T() ) const;
|
||||||
|
|
||||||
|
QSizeF strutSizeHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
void setStrutSizeHint( QskAspect::Aspect, const QSizeF& );
|
||||||
|
void setStrutSizeHint( QskAspect::Aspect, qreal width, qreal height );
|
||||||
|
|
||||||
void setMarginHint( QskAspect::Aspect, qreal );
|
void setMarginHint( QskAspect::Aspect, qreal );
|
||||||
void setMarginHint( QskAspect::Aspect, const QMarginsF& );
|
void setMarginHint( QskAspect::Aspect, const QMarginsF& );
|
||||||
bool resetMarginHint( QskAspect::Aspect );
|
bool resetMarginHint( QskAspect::Aspect );
|
||||||
|
|
|
@ -23,7 +23,9 @@ QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
||||||
setNodeRoles( { PanelRole, GrooveRole, FillRole, HandleRole } );
|
setNodeRoles( { PanelRole, GrooveRole, FillRole, HandleRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSliderSkinlet::~QskSliderSkinlet() = default;
|
QskSliderSkinlet::~QskSliderSkinlet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QRectF QskSliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
QRectF QskSliderSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||||
|
@ -92,32 +94,12 @@ QSGNode* QskSliderSkinlet::updateSubNode(
|
||||||
QRectF QskSliderSkinlet::panelRect(
|
QRectF QskSliderSkinlet::panelRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
auto r = contentsRect;
|
||||||
|
|
||||||
const auto subControl = QskSlider::Panel;
|
|
||||||
|
|
||||||
qreal size = slider->metric( subControl | Size ); // 0: no hint
|
|
||||||
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
We use MinimumHeight/MaximumHeight/Size for the "thickness" of
|
|
||||||
to slider even if "Height" is not the expected value for
|
|
||||||
vertical sliders. Maybe we should have the orientation as an aspect bit ?
|
|
||||||
*/
|
|
||||||
|
|
||||||
const qreal minSize = slider->metric( subControl | MinimumHeight );
|
|
||||||
const qreal maxSize = slider->metric( subControl | MaximumHeight );
|
|
||||||
|
|
||||||
size = qMax( size, minSize );
|
|
||||||
if ( maxSize > minSize )
|
|
||||||
size = qMin( size, maxSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF r = contentsRect;
|
|
||||||
|
|
||||||
|
const qreal size = slider->metric( QskSlider::Panel | QskAspect::Size ); // 0: no hint
|
||||||
if ( size > 0 && size < r.height() )
|
if ( size > 0 && size < r.height() )
|
||||||
{
|
{
|
||||||
const auto alignment = slider->alignmentHint( subControl );
|
const auto alignment = slider->alignmentHint( QskSlider::Panel );
|
||||||
|
|
||||||
if ( slider->orientation() == Qt::Horizontal )
|
if ( slider->orientation() == Qt::Horizontal )
|
||||||
r = qskAlignedRectF( r, r.width(), size, alignment & Qt::AlignVertical_Mask );
|
r = qskAlignedRectF( r, r.width(), size, alignment & Qt::AlignVertical_Mask );
|
||||||
|
@ -173,13 +155,15 @@ QRectF QskSliderSkinlet::scaleRect(
|
||||||
QRectF QskSliderSkinlet::fillRect(
|
QRectF QskSliderSkinlet::fillRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
auto r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
using Q = QskSlider;
|
||||||
r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) );
|
|
||||||
|
|
||||||
qreal pos = slider->metric( QskSlider::Handle | QskAspect::Position );
|
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
||||||
|
r = r.marginsRemoved( qskPadding( slider, Q::Panel ) );
|
||||||
|
|
||||||
|
qreal pos = slider->metric( Q::Handle | QskAspect::Position );
|
||||||
pos = qBound( 0.0, pos, 1.0 );
|
pos = qBound( 0.0, pos, 1.0 );
|
||||||
|
|
||||||
auto fillRect = innerRect( slider, contentsRect, QskSlider::Fill );
|
auto fillRect = innerRect( slider, contentsRect, Q::Fill );
|
||||||
if ( slider->orientation() == Qt::Horizontal )
|
if ( slider->orientation() == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
fillRect.setLeft( r.left() );
|
fillRect.setLeft( r.left() );
|
||||||
|
@ -197,7 +181,6 @@ QRectF QskSliderSkinlet::fillRect(
|
||||||
QRectF QskSliderSkinlet::handleRect(
|
QRectF QskSliderSkinlet::handleRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
|
||||||
using Q = QskSlider;
|
using Q = QskSlider;
|
||||||
|
|
||||||
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
||||||
|
@ -210,7 +193,7 @@ QRectF QskSliderSkinlet::handleRect(
|
||||||
{
|
{
|
||||||
QskSkinHintStatus status;
|
QskSkinHintStatus status;
|
||||||
|
|
||||||
extent = slider->metric( Q::Handle | Size, &status );
|
extent = slider->metric( Q::Handle | QskAspect::Size, &status );
|
||||||
if ( !status.isValid() )
|
if ( !status.isValid() )
|
||||||
extent = isHorizontal ? r.height() : r.width();
|
extent = isHorizontal ? r.height() : r.width();
|
||||||
}
|
}
|
||||||
|
@ -222,7 +205,7 @@ QRectF QskSliderSkinlet::handleRect(
|
||||||
slider->marginHint( Q::Handle) );
|
slider->marginHint( Q::Handle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal pos = slider->metric( Q::Handle | Position );
|
qreal pos = slider->metric( Q::Handle | QskAspect::Position );
|
||||||
pos = qBound( 0.0, pos, 1.0 );
|
pos = qBound( 0.0, pos, 1.0 );
|
||||||
|
|
||||||
if ( slider->orientation() == Qt::Horizontal )
|
if ( slider->orientation() == Qt::Horizontal )
|
||||||
|
|
|
@ -111,9 +111,9 @@ qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const
|
||||||
const QFontMetricsF fm( subWindow->effectiveFont( Q::TitleBarText ) );
|
const QFontMetricsF fm( subWindow->effectiveFont( Q::TitleBarText ) );
|
||||||
|
|
||||||
const qreal height = fm.height() + margins.top() + margins.bottom();
|
const qreal height = fm.height() + margins.top() + margins.bottom();
|
||||||
const qreal minHeight = subWindow->metric( Q::TitleBar | QskAspect::MinimumHeight );
|
const auto strutSize = subWindow->strutSizeHint( Q::TitleBar );
|
||||||
|
|
||||||
return qMax( height, minHeight );
|
return qMax( height, strutSize.height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskSubWindowSkinlet::symbolRect(
|
QRectF QskSubWindowSkinlet::symbolRect(
|
||||||
|
|
|
@ -93,14 +93,12 @@ QSizeF QskTabButton::contentsSizeHint(
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
QSizeF size( metric( Panel | QskAspect::MinimumWidth ),
|
auto size = strutSizeHint( Panel );
|
||||||
metric( Panel | QskAspect::MinimumHeight ) );
|
|
||||||
|
|
||||||
if ( !m_data->text.isEmpty() )
|
if ( !m_data->text.isEmpty() )
|
||||||
{
|
{
|
||||||
const QFontMetricsF fm( effectiveFont( Text ) );
|
const QFontMetricsF fm( effectiveFont( Text ) );
|
||||||
const auto textSize = fm.size( Qt::TextShowMnemonic, m_data->text );
|
size += fm.size( Qt::TextShowMnemonic, m_data->text );
|
||||||
size += textSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|
|
@ -463,10 +463,8 @@ QSizeF QskTextInput::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const
|
||||||
const qreal w = input->implicitWidth();
|
const qreal w = input->implicitWidth();
|
||||||
const qreal h = input->implicitHeight();
|
const qreal h = input->implicitHeight();
|
||||||
|
|
||||||
const QSizeF minSize( metric( Panel | QskAspect::MinimumWidth ),
|
const auto hint = outerBoxSize( Panel, QSizeF( w, h ) );
|
||||||
metric( Panel | QskAspect::MinimumHeight ) );
|
return hint.expandedTo( strutSizeHint( Panel ) );
|
||||||
|
|
||||||
return outerBoxSize( Panel, QSizeF( w, h ) ).expandedTo( minSize );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskTextInput::updateLayout()
|
void QskTextInput::updateLayout()
|
||||||
|
|
|
@ -37,10 +37,7 @@ namespace
|
||||||
|
|
||||||
auto size = QFontMetricsF( font() ).size( Qt::TextSingleLine, text() );
|
auto size = QFontMetricsF( font() ).size( Qt::TextSingleLine, text() );
|
||||||
|
|
||||||
const QSizeF minSize( metric( Panel | QskAspect::MinimumWidth ),
|
size = size.expandedTo( strutSizeHint( Panel ) );
|
||||||
metric( Panel | QskAspect::MinimumHeight ) );
|
|
||||||
|
|
||||||
size = size.expandedTo( minSize );
|
|
||||||
size = outerBoxSize( Panel, size );
|
size = outerBoxSize( Panel, size );
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|
Loading…
Reference in New Issue