6#include "QskSeparatorSkinlet.h"
7#include "QskSeparator.h"
9#include "QskGradientDirection.h"
12QskSeparatorSkinlet::QskSeparatorSkinlet(
QskSkin* skin )
15 setNodeRoles( { PanelRole } );
18QskSeparatorSkinlet::~QskSeparatorSkinlet() =
default;
20QRectF QskSeparatorSkinlet::subControlRect(
const QskSkinnable* skinnable,
23 const auto separator =
static_cast< const QskSeparator*
>( skinnable );
27 return panelRect( separator, contentsRect );
30 return Inherited::subControlRect( skinnable, contentsRect, subControl );
33QSGNode* QskSeparatorSkinlet::updateSubNode(
34 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node )
const
36 const auto separator =
static_cast< const QskSeparator*
>( skinnable );
46 auto gradient = separator->gradientHint( Q::Panel );
47 if ( ( gradient.type() == QskGradient::Stops ) && !gradient.isMonochrome() )
50 const auto orientation = ( separator->orientation() == Qt::Vertical )
51 ? Qt::Horizontal : Qt::Vertical;
53 gradient.setLinearDirection( orientation );
56 return updateBoxNode( separator, node, rect, gradient, Q::Panel );
60 return Inherited::updateSubNode( skinnable, nodeRole, node );
63QRectF QskSeparatorSkinlet::panelRect(
64 const QskSeparator* separator,
const QRectF& contentsRect )
const
66 const qreal extent = separator->extent();
72 r.setWidth( contentsRect.width() );
73 r.setHeight( extent );
77 r.setHeight( contentsRect.height() );
81 r.moveCenter( contentsRect.center() );
85QSizeF QskSeparatorSkinlet::sizeHint(
const QskSkinnable* skinnable,
86 Qt::SizeHint which,
const QSizeF& )
const
88 if ( which != Qt::PreferredSize )
91 const auto separator =
static_cast< const QskSeparator*
>( skinnable );
93 const qreal extent = separator->extent();
96 return QSizeF( -1, extent );
98 return QSizeF( extent, -1 );
101#include "moc_QskSeparatorSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF subControlRect(QskAspect::Subcontrol) const
Separates a group of items from adjacent items.
static const QskAspect::Subcontrol Panel
Qt::Orientation orientation
Orientation of the separator - Qt::Horizontal (the default) or Qt::Vertical.