Revert "move tolerance in mouse handlinge code"

This reverts commit 2214d2160fd4c37151f9f6451f06ce12f7b7dada.

We keep the tolerance handling inside the other function.
This commit is contained in:
Peter Hartmann 2021-12-03 10:48:32 +01:00
parent 65db642d17
commit 6eb13f245b
1 changed files with 20 additions and 10 deletions

View File

@ -110,24 +110,31 @@ void LightDisplay::mouseMoveEvent( QMouseEvent* event )
const auto rect = subControlRect( ColdAndWarmArc );
bool arcContainsMousePos = arcContainsPoint( rect, mousePos );
const QskArcMetrics metrics = arcMetricsHint( ColdAndWarmArc );
qreal angle = angleFromPoint( rect, mousePos );
const int tolerance = 20;
bool arcWithinStartAngleTolerance = ( angleDiff( angle, metrics.startAngle() ) < tolerance );
bool arcWithinEndAngleTolerance = ( angleDiff( angle, metrics.endAngle() ) < tolerance );
if( !( arcContainsMousePos || arcWithinStartAngleTolerance || arcWithinEndAngleTolerance ) )
if( !arcContainsMousePos )
{
setSkinStateFlag( Pressed, false );
return;
}
if( !arcContainsMousePos )
const QskArcMetrics metrics = arcMetricsHint( ColdAndWarmArc );
qreal angle = angleFromPoint( rect, mousePos );
const int tolerance = 20;
if( !angleInRange( metrics, angle ) )
{
// we're slightly outside the range, but don't want to give up
// the Pressed state
angle = arcWithinStartAngleTolerance ? metrics.startAngle() : metrics.endAngle();
if( angleDiff( angle, metrics.startAngle() ) < tolerance )
{
angle = metrics.startAngle();
}
else if( angleDiff( angle, metrics.endAngle() ) < tolerance )
{
angle = metrics.endAngle();
}
}
qreal ratio = ( metrics.spanAngle() - angle ) / metrics.spanAngle();
@ -162,7 +169,10 @@ bool LightDisplay::arcContainsPoint( const QRectF& rect, const QPointF& point )
rect.center().y() - point.y() );
const qreal angle = angleFromPoint( rect, point );
const bool angleWithinRange = angleInRange( metrics, angle );
const bool angleWithinRange = angleInRange( metrics, angle )
|| angleDiff( angle, metrics.startAngle() ) <= tolerance
|| angleDiff( angle, metrics.endAngle() ) <= tolerance;
// 2. check whether point is on arc
const qreal radiusMax = rect.width() / 2;