Waveshaper updates: added amplitude +/- buttons, toggle led to clip input to 0dB, more helpful gridlines in wavegraph

Mallets: artwork update by Bill Y.
New knob: knob_vintage32, currently only used in Mallets, can be used for other things in the future (maybe if we get some more vintage-style synths/effects?)
Graph widget: added new drawing mode (bar style graph) for future use, currently unused anywhere, have plans
This commit is contained in:
Vesa
2014-02-14 18:18:16 +02:00
parent 6b54cf90d1
commit 9265913b73
23 changed files with 197 additions and 94 deletions

View File

@@ -128,12 +128,12 @@ void graph::mouseMoveEvent ( QMouseEvent * _me )
x = qMax( 2, m_lastCursorX - 1 );
}*/
x = qMax( 2, qMin( x, width()-3 ) );
x = qMax( 2, qMin( x, width()-3 ) );
y = qMax( 2, qMin( y, height()-3 ) );
if( qAbs( diff ) > 1 )
{
drawLineAt( x, y, m_lastCursorX );
{
drawLineAt( x, y, m_lastCursorX );
}
else
{
@@ -205,7 +205,7 @@ void graph::drawLineAt( int _x, int _y, int _lastx )
_x -= 2;
_y -= 2;
_lastx -= 2;
_lastx = qMax( 0, qMin( _lastx, width()-5 ) );
float range = minVal - maxVal;
@@ -270,13 +270,15 @@ void graph::paintEvent( QPaintEvent * )
QPainter p( this );
p.setPen( QPen( m_graphColor, 1 ) );
QColor gcol = QColor( m_graphColor.red(), m_graphColor.green(), m_graphColor.blue(), 100 );
QVector<float> * samps = &(model()->m_samples);
int length = model()->length();
const float maxVal = model()->maxValue();
const float minVal = model()->minValue();
float xscale = (float)( width()-4 ) / length;
float yscale = (float)( height()-4 ) / ( model()->minValue() - maxVal );
float yscale = (float)( height()-4 ) / ( minVal - maxVal );
// Max index, more useful below
length--;
@@ -284,7 +286,7 @@ void graph::paintEvent( QPaintEvent * )
switch( m_graphStyle )
{
case graph::LinearStyle:
case graph::LinearStyle:
p.setRenderHints( QPainter::Antialiasing, true );
for( int i=0; i < length; i++ )
@@ -328,7 +330,7 @@ void graph::paintEvent( QPaintEvent * )
width()-3,
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ) );
break;
case graph::LinearNonCyclicStyle:
p.setRenderHints( QPainter::Antialiasing, true );
@@ -347,7 +349,26 @@ void graph::paintEvent( QPaintEvent * )
p.setRenderHints( QPainter::Antialiasing, false );
break;
case graph::BarStyle:
for( int i=0; i <= length; i++ )
{
p.fillRect( 2+static_cast<int>( i*xscale ),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
qMax( static_cast<int>(xscale) - 1, 1 ),
qMax( static_cast<int>( ( minVal - maxVal ) * yscale ) - static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ), 1 ),
gcol );
p.setPen( QPen( m_graphColor, 1 ) );
p.drawLine( 2+static_cast<int>(i*xscale),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
qMax( static_cast<int>(i*xscale) + static_cast<int>(xscale), 2+static_cast<int>(i*xscale) ),
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale )
);
}
break;
default:
break;
@@ -472,7 +493,7 @@ void graphModel::setSampleAt( int _x, float _val )
//snap to the grid
_val -= ( m_step != 0.0 ) ? fmod( _val, m_step ) * m_step : 0;
// boundary crop
// boundary crop
_x = qMax( 0, qMin( length()-1, _x ) );
_val = qMax( minValue(), qMin( maxValue(), _val ) );

View File

@@ -321,7 +321,6 @@ void knob::drawKnob( QPainter * _p )
width() / 2 - m_knobPixmap->width() / 2 ), 0,
*m_knobPixmap );
// p.setPen( QPen( QColor( 200, 0, 0 ), 2 ) );
p.setRenderHint( QPainter::Antialiasing );
const int centerAngle = angleFromValue( model()->centerValue(), model()->minValue(), model()->maxValue(), m_totalAngle );
@@ -329,7 +328,11 @@ void knob::drawKnob( QPainter * _p )
const int arcLineWidth = 2;
const int arcRectSize = m_knobPixmap->width() - arcLineWidth;
QColor col = QApplication::palette().color( QPalette::Active, QPalette::WindowText );
QColor col;
if( m_knobNum == knobVintage_32 )
{ col = QApplication::palette().color( QPalette::Active, QPalette::Shadow ); }
else
{ col = QApplication::palette().color( QPalette::Active, QPalette::WindowText ); }
col.setAlpha( 70 );
p.setPen( QPen( col, 2 ) );
@@ -368,6 +371,13 @@ void knob::drawKnob( QPainter * _p )
p.drawLine( calculateLine( mid, radius ) );
break;
}
case knobVintage_32:
{
p.setPen( QPen( QApplication::palette().color( QPalette::Active,
QPalette::Shadow), 2 ) );
p.drawLine( calculateLine( mid, radius-2, 2 ) );
break;
}
}
p.drawArc( mid.x() - arcRectSize/2, 1, arcRectSize, arcRectSize, (90-centerAngle)*16, -16*(m_angle-centerAngle) );