Skip to content

Commit

Permalink
QskProgressRingSkinlet::contentsSizeHint with constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
uwerat committed Sep 9, 2024
1 parent d0a564f commit cc64460
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
29 changes: 16 additions & 13 deletions examples/iotdashboard/Skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ void Skin::initHints()

ed.setPadding( MainContentGridBox::Panel, { 19, 0, 27, 24 } );

// menu bar:

{
// menu bar:

using Q = QskPushButton;
using A = QskAspect;

Expand All @@ -110,24 +110,27 @@ void Skin::initHints()
ed.setAlignment( Q::Icon | A::Header, Qt::AlignCenter );
}

// top bar:
ed.setPadding( TopBar::Panel, { 25, 35, 25, 0 } );
{
// top bar:

ed.setColor( TopBarItem::Item1 | QskAspect::TextColor, 0xffff3122 );
ed.setColor( TopBarItem::Item2 | QskAspect::TextColor, 0xff6776ff );
ed.setColor( TopBarItem::Item3 | QskAspect::TextColor, 0xfff99055 );
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, 0xff6776ff );
ed.setPadding( TopBar::Panel, { 25, 35, 25, 0 } );

ed.setGradient( TopBarItem::Item1, 0xffff5c00, 0xffff3122 );
ed.setGradient( TopBarItem::Item2, 0xff6776ff, 0xff6100ff );
ed.setGradient( TopBarItem::Item3, 0xffffce50, 0xffff3122 );
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
ed.setColor( TopBarItem::Item1 | QskAspect::TextColor, 0xffff3122 );
ed.setColor( TopBarItem::Item2 | QskAspect::TextColor, 0xff6776ff );
ed.setColor( TopBarItem::Item3 | QskAspect::TextColor, 0xfff99055 );
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, 0xff6776ff );

ed.setGradient( TopBarItem::Item1, 0xffff5c00, 0xffff3122 );
ed.setGradient( TopBarItem::Item2, 0xff6776ff, 0xff6100ff );
ed.setGradient( TopBarItem::Item3, 0xffffce50, 0xffff3122 );
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
}

// the bar gradient is defined through the top bar items above
ed.setArcMetrics( QskProgressRing::Groove, 90, -360, 8.53 );
// the span angle will be set in the progress bar, we just give a dummy
// 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 } );

Expand Down
1 change: 0 additions & 1 deletion src/controls/QskProgressRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*****************************************************************************/

#include "QskProgressRing.h"

#include "QskIntervalF.h"

QSK_SUBCONTROL( QskProgressRing, Groove )
Expand Down
17 changes: 15 additions & 2 deletions src/controls/QskProgressRingSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,25 @@ QSGNode* QskProgressRingSkinlet::updateFillNode(
}

QSizeF QskProgressRingSkinlet::sizeHint( const QskSkinnable* skinnable,
Qt::SizeHint which, const QSizeF& ) const
Qt::SizeHint which, const QSizeF& constraint ) const
{
if ( which != Qt::PreferredSize )
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(
Expand Down

0 comments on commit cc64460

Please sign in to comment.