6#include "QskStatusIndicatorSkinlet.h"
7#include "QskStatusIndicator.h"
10#include "QskColorFilter.h"
11#include "QskFunctions.h"
12#include "QskGraphic.h"
14QskStatusIndicatorSkinlet::QskStatusIndicatorSkinlet(
QskSkin* skin )
17 setNodeRoles( { GraphicRole } );
20QskStatusIndicatorSkinlet::~QskStatusIndicatorSkinlet() =
default;
22QRectF QskStatusIndicatorSkinlet::subControlRect(
const QskSkinnable* skinnable,
27 if ( subControl == QskStatusIndicator::Graphic )
29 return graphicRect( label, contentsRect );
32 return Inherited::subControlRect( skinnable, contentsRect, subControl );
35QSGNode* QskStatusIndicatorSkinlet::updateSubNode(
36 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node )
const
44 return updateGraphicNode( indicator, node );
48 return Inherited::updateSubNode( skinnable, nodeRole, node );
51QRect QskStatusIndicatorSkinlet::graphicRect(
59 const QRect graphicRect = contentsRect.toAlignedRect();
61 QSizeF sz = indicator->graphic( indicator->status() ).defaultSize();
62 sz.scale( graphicRect.size(), Qt::KeepAspectRatio );
64 return qskAlignedRect( graphicRect,
65 (
int ) sz.width(), (
int ) sz.height(), Qt::AlignCenter );
68QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode(
71 const auto subControl = QskStatusIndicator::Graphic;
73 const auto rect = subControlRect( indicator, indicator->
contentsRect(), subControl );
74 const auto alignment = indicator->
alignmentHint( subControl, Qt::AlignCenter );
75 const int status = indicator->status();
77 node = QskSkinlet::updateGraphicNode( indicator, node,
78 indicator->graphic( status ), indicator->graphicFilter( status ),
84QSizeF QskStatusIndicatorSkinlet::sizeHint(
const QskSkinnable* skinnable,
85 Qt::SizeHint which,
const QSizeF& constraint )
const
87 if ( which != Qt::PreferredSize )
94 for (
const auto status : indicator->statusList() )
96 const auto graphic = indicator->graphic( status );
98 if ( !graphic.isEmpty() )
100 auto hint = graphic.defaultSize();
102 if ( !hint.isEmpty() )
104 if ( constraint.width() >= 0.0 )
106 hint.setHeight( sz.height() * constraint.width() / sz.width() );
108 else if ( constraint.height() >= 0.0 )
110 hint.setWidth( sz.width() * constraint.height() / sz.height() );
114 sz = sz.expandedTo( hint );
121#include "moc_QskStatusIndicatorSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF contentsRect() const
Qt::Alignment alignmentHint(QskAspect, Qt::Alignment=Qt::Alignment()) const
Retrieves an alignment hint.