Remove ripple from QskSwitchButton

This commit is contained in:
Clemens Manert 2021-11-22 21:00:16 +01:00
parent 8add804e3c
commit e28b0cdfb5
No known key found for this signature in database
GPG Key ID: 9197EAE8F85E3A18
4 changed files with 6 additions and 57 deletions

View File

@ -2,7 +2,6 @@
QSK_SUBCONTROL( QskSwitchButton, Handle )
QSK_SUBCONTROL( QskSwitchButton, Groove )
QSK_SUBCONTROL( QskSwitchButton, Ripple )
struct QskSwitchButton::PrivateData
{

View File

@ -17,7 +17,7 @@ class QSK_EXPORT QskSwitchButton : public QskAbstractButton
WRITE setInverted NOTIFY invertedChanged FINAL )
public:
QSK_SUBCONTROLS( Groove, Handle, Ripple )
QSK_SUBCONTROLS( Groove, Handle )
QskSwitchButton( Qt::Orientation, QQuickItem* parent = nullptr );
QskSwitchButton( QQuickItem* parent = nullptr );

View File

@ -3,8 +3,9 @@
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskSwitchButtonSkinlet.h"
#include "QskSwitchButton.h"
#include "QskSwitchButtonSkinlet.h"
#include "QskSGNode.h"
static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton )
{
@ -26,7 +27,7 @@ static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton )
QskSwitchButtonSkinlet::QskSwitchButtonSkinlet( QskSkin* skin )
: Inherited( skin )
{
setNodeRoles( { GrooveRole, HandleRole, RippleRole } );
setNodeRoles( { GrooveRole, HandleRole } );
}
QskSwitchButtonSkinlet::~QskSwitchButtonSkinlet()
@ -48,12 +49,6 @@ QRectF QskSwitchButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
return grooveRect( skinnable, contentsRect );
}
if ( subControl == Q::Ripple )
{
return rippleRect( skinnable, contentsRect );
}
return Inherited::subControlRect( skinnable, contentsRect, subControl );
}
@ -63,12 +58,10 @@ QSizeF QskSwitchButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
if ( which != Qt::PreferredSize )
return QSizeF();
auto grooveHint = skinnable->strutSizeHint( QskSwitchButton::Groove );
auto groovehint = skinnable->strutSizeHint( QskSwitchButton::Groove );
auto handleHint = skinnable->strutSizeHint( QskSwitchButton::Handle );
auto rippleHint = skinnable->strutSizeHint( QskSwitchButton::Ripple );
auto hint = grooveHint.expandedTo( grooveHint + rippleHint - handleHint );
hint = hint.expandedTo( rippleHint );
auto hint = groovehint.expandedTo( groovehint - handleHint );
hint = hint.expandedTo( handleHint );
return hint;
@ -81,9 +74,6 @@ QSGNode* QskSwitchButtonSkinlet::updateSubNode( const QskSkinnable* skinnable,
switch ( nodeRole )
{
case RippleRole:
return updateBoxNode( skinnable, node, Q::Ripple );
case HandleRole:
return updateBoxNode( skinnable, node, Q::Handle );
@ -166,42 +156,4 @@ QRectF QskSwitchButtonSkinlet::handleRect(
return r;
}
QRectF QskSwitchButtonSkinlet::rippleRect(
const QskSkinnable* skinnable, const QRectF& contentsRect ) const
{
using Q = QskSwitchButton;
const auto switchButton = static_cast< const Q* >( skinnable );
const auto grooveRect = subControlRect( skinnable, contentsRect, Q::Groove );
const auto pos = qskEffectivePosition( switchButton );
const auto sizeHandle = skinnable->strutSizeHint( Q::Handle );
const auto sizeRipple = skinnable->strutSizeHint( Q::Ripple );
qreal cx, cy;
if( switchButton->orientation() == Qt::Vertical )
{
const qreal y0 = grooveRect.y() + 0.5 * sizeHandle.height();
const qreal h = grooveRect.height() - sizeHandle.height();
cx = grooveRect.x() + 0.5 * grooveRect.width();
cy = y0 + pos * h;
}
else
{
const qreal x0 = grooveRect.x() + 0.5 * sizeHandle.width();
const qreal w = grooveRect.width() - sizeHandle.width();
cx = x0 + pos * w;
cy = grooveRect.y() + 0.5 * grooveRect.height();
}
QRectF r;
r.setSize( sizeRipple );
r.moveCenter( QPointF( cx, cy ) );
return r;
}
#include "moc_QskSwitchButtonSkinlet.cpp"

View File

@ -19,7 +19,6 @@ class QSK_EXPORT QskSwitchButtonSkinlet : public QskSkinlet
{
GrooveRole,
HandleRole,
RippleRole,
};
Q_INVOKABLE QskSwitchButtonSkinlet( QskSkin* = nullptr );
@ -38,7 +37,6 @@ class QSK_EXPORT QskSwitchButtonSkinlet : public QskSkinlet
private:
QRectF grooveRect( const QskSkinnable*, const QRectF& ) const;
QRectF handleRect( const QskSkinnable*, const QRectF& ) const;
QRectF rippleRect( const QskSkinnable*, const QRectF& ) const;
};
#endif