Merge pull request #379 from diizy/stable-0.4

Updated knob code, now everything seems to work really smoothly regardle...
This commit is contained in:
Tobias Doerffel
2014-02-24 21:18:41 +01:00
33 changed files with 30 additions and 14 deletions

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 959 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 900 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 566 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@@ -36,8 +36,6 @@
class QPixmap;
class textFloat;
#define KNOB_SMOOTH_FACTOR 0.125f
enum knobTypes
{
knobDark_28, knobBright_26, knobSmall_17, knobGreen_17, knobVintage_32, knobStyled
@@ -55,7 +53,7 @@ class EXPORT knob : public QWidget, public FloatModelView
Q_PROPERTY(float centerPointY READ centerPointY WRITE setCenterPointY)
Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth)
// Unfortunately, the gradient syntax doesn't create our gradient
// correctly so we need to do this:
Q_PROPERTY(QColor outerColor READ outerColor WRITE setOuterColor)
@@ -90,8 +88,8 @@ public:
float lineWidth() const;
void setLineWidth( float _w );
QColor outerColor() const;
QColor outerColor() const;
void setOuterColor( const QColor & _c );
@@ -140,9 +138,7 @@ private:
inline float pageSize() const
{
return( qMax<float>( ( model()->maxValue() -
model()->minValue() ) / 100.0f,
modelUntyped()->step<float>() ) );
return ( model()->maxValue() - model()->minValue() ) / 100.0f;
}
@@ -156,6 +152,7 @@ private:
QPoint m_mouseOffset;
QPoint m_origMousePos;
float m_leftOver;
bool m_buttonPressed;
float m_totalAngle;

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 461 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 420 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 653 B

After

Width:  |  Height:  |  Size: 646 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 647 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

After

Width:  |  Height:  |  Size: 448 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

After

Width:  |  Height:  |  Size: 373 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

After

Width:  |  Height:  |  Size: 601 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 561 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 337 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 292 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 907 B

After

Width:  |  Height:  |  Size: 795 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 452 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 387 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 489 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 448 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 832 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 411 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 366 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 547 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 533 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 405 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 324 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 515 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 430 B

View File

@@ -388,12 +388,19 @@ void knob::drawKnob( QPainter * _p )
}
float knob::getValue( const QPoint & _p )
{
if( engine::mainWindow()->isShiftPressed() )
{
float value;
// arcane mathemagicks for calculating knob movement
value = ( ( _p.y() + _p.y() * qMin( qAbs( _p.y() / 2 ), 6 ) ) ) / 10.0f;
// if shift pressed we want slower movement
if( engine::mainWindow()->isShiftPressed() )
{
return ( _p.y() * model()->step<float>());
}
return ( _p.y() * KNOB_SMOOTH_FACTOR * pageSize() );
value /= 4.0f;
value = qBound( -4.0f, value, 4.0f );
}
return value * pageSize();
}
@@ -463,6 +470,7 @@ void knob::mousePressEvent( QMouseEvent * _me )
const QPoint & p = _me->pos();
m_origMousePos = p;
m_mouseOffset = QPoint(0, 0);
m_leftOver = 0.0f;
emit sliderPressed();
@@ -580,7 +588,18 @@ void knob::wheelEvent( QWheelEvent * _we )
void knob::setPosition( const QPoint & _p )
{
model()->setValue( model()->value() - getValue(_p) );
const float value = getValue( _p ) + m_leftOver;
const float step = model()->step<float>();
if( qAbs( value ) >= step )
{
model()->setValue( model()->value() - value );
m_leftOver = 0.0f;
}
else
{
m_leftOver = value;
}
}