Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliasing in AutomationPatternView and AutomationEditor fixed #3386

Merged
merged 16 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ AutomationEditor {
qproperty-gridColor: #808080;
qproperty-crossColor: rgb( 255, 51, 51 );

qproperty-graphColor: qlineargradient(spread:reflect,
x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(153, 175, 255, 250), stop:1 rgba(153, 175, 255, 100));
qproperty-graphColor: rgba(153, 175, 255, 250);
qproperty-scaleColor: qlineargradient(spread:reflect,
x1:0, y1:0.5, x2:1, y2:0.5,
stop:0 #333, stop:1 #202020);
Expand Down
3 changes: 1 addition & 2 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ AutomationEditor {
qproperty-beatLineColor: #4a3bba;
qproperty-barLineColor: #8173fe;

qproperty-graphColor: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(69,42,153,180), stop:1 rgba(69,42,153,100));
qproperty-graphColor: rgba(69,42,153,180);
qproperty-scaleColor: #262b30;
}

Expand Down
5 changes: 2 additions & 3 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ public slots:

float getLevel( int y );
int xCoordOfTick( int tick );
int yCoordOfLevel( float level );
inline void drawLevelTick( QPainter & p, int tick,
float value, bool is_selected );
float yCoordOfLevel( float level );
inline void drawLevelTick( QPainter & p, int tick, float value);// bool is_selected ); //NEEDS Change in CSS
void removeSelection();
void selectAll();
void getSelectedValues(timeMap & selected_values );
Expand Down
44 changes: 27 additions & 17 deletions src/gui/AutomationPatternView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )

const float y_scale = max - min;
const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale;
const float ppTick = ppt / MidiTime::ticksPerTact();

p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH );
p.scale( 1.0f, -h );
Expand All @@ -293,14 +294,14 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
lin2grad.setColorAt( 0.5, col );
lin2grad.setColorAt( 0, col.darker( 150 ) );

p.setRenderHints( QPainter::Antialiasing, true );
for( AutomationPattern::timeMap::const_iterator it =
m_pat->getTimeMap().begin();
it != m_pat->getTimeMap().end(); ++it )
{
if( it+1 == m_pat->getTimeMap().end() )
{
const float x1 = x_base + it.key() * ppt /
MidiTime::ticksPerTact();
const float x1 = x_base + it.key() * ppTick;
const float x2 = (float)( width() - TCO_BORDER_WIDTH );
if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break;
if( gradient() )
Expand All @@ -315,27 +316,36 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
}

float *values = m_pat->valuesAfter( it.key() );
for( int i = it.key(); i < (it + 1).key(); i++ )

QPainterPath path;
QPointF origin = QPointF( x_base + it.key() * ppTick, 0.0f );
path.moveTo( origin );
path.moveTo( QPointF( x_base + it.key() * ppTick,values[0] ) );
float x;
for( int i = it.key() + 1; i < ( it + 1 ).key(); i++ )
{
float value = values[i - it.key()];
const float x1 = x_base + i * ppt /
MidiTime::ticksPerTact();
const float x2 = x_base + (i + 1) * ppt /
MidiTime::ticksPerTact();
if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break;
x = x_base + i * ppTick;
if( x > ( width() - TCO_BORDER_WIDTH ) ) break;
float value = values[ i - it.key() ];
path.lineTo( QPointF( x, value ) );

if( gradient() )
{
p.fillRect( QRectF( x1, 0.0f, x2 - x1, value ), lin2grad );
}
else
{
p.fillRect( QRectF( x1, 0.0f, x2 - x1, value ), col );
}
}
path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, values[ ( it + 1 ).key() - 1 - it.key() ] );
path.lineTo( x_base + ( ( it + 1 ).key() ) * ppTick, 0.0f );
path.lineTo( origin );

if( gradient() )
{
p.fillPath( path, lin2grad );
}
else
{
p.fillPath( path, col );
}
delete [] values;
}

p.setRenderHints( QPainter::Antialiasing, false );
p.resetMatrix();

// bar lines
Expand Down
58 changes: 41 additions & 17 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )

