windows style: Style progress bar

... and allow for the case where the bar is bigger than the groove.
This commit is contained in:
Peter Hartmann 2023-06-02 15:14:13 +02:00 committed by uwerat
parent 0421066dee
commit d56c99b3e7
3 changed files with 36 additions and 10 deletions

View File

@ -276,6 +276,16 @@ void Editor::setupPopup()
void Editor::setupProgressBar()
{
using Q = QskProgressBar;
using A = QskAspect;
setMetric( Q::Groove | A::Size, 1 );
setBoxShape( Q::Groove, 100, Qt::RelativeSize );
setGradient( Q::Groove, theme.palette.strokeColor.controlStrongStroke.defaultColor );
setMetric( Q::Bar| A::Size, 3 );
setBoxShape( Q::Bar, 100, Qt::RelativeSize );
setGradient( Q::Bar, theme.palette.fillColor.accent.defaultColor );
}
void Editor::setupPushButton()

View File

@ -192,7 +192,9 @@ void QskProgressBar::resetExtent()
qreal QskProgressBar::extent() const
{
return metric( Groove | QskAspect::Size );
auto grooveSize = metric( Groove | QskAspect::Size );
auto barSize = metric( Bar | QskAspect::Size );
return qMax( grooveSize, barSize );
}
void QskProgressBar::setOrigin( qreal origin )

View File

@ -62,28 +62,29 @@ QRectF QskProgressBarSkinlet::subControlRect(
const QskSkinnable* skinnable, const QRectF& contentsRect,
QskAspect::Subcontrol subControl ) const
{
const auto bar = static_cast< const QskProgressBar* >( skinnable );
using Q = QskProgressBar;
const auto bar = static_cast< const Q* >( skinnable );
if( subControl == QskProgressBar::Groove )
if( subControl == Q::Groove )
{
const auto extent = bar->extent();
const auto grooveSize = bar->metric( Q::Groove | QskAspect::Size );
auto rect = contentsRect;
if ( bar->orientation() == Qt::Horizontal )
{
rect.setY( rect.y() + 0.5 * ( rect.height() - extent ) );
rect.setHeight( extent );
rect.setY( rect.y() + 0.5 * ( rect.height() - grooveSize ) );
rect.setHeight( grooveSize );
}
else
{
rect.setX( rect.x() + 0.5 * ( rect.width() - extent ) );
rect.setWidth( extent );
rect.setX( rect.x() + 0.5 * ( rect.width() - grooveSize ) );
rect.setWidth( grooveSize );
}
return rect;
}
if( subControl == QskProgressBar::Bar )
if( subControl == Q::Bar )
{
return barRect( bar );
}
@ -154,10 +155,23 @@ QSGNode* QskProgressBarSkinlet::updateBarNode(
QRectF QskProgressBarSkinlet::barRect( const QskProgressBar* bar ) const
{
const auto subControl = QskProgressBar::Groove;
using Q = QskProgressBar;
const auto subControl = Q::Groove;
const auto barSize = bar->metric( Q::Bar | QskAspect::Size );
auto rect = bar->subControlRect( subControl );
if ( bar->orientation() == Qt::Horizontal )
{
rect.setY( rect.y() + 0.5 * ( rect.height() - barSize ) );
rect.setHeight( barSize );
}
else
{
rect.setX( rect.x() + 0.5 * ( rect.width() - barSize ) );
rect.setWidth( barSize );
}
const auto borderMetrics = bar->boxBorderMetricsHint( subControl );
auto m = bar->paddingHint( subControl );