Remove ripple from QskSwitchButton
This commit is contained in:
parent
8add804e3c
commit
e28b0cdfb5
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskSwitchButton, Handle )
|
QSK_SUBCONTROL( QskSwitchButton, Handle )
|
||||||
QSK_SUBCONTROL( QskSwitchButton, Groove )
|
QSK_SUBCONTROL( QskSwitchButton, Groove )
|
||||||
QSK_SUBCONTROL( QskSwitchButton, Ripple )
|
|
||||||
|
|
||||||
struct QskSwitchButton::PrivateData
|
struct QskSwitchButton::PrivateData
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ class QSK_EXPORT QskSwitchButton : public QskAbstractButton
|
||||||
WRITE setInverted NOTIFY invertedChanged FINAL )
|
WRITE setInverted NOTIFY invertedChanged FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Groove, Handle, Ripple )
|
QSK_SUBCONTROLS( Groove, Handle )
|
||||||
|
|
||||||
QskSwitchButton( Qt::Orientation, QQuickItem* parent = nullptr );
|
QskSwitchButton( Qt::Orientation, QQuickItem* parent = nullptr );
|
||||||
QskSwitchButton( QQuickItem* parent = nullptr );
|
QskSwitchButton( QQuickItem* parent = nullptr );
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskSwitchButtonSkinlet.h"
|
|
||||||
#include "QskSwitchButton.h"
|
#include "QskSwitchButton.h"
|
||||||
|
#include "QskSwitchButtonSkinlet.h"
|
||||||
|
#include "QskSGNode.h"
|
||||||
|
|
||||||
static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton )
|
static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton )
|
||||||
{
|
{
|
||||||
|
@ -26,7 +27,7 @@ static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton )
|
||||||
QskSwitchButtonSkinlet::QskSwitchButtonSkinlet( QskSkin* skin )
|
QskSwitchButtonSkinlet::QskSwitchButtonSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
{
|
{
|
||||||
setNodeRoles( { GrooveRole, HandleRole, RippleRole } );
|
setNodeRoles( { GrooveRole, HandleRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSwitchButtonSkinlet::~QskSwitchButtonSkinlet()
|
QskSwitchButtonSkinlet::~QskSwitchButtonSkinlet()
|
||||||
|
@ -48,12 +49,6 @@ QRectF QskSwitchButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
return grooveRect( skinnable, contentsRect );
|
return grooveRect( skinnable, contentsRect );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( subControl == Q::Ripple )
|
|
||||||
{
|
|
||||||
return rippleRect( skinnable, contentsRect );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,12 +58,10 @@ QSizeF QskSwitchButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
auto grooveHint = skinnable->strutSizeHint( QskSwitchButton::Groove );
|
auto groovehint = skinnable->strutSizeHint( QskSwitchButton::Groove );
|
||||||
auto handleHint = skinnable->strutSizeHint( QskSwitchButton::Handle );
|
auto handleHint = skinnable->strutSizeHint( QskSwitchButton::Handle );
|
||||||
auto rippleHint = skinnable->strutSizeHint( QskSwitchButton::Ripple );
|
|
||||||
|
|
||||||
auto hint = grooveHint.expandedTo( grooveHint + rippleHint - handleHint );
|
auto hint = groovehint.expandedTo( groovehint - handleHint );
|
||||||
hint = hint.expandedTo( rippleHint );
|
|
||||||
hint = hint.expandedTo( handleHint );
|
hint = hint.expandedTo( handleHint );
|
||||||
|
|
||||||
return hint;
|
return hint;
|
||||||
|
@ -81,9 +74,6 @@ QSGNode* QskSwitchButtonSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
||||||
|
|
||||||
switch ( nodeRole )
|
switch ( nodeRole )
|
||||||
{
|
{
|
||||||
case RippleRole:
|
|
||||||
return updateBoxNode( skinnable, node, Q::Ripple );
|
|
||||||
|
|
||||||
case HandleRole:
|
case HandleRole:
|
||||||
return updateBoxNode( skinnable, node, Q::Handle );
|
return updateBoxNode( skinnable, node, Q::Handle );
|
||||||
|
|
||||||
|
@ -166,42 +156,4 @@ QRectF QskSwitchButtonSkinlet::handleRect(
|
||||||
return r;
|
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"
|
#include "moc_QskSwitchButtonSkinlet.cpp"
|
||||||
|
|
|
@ -19,7 +19,6 @@ class QSK_EXPORT QskSwitchButtonSkinlet : public QskSkinlet
|
||||||
{
|
{
|
||||||
GrooveRole,
|
GrooveRole,
|
||||||
HandleRole,
|
HandleRole,
|
||||||
RippleRole,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_INVOKABLE QskSwitchButtonSkinlet( QskSkin* = nullptr );
|
Q_INVOKABLE QskSwitchButtonSkinlet( QskSkin* = nullptr );
|
||||||
|
@ -38,7 +37,6 @@ class QSK_EXPORT QskSwitchButtonSkinlet : public QskSkinlet
|
||||||
private:
|
private:
|
||||||
QRectF grooveRect( const QskSkinnable*, const QRectF& ) const;
|
QRectF grooveRect( const QskSkinnable*, const QRectF& ) const;
|
||||||
QRectF handleRect( const QskSkinnable*, const QRectF& ) const;
|
QRectF handleRect( const QskSkinnable*, const QRectF& ) const;
|
||||||
QRectF rippleRect( const QskSkinnable*, const QRectF& ) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue