From e28b0cdfb5c2cac2ef70637a8b691e0119ba08b9 Mon Sep 17 00:00:00 2001 From: Clemens Manert Date: Mon, 22 Nov 2021 21:00:16 +0100 Subject: [PATCH] Remove ripple from QskSwitchButton --- src/controls/QskSwitchButton.cpp | 1 - src/controls/QskSwitchButton.h | 2 +- src/controls/QskSwitchButtonSkinlet.cpp | 58 +++---------------------- src/controls/QskSwitchButtonSkinlet.h | 2 - 4 files changed, 6 insertions(+), 57 deletions(-) diff --git a/src/controls/QskSwitchButton.cpp b/src/controls/QskSwitchButton.cpp index 78700579..a30079d6 100644 --- a/src/controls/QskSwitchButton.cpp +++ b/src/controls/QskSwitchButton.cpp @@ -2,7 +2,6 @@ QSK_SUBCONTROL( QskSwitchButton, Handle ) QSK_SUBCONTROL( QskSwitchButton, Groove ) -QSK_SUBCONTROL( QskSwitchButton, Ripple ) struct QskSwitchButton::PrivateData { diff --git a/src/controls/QskSwitchButton.h b/src/controls/QskSwitchButton.h index c88da791..ad23c0a8 100644 --- a/src/controls/QskSwitchButton.h +++ b/src/controls/QskSwitchButton.h @@ -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 ); diff --git a/src/controls/QskSwitchButtonSkinlet.cpp b/src/controls/QskSwitchButtonSkinlet.cpp index a3b107ba..852f2b25 100644 --- a/src/controls/QskSwitchButtonSkinlet.cpp +++ b/src/controls/QskSwitchButtonSkinlet.cpp @@ -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" diff --git a/src/controls/QskSwitchButtonSkinlet.h b/src/controls/QskSwitchButtonSkinlet.h index 188ad763..8aef673e 100644 --- a/src/controls/QskSwitchButtonSkinlet.h +++ b/src/controls/QskSwitchButtonSkinlet.h @@ -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