qskinny/src/controls/QskSeparatorSkinlet.cpp

71 lines
1.9 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskSeparatorSkinlet.h"
2018-08-03 08:15:28 +02:00
#include "QskSeparator.h"
2017-07-21 18:21:34 +02:00
2018-08-03 08:30:23 +02:00
#include "QskAspect.h"
2018-08-03 08:15:28 +02:00
QskSeparatorSkinlet::QskSeparatorSkinlet( QskSkin* skin )
: Inherited( skin )
2017-07-21 18:21:34 +02:00
{
setNodeRoles( { PanelRole } );
}
QskSeparatorSkinlet::~QskSeparatorSkinlet() = default;
QRectF QskSeparatorSkinlet::subControlRect( const QskSkinnable* skinnable,
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
2018-08-03 08:15:28 +02:00
{
2017-07-21 18:21:34 +02:00
const auto separator = static_cast< const QskSeparator* >( skinnable );
2018-08-03 08:15:28 +02:00
2017-07-21 18:21:34 +02:00
if ( subControl == QskSeparator::Panel )
{
return panelRect( separator, contentsRect );
2017-07-21 18:21:34 +02:00
}
2018-08-03 08:15:28 +02:00
return Inherited::subControlRect( skinnable, contentsRect, subControl );
2017-09-01 11:55:55 +02:00
}
QSGNode* QskSeparatorSkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
const auto separator = static_cast< const QskSeparator* >( skinnable );
2018-08-03 08:15:28 +02:00
switch ( nodeRole )
2017-09-01 11:55:55 +02:00
{
case PanelRole:
{
return updateBoxNode( separator, node, QskSeparator::Panel );
2017-09-01 11:55:55 +02:00
}
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
}
2017-07-21 18:21:34 +02:00
QRectF QskSeparatorSkinlet::panelRect(
const QskSeparator* separator, const QRectF& contentsRect ) const
2017-07-21 18:21:34 +02:00
{
2020-12-17 08:53:44 +01:00
const qreal extent = separator->extent();
2017-07-21 18:21:34 +02:00
QRectF r;
if ( separator->orientation() == Qt::Horizontal )
{
r.setWidth( contentsRect.width() );
2020-12-17 08:53:44 +01:00
r.setHeight( extent );
2017-07-21 18:21:34 +02:00
}
else
{
r.setHeight( contentsRect.height() );
2020-12-17 08:53:44 +01:00
r.setWidth( extent );
2017-07-21 18:21:34 +02:00
}
r.moveCenter( contentsRect.center() );
2017-07-21 18:21:34 +02:00
return r;
}
#include "moc_QskSeparatorSkinlet.cpp"