minor cleanups

This commit is contained in:
Uwe Rathmann 2022-07-17 14:44:19 +02:00
parent bcfe966a87
commit e6fb38d383
2 changed files with 19 additions and 17 deletions

View File

@ -318,7 +318,7 @@ void QskPushButton::mousePressEvent( QMouseEvent* event )
if( hint.isValid() ) if( hint.isValid() )
{ {
setSkinHint( Ripple | QskAspect::Position, event->pos() ); setSkinHint( Ripple | QskAspect::Metric | QskAspect::Position, event->pos() );
m_data->clickAnimator.setWindow( window() ); m_data->clickAnimator.setWindow( window() );
m_data->clickAnimator.setButton( this ); m_data->clickAnimator.setButton( this );

View File

@ -38,30 +38,40 @@ QskPushButtonSkinlet::~QskPushButtonSkinlet() = default;
QRectF QskPushButtonSkinlet::subControlRect( const QskSkinnable* skinnable, QRectF QskPushButtonSkinlet::subControlRect( const QskSkinnable* skinnable,
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
{ {
using Q = QskPushButton;
const auto button = static_cast< const QskPushButton* >( skinnable ); const auto button = static_cast< const QskPushButton* >( skinnable );
if ( subControl == QskPushButton::Text ) if ( subControl == Q::Text )
{ {
return textRect( button, contentsRect ); return textRect( button, contentsRect );
} }
else if ( subControl == QskPushButton::Graphic ) else if ( subControl == Q::Graphic )
{ {
return graphicRect( button, contentsRect ); return graphicRect( button, contentsRect );
} }
else if ( subControl == QskPushButton::Panel ) else if ( subControl == Q::Panel )
{ {
return contentsRect; return contentsRect;
} }
else if ( subControl == QskPushButton::Ripple ) else if ( subControl == Q::Ripple )
{ {
const auto clickPos = button->effectiveSkinHint( QskPushButton::Ripple | QskAspect::Position ).toPointF(); const auto ratio = button->metric( Q::Ripple | QskAspect::Size );
const auto ratio = button->metric( QskPushButton::Ripple | QskAspect::Size ); if ( ratio <= 0.0 )
return QRectF();
const auto clickPos = button->effectiveSkinHint(
Q::Ripple | QskAspect::Metric | QskAspect::Position ).toPointF();
const auto w = contentsRect.width() * ratio; const auto w = contentsRect.width() * ratio;
const auto h = contentsRect.height() * ratio; const auto h = contentsRect.height() * ratio;
const auto x = clickPos.x() - w; const auto x = clickPos.x() - w;
const auto y = clickPos.y() - h; const auto y = clickPos.y() - h;
const QRectF r( x, y, w * 2, h * 2 ); const QRectF r( x, y, w * 2, h * 2 );
return r.intersected( contentsRect );
const auto clipRect = subControlRect( skinnable, contentsRect, Q::Panel );
return r.intersected( clipRect );
} }
return Inherited::subControlRect( skinnable, contentsRect, subControl ); return Inherited::subControlRect( skinnable, contentsRect, subControl );
@ -80,17 +90,9 @@ QSGNode* QskPushButtonSkinlet::updateSubNode(
} }
case RippleRole: case RippleRole:
{
if( button->hasAnimationHint( QskPushButton::Ripple | QskAspect::Color )
&& button->metric( QskPushButton::Ripple | QskAspect::Size ) > 0.0 )
{ {
return updateBoxNode( button, node, QskPushButton::Ripple ); return updateBoxNode( button, node, QskPushButton::Ripple );
} }
else
{
return nullptr;
}
}
case TextRole: case TextRole:
{ {