QskSlider::tracking fixed
This commit is contained in:
parent
fe66b99057
commit
4ebd07390f
@ -140,4 +140,10 @@ qreal QskBoundedControl::valueAsRatio( qreal value ) const
|
||||
return ( value - m_minimum ) / ( m_maximum - m_minimum );
|
||||
}
|
||||
|
||||
qreal QskBoundedControl::valueFromRatio( qreal ratio ) const
|
||||
{
|
||||
ratio = qBound( 0.0, ratio, 1.0 );
|
||||
return m_minimum + ratio * ( m_maximum - m_minimum );
|
||||
}
|
||||
|
||||
#include "moc_QskBoundedControl.cpp"
|
||||
|
@ -33,7 +33,9 @@ class QSK_EXPORT QskBoundedControl : public QskControl
|
||||
QskIntervalF boundaries() const;
|
||||
|
||||
qreal boundedValue( qreal ) const;
|
||||
|
||||
qreal valueAsRatio( qreal ) const;
|
||||
qreal valueFromRatio( qreal ) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setMinimum( qreal );
|
||||
|
@ -17,6 +17,12 @@ QSK_SYSTEM_STATE( QskSlider, Pressed, QskAspect::FirstSystemState << 2 )
|
||||
QSK_SYSTEM_STATE( QskSlider, Minimum, QskAspect::FirstSystemState << 3 )
|
||||
QSK_SYSTEM_STATE( QskSlider, Maximum, QskAspect::FirstSystemState << 4 )
|
||||
|
||||
static inline QskAspect::Aspect qskAspectPosition( const QskSlider* slider )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
return slider->effectiveSubcontrol( QskSlider::Handle ) | Position | Metric;
|
||||
}
|
||||
|
||||
class QskSlider::PrivateData
|
||||
{
|
||||
public:
|
||||
@ -105,9 +111,7 @@ bool QskSlider::isTracking() const
|
||||
|
||||
void QskSlider::aboutToShow()
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( QskSlider::Handle );
|
||||
setMetric( subControl | QskAspect::Position, valueAsRatio() );
|
||||
|
||||
setMetric( qskAspectPosition( this ), valueAsRatio() );
|
||||
Inherited::aboutToShow();
|
||||
}
|
||||
|
||||
@ -161,14 +165,6 @@ void QskSlider::mouseMoveEvent( QMouseEvent* event )
|
||||
if ( !isPressed() )
|
||||
return;
|
||||
|
||||
if ( !m_data->tracking )
|
||||
{
|
||||
#if 0
|
||||
// if tracking is false we need to update the position only
|
||||
// without changing the value TODO..
|
||||
#endif
|
||||
}
|
||||
|
||||
const auto r = subControlRect( Scale );
|
||||
|
||||
qreal newValue;
|
||||
@ -184,7 +180,14 @@ void QskSlider::mouseMoveEvent( QMouseEvent* event )
|
||||
newValue = m_data->pressedValue - distance / r.height() * boundaryLength();
|
||||
}
|
||||
|
||||
if ( m_data->tracking )
|
||||
{
|
||||
setValue( newValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
updatePosition( newValue, QskAnimationHint() );
|
||||
}
|
||||
}
|
||||
|
||||
void QskSlider::mouseReleaseEvent( QMouseEvent* event )
|
||||
@ -217,22 +220,34 @@ void QskSlider::mouseReleaseEvent( QMouseEvent* event )
|
||||
else
|
||||
pageDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !m_data->tracking )
|
||||
{
|
||||
const auto pos = metric( qskAspectPosition( this ) );
|
||||
setValue( valueFromRatio( pos ) );
|
||||
}
|
||||
}
|
||||
|
||||
setSkinStateFlag( Pressed, false );
|
||||
Q_EMIT pressedChanged( false );
|
||||
}
|
||||
|
||||
void QskSlider::updatePosition()
|
||||
{
|
||||
const auto hint = animation( qskAspectPosition( this ) | skinState() );
|
||||
updatePosition( value(), hint );
|
||||
}
|
||||
|
||||
void QskSlider::updatePosition( qreal value, const QskAnimationHint& hint )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
setSkinStateFlag( QskSlider::Minimum, value() <= minimum() );
|
||||
setSkinStateFlag( QskSlider::Maximum, value() >= maximum() );
|
||||
setSkinStateFlag( QskSlider::Minimum, value <= minimum() );
|
||||
setSkinStateFlag( QskSlider::Maximum, value >= maximum() );
|
||||
|
||||
const auto aspect = effectiveSubcontrol( QskSlider::Handle ) | Position | Metric;
|
||||
|
||||
const auto hint = animation( aspect | skinState() );
|
||||
const qreal pos = valueAsRatio();
|
||||
const auto aspect = qskAspectPosition( this );
|
||||
const qreal pos = valueAsRatio( value );
|
||||
|
||||
if ( hint.duration > 0 )
|
||||
{
|
||||
|
@ -62,6 +62,7 @@ class QSK_EXPORT QskSlider : public QskBoundedValueInput
|
||||
|
||||
private:
|
||||
void updatePosition();
|
||||
void updatePosition( qreal value, const QskAnimationHint& );
|
||||
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user