QskProgressRingSkinlet::contentsSizeHint with constraints

This commit is contained in:
Uwe Rathmann 2024-09-09 09:54:23 +02:00
parent d0a564ff50
commit cc64460a80
3 changed files with 31 additions and 16 deletions

View File

@ -84,9 +84,9 @@ void Skin::initHints()
ed.setPadding( MainContentGridBox::Panel, { 19, 0, 27, 24 } ); ed.setPadding( MainContentGridBox::Panel, { 19, 0, 27, 24 } );
{
// menu bar: // menu bar:
{
using Q = QskPushButton; using Q = QskPushButton;
using A = QskAspect; using A = QskAspect;
@ -110,7 +110,9 @@ void Skin::initHints()
ed.setAlignment( Q::Icon | A::Header, Qt::AlignCenter ); ed.setAlignment( Q::Icon | A::Header, Qt::AlignCenter );
} }
{
// top bar: // top bar:
ed.setPadding( TopBar::Panel, { 25, 35, 25, 0 } ); ed.setPadding( TopBar::Panel, { 25, 35, 25, 0 } );
ed.setColor( TopBarItem::Item1 | QskAspect::TextColor, 0xffff3122 ); ed.setColor( TopBarItem::Item1 | QskAspect::TextColor, 0xffff3122 );
@ -122,12 +124,13 @@ void Skin::initHints()
ed.setGradient( TopBarItem::Item2, 0xff6776ff, 0xff6100ff ); ed.setGradient( TopBarItem::Item2, 0xff6776ff, 0xff6100ff );
ed.setGradient( TopBarItem::Item3, 0xffffce50, 0xffff3122 ); ed.setGradient( TopBarItem::Item3, 0xffffce50, 0xffff3122 );
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff ); ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
}
// the bar gradient is defined through the top bar items above // the bar gradient is defined through the top bar items above
ed.setArcMetrics( QskProgressRing::Groove, 90, -360, 8.53 ); ed.setArcMetrics( QskProgressRing::Groove, 90, -360, 8.53 );
// the span angle will be set in the progress bar, we just give a dummy // the span angle will be set in the progress bar, we just give a dummy
// value here: // value here:
ed.setArcMetrics( QskProgressRing::Fill, 90, -360, 8.53 ); ed.setArcMetrics( QskProgressRing::Fill, ed.arcMetrics( QskProgressRing::Groove ) );
ed.setFontRole( TimeTitleLabel::Text, { QskFontRole::Caption, QskFontRole::High } ); ed.setFontRole( TimeTitleLabel::Text, { QskFontRole::Caption, QskFontRole::High } );

View File

@ -4,7 +4,6 @@
*****************************************************************************/ *****************************************************************************/
#include "QskProgressRing.h" #include "QskProgressRing.h"
#include "QskIntervalF.h" #include "QskIntervalF.h"
QSK_SUBCONTROL( QskProgressRing, Groove ) QSK_SUBCONTROL( QskProgressRing, Groove )

View File

@ -74,12 +74,25 @@ QSGNode* QskProgressRingSkinlet::updateFillNode(
} }
QSizeF QskProgressRingSkinlet::sizeHint( const QskSkinnable* skinnable, QSizeF QskProgressRingSkinlet::sizeHint( const QskSkinnable* skinnable,
Qt::SizeHint which, const QSizeF& ) const Qt::SizeHint which, const QSizeF& constraint ) const
{ {
if ( which != Qt::PreferredSize ) if ( which != Qt::PreferredSize )
return QSizeF(); return QSizeF();
return skinnable->strutSizeHint( Q::Fill ); auto hint = skinnable->strutSizeHint( Q::Fill );
hint = hint.expandedTo( skinnable->strutSizeHint( Q::Groove ) );
if ( !constraint.isEmpty() )
{
const qreal aspectRatio = hint.isEmpty() ? 1.0 : hint.width() / hint.height();
if ( constraint.width() >= 0.0 )
hint.setHeight( constraint.width() / aspectRatio );
else
hint.setWidth( constraint.height() * aspectRatio );
}
return hint;
} }
QskIntervalF QskProgressRingSkinlet::fillInterval( QskIntervalF QskProgressRingSkinlet::fillInterval(