diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 7c62a852a1c..06ae4c72bff 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -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); diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 6d9c1c712a5..035ed7a5f56 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -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; } diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index b926b2613bd..2e77a7483dd 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -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 ); diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 89dc28f26a0..c0f7f6a4384 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -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 ); @@ -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() ) @@ -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 diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index a425b0dea39..a6f7d16deec 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -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 @@ -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 @@ -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() ); + p.setRenderHints( QPainter::Antialiasing, false ); delete [] values; // Draw circle @@ -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); @@ -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 ); @@ -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 ); }