if( validPattern() )
{
int len_ticks = 4;
//NEEDS Change in CSS
//int len_ticks = 4;
timeMap & time_map = m_pattern->getTimeMap();

//Don't bother doing/rendering anything if there is no automation points
Expand All @@ -1307,8 +1308,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
{
break;
}

bool is_selected = false;

//NEEDS Change in CSS
/*bool is_selected = false;
// if we're in move-mode, we may only draw
// values in selected area, that have originally
// been selected and not values that are now in
Expand All @@ -1326,15 +1328,34 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
it.key() + len_ticks <= sel_pos_end )
{
is_selected = true;
}
}*/

float *values = m_pattern->valuesAfter( it.key() );
for( int i = 0; i < (it+1).key() - it.key(); i++ )

float nextValue;
if ( m_pattern->valuesAfter( ( it + 1 ).key() ) != NULL )
{
nextValue = *( m_pattern->valuesAfter( ( it + 1 ).key() ) );
}
else
{
nextValue = values[ ( it + 1 ).key() - it.key() -1 ];
}

drawLevelTick( p, it.key() + i, values[i],
is_selected );
p.setRenderHints( QPainter::Antialiasing, true );
QPainterPath path;
path.moveTo( QPointF( xCoordOfTick( it.key() ), yCoordOfLevel( 0 ) ) );
for( int i = 0; i < ( it + 1 ).key() - it.key(); i++ )
{ path.lineTo( QPointF( xCoordOfTick( it.key() + i ), yCoordOfLevel( values[i] ) ) );
//NEEDS Change in CSS
//drawLevelTick( p, it.key() + i, values[i], is_selected );

}
path.lineTo( QPointF( xCoordOfTick( ( it + 1 ).key() ), yCoordOfLevel( nextValue ) ) );
path.lineTo( QPointF( xCoordOfTick( ( it + 1 ).key() ), yCoordOfLevel( 0 ) ) );
path.lineTo( QPointF( xCoordOfTick( it.key() ), yCoordOfLevel( 0 ) ) );
p.fillPath( path, graphColor() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_selected variable was used when a particular automation point was selected, but this is disabled and broken atm, it would requre some CSS changes to be properly implemented, and we can save that for when that feature gets fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can I delete the code referencing the is_selected variable and related code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good when it's commented out as now.

p.setRenderHints( QPainter::Antialiasing, false );
delete [] values;

// Draw circle
Expand All @@ -1349,7 +1370,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
// TODO: Find out if the section after the last control
// point is able to be selected and if so set this
// boolean correctly
drawLevelTick( p, i, it.value(), false );
drawLevelTick( p, i, it.value()); ////NEEDS Change in CSS:, false );
}
// Draw circle(the last one)
drawAutomationPoint(p, it);
Expand Down Expand Up @@ -1433,27 +1454,25 @@ int AutomationEditor::xCoordOfTick(int tick )



int AutomationEditor::yCoordOfLevel(float level )
float AutomationEditor::yCoordOfLevel(float level )
{
int grid_bottom = height() - SCROLLBAR_SIZE - 1;
if( m_y_auto )
{
return (int)( grid_bottom - ( grid_bottom - TOP_MARGIN )
* ( level - m_minLevel )
/ ( m_maxLevel - m_minLevel ) );
return ( grid_bottom - ( grid_bottom - TOP_MARGIN ) * ( level - m_minLevel ) / ( m_maxLevel - m_minLevel ) );
}
else
{
return (int)( grid_bottom - ( level - m_bottomLevel )
* m_y_delta );
return ( grid_bottom - ( level - m_bottomLevel ) * m_y_delta );
}
}




void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value,
bool is_selected )
//NEEDS Change in CSS
void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value)
// bool is_selected )
{
int grid_bottom = height() - SCROLLBAR_SIZE - 1;
const int x = xCoordOfTick( tick );
Expand Down Expand Up @@ -1481,10 +1500,15 @@ void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value,
rect_height = (int)( value * m_y_delta );
}

QBrush currentColor = is_selected
//NEEDS Change in CSS
/*QBrush currentColor = is_selected
? QBrush( QColor( 0x00, 0x40, 0xC0 ) )
: graphColor();

*/

QBrush currentColor = graphColor();

p.fillRect( x, y_start, rect_width, rect_height, currentColor );
}

Expand Down