diff --git a/TODO b/TODO index 9cd0a167d..a80523bf6 100644 --- a/TODO +++ b/TODO @@ -52,7 +52,6 @@ - add FLAC as export-format? Andrew Kelley's todo: -- make knobs easier to tune (less sensitive) - add a Modulator class and a Humanizer tool to the piano roll - when a song goes past the end of the song, make it stop or loop - when looking at a piano roll, if the song is playing that pattern, move the position ticker to where it should be diff --git a/include/knob.h b/include/knob.h index 36bbfbeee..b03391d7d 100644 --- a/include/knob.h +++ b/include/knob.h @@ -141,6 +141,11 @@ private: static textFloat * s_textFloat; + // how many pixels to get from one end of the knob to the other + static const int m_pixelHeight = 400; + // same as model()->value(), except it is a float + float m_fineModelValue; + int m_knobNum; QString m_label; diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp index 7aed4ae72..5d6dffbf0 100644 --- a/src/gui/widgets/knob.cpp +++ b/src/gui/widgets/knob.cpp @@ -85,6 +85,9 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) : setFixedSize( m_knobPixmap->width(), m_knobPixmap->height() ); } + + m_fineModelValue = model()->value(); + setTotalAngle( 270.0f ); setInnerRadius( 1.0f ); setOuterRadius( 10.0f ); @@ -262,7 +265,7 @@ bool knob::updateAngle( void ) int angle = 0; if( model() && model()->maxValue() != model()->minValue() ) { - float a = ( model()->value() - 0.5 * ( model()->minValue() + + float a = ( m_fineModelValue - 0.5 * ( model()->minValue() + model()->maxValue() ) ) / ( model()->maxValue() - model()->minValue() ) * m_totalAngle; @@ -375,9 +378,15 @@ float knob::getValue( const QPoint & _p ) { if( engine::getMainWindow()->isShiftPressed() ) { - return( ( _p.y() - m_origMousePos.y() ) * model()->step() ); + //return( ( _p.y() - m_origMousePos.y() ) * model()->step() ); + return( ( _p.y() - m_origMousePos.y() ) * pageSize() ); + } + else + { + return (float)( _p.y() - m_origMousePos.y() ) / (float)(m_pixelHeight) + * (model()->maxValue() - model()->minValue()) ; + //+ model()->minValue(); } - return( ( _p.y() - m_origMousePos.y() ) * pageSize() ); } @@ -563,7 +572,19 @@ void knob::wheelEvent( QWheelEvent * _we ) void knob::setPosition( const QPoint & _p ) { - model()->setValue( model()->value() - getValue( _p ) ); + // this variable will be exactly where the knob is turned to + m_fineModelValue -= getValue( _p ); + if( m_fineModelValue < model()->minValue() ) + { + m_fineModelValue = model()->minValue(); + } + else if( m_fineModelValue > model()->maxValue() ) + { + m_fineModelValue = model()->maxValue(); + } + + // this can round + model()->setValue( m_fineModelValue ); }