Envelope: fix drawing of envelope graph, scale to fit view if graph gets too long
(also fix typo in last pianoview commit)
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ENVELOPE_AND_LFO_VIEW_H
|
||||
#define _ENVELOPE_AND_LFO_VIEW_H
|
||||
#ifndef ENVELOPE_AND_LFO_VIEW_H
|
||||
#define ENVELOPE_AND_LFO_VIEW_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
|
||||
@@ -469,7 +469,7 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
|
||||
Piano::WhiteKey ) ?
|
||||
PW_WHITE_KEY_HEIGHT : PW_BLACK_KEY_HEIGHT ) )
|
||||
{
|
||||
velocity = m_piano->instrumentTrack()->midiPort()->baseVelocity() );
|
||||
velocity = m_piano->instrumentTrack()->midiPort()->baseVelocity();
|
||||
}
|
||||
// set note on
|
||||
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOn, 0, key_num, velocity ) );
|
||||
|
||||
@@ -62,8 +62,7 @@ const int SUSTAIN_KNOB_X = DECAY_KNOB_X+KNOB_X_SPACING;
|
||||
const int RELEASE_KNOB_X = SUSTAIN_KNOB_X+KNOB_X_SPACING;
|
||||
const int AMOUNT_KNOB_X = RELEASE_KNOB_X+KNOB_X_SPACING;
|
||||
|
||||
const float TIME_UNIT_WIDTH = 24.0;
|
||||
|
||||
const int TIME_UNIT_WIDTH = 40;
|
||||
|
||||
const int LFO_GRAPH_X = 6;
|
||||
const int LFO_GRAPH_Y = ENV_KNOBS_LBL_Y+14;
|
||||
@@ -425,48 +424,56 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
|
||||
const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3;
|
||||
const int avail_height = s_envGraph->height() - 6;
|
||||
|
||||
int x1 = ENV_GRAPH_X + 2 + static_cast<int>( m_predelayKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
int x1 = static_cast<int>( m_predelayKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
int x3 = x2 + static_cast<int>( m_holdKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
int x4 = x3 + static_cast<int>( ( m_decayKnob->value<float>() *
|
||||
( 1 - m_sustainKnob->value<float>() ) ) * TIME_UNIT_WIDTH );
|
||||
int x5 = x4 + static_cast<int>( m_releaseKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
if( x5 > 174 )
|
||||
{
|
||||
x1 = ( x1 * 174 ) / x5;
|
||||
x2 = ( x2 * 174 ) / x5;
|
||||
x3 = ( x3 * 174 ) / x5;
|
||||
x4 = ( x4 * 174 ) / x5;
|
||||
x5 = ( x5 * 174 ) / x5;
|
||||
}
|
||||
x1 += ENV_GRAPH_X + 2;
|
||||
x2 += ENV_GRAPH_X + 2;
|
||||
x3 += ENV_GRAPH_X + 2;
|
||||
x4 += ENV_GRAPH_X + 2;
|
||||
x5 += ENV_GRAPH_X + 2;
|
||||
|
||||
p.drawLine( x1, y_base, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_holdKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base - avail_height, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
p.drawLine( x2, y_base - avail_height, x3, y_base - avail_height );
|
||||
p.fillRect( x2 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( ( m_decayKnob->value<float>() *
|
||||
( 1 - m_sustainKnob->value<float>() ) ) *
|
||||
TIME_UNIT_WIDTH );
|
||||
p.fillRect( x2, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
|
||||
p.drawLine( x1, y_base-avail_height, x2, static_cast<int>( y_base -
|
||||
p.drawLine( x3, y_base-avail_height, x4, static_cast<int>( y_base -
|
||||
avail_height +
|
||||
( 1 - m_sustainKnob->value<float>() ) * avail_height ) );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
p.fillRect( x3 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_releaseKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, static_cast<int>( y_base - avail_height +
|
||||
p.fillRect( x3, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
|
||||
p.drawLine( x4, static_cast<int>( y_base - avail_height +
|
||||
( 1 - m_sustainKnob->value<float>() ) *
|
||||
avail_height ), x2, y_base );
|
||||
p.fillRect( x1 - 1, static_cast<int>( y_base - avail_height +
|
||||
avail_height ), x5, y_base );
|
||||
p.fillRect( x4 - 1, static_cast<int>( y_base - avail_height +
|
||||
( 1 - m_sustainKnob->value<float>() ) *
|
||||
avail_height ) - 2, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, static_cast<int>( y_base - avail_height +
|
||||
p.fillRect( x4, static_cast<int>( y_base - avail_height +
|
||||
( 1 - m_sustainKnob->value<float>() ) *
|
||||
avail_height ) - 1, 2, 2,
|
||||
end_points_color );
|
||||
p.fillRect( x2 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
p.fillRect( x2, y_base - 1, 2, 2, end_points_color );
|
||||
p.fillRect( x5 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
p.fillRect( x5, y_base - 1, 2, 2, end_points_color );
|
||||
|
||||
|
||||
int LFO_GRAPH_W = s_lfoGraph->width() - 6; // substract border
|
||||
|
||||
Reference in New Issue
Block a user