Widgets/Fader: generic knob drawing code

Instead of hard-coding pixmap sizes, calculate everything dynamically.
This commit is contained in:
Tobias Doerffel
2012-11-27 23:56:37 +01:00
parent 3b72f1e9d9
commit 3739ef82c6
2 changed files with 5 additions and 16 deletions

View File

@@ -79,12 +79,12 @@ private:
virtual void wheelEvent( QWheelEvent *ev );
virtual void paintEvent( QPaintEvent *ev );
inline uint knob_y() const
int knobPosY() const
{
float fRange = m_model->maxValue() - m_model->minValue();
float realVal = m_model->value() - m_model->minValue();
// uint knob_y = (uint)( 116.0 - ( 86.0 * ( m_model->value() / fRange ) ) );
return (uint)( 116.0 - ( 86.0 * ( realVal / fRange ) ) );
return height() - ( ( height() - m_knob.height() ) * ( realVal / fRange ) );
}
FloatModel * m_model;