make knobs easier to tune
This commit is contained in:
1
TODO
1
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<float>() );
|
||||
//return( ( _p.y() - m_origMousePos.y() ) * model()->step<float>() );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user