From 3ccc0685b70508c3f37fe15e21ad6181fddb9d8d Mon Sep 17 00:00:00 2001 From: Vesa Date: Mon, 24 Feb 2014 01:49:48 +0200 Subject: [PATCH] More updates to song editor graphics based on feedback and IRC discussions also fixed the automation pattern rendering which had some slightly bad behaviour --- include/track.h | 2 +- src/core/track.cpp | 4 +-- src/gui/AutomationPatternView.cpp | 57 ++++++++++++++++--------------- src/tracks/SampleTrack.cpp | 19 ++++++++--- src/tracks/bb_track.cpp | 13 ++++--- src/tracks/pattern.cpp | 50 ++++++++++++++++----------- 6 files changed, 85 insertions(+), 60 deletions(-) diff --git a/include/track.h b/include/track.h index e30e62e48..506e1ece6 100644 --- a/include/track.h +++ b/include/track.h @@ -67,7 +67,7 @@ const int TRACK_OP_WIDTH_COMPACT = 60; const int MINIMAL_TRACK_HEIGHT = 8; const int DEFAULT_TRACK_HEIGHT = 32; -const int TCO_BORDER_WIDTH = 1; +const int TCO_BORDER_WIDTH = 2; class trackContentObject : public Model, public JournallingObject diff --git a/src/core/track.cpp b/src/core/track.cpp index a67a3365e..f2d4b3a3d 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -422,8 +422,8 @@ void trackContentObjectView::updateLength() { setFixedWidth( static_cast( m_tco->length() * pixelsPerTact() / - MidiTime::ticksPerTact() ) + - TCO_BORDER_WIDTH * 2-1 ); + MidiTime::ticksPerTact() ) + 1 /*+ + TCO_BORDER_WIDTH * 2-1*/ ); } m_trackView->trackContainerView()->update(); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index b8b64bc74..85a424018 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -174,7 +174,7 @@ void AutomationPatternView::constructContextMenu( QMenu * _cm ) this, SLOT( disconnectObject( QAction * ) ) ); _cm->addMenu( m ); } - + _cm->addSeparator(); } @@ -213,14 +213,23 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); - const QColor c = isSelected() ? QColor( 0, 0, 224 ) : - QColor( 0x99, 0xAF, 0xFF ); + QColor c; + if( !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) ) + c = isSelected() ? QColor( 0, 0, 224 ) + : QColor( 0x99, 0xAF, 0xFF ); + else + c = QColor( 80,80,80 ); + lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); p.setBrush( lingrad ); - p.setPen( QColor( 0, 0, 0 ) ); - p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) ); + p.setPen( c.lighter( 160 ) ); + p.drawRect( 1, 1, width()-3, height()-3 ); + + p.setBrush( QBrush() ); + p.setPen( c.darker( 300 ) ); + p.drawRect( 0, 0, width()-1, height()-1 ); const float ppt = fixedTCOs() ? ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) @@ -232,40 +241,29 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) for( tact_t t = 1; t < m_pat->length().getTact(); ++t ) { - p.drawLine( x_base + static_cast( ppt * t ) - 1, - TCO_BORDER_WIDTH, x_base + static_cast( - ppt * t ) - 1, 5 ); - p.drawLine( x_base + static_cast( ppt * t ) - 1, - height() - ( 4 + 2 * TCO_BORDER_WIDTH ), - x_base + static_cast( ppt * t ) - 1, - height() - 2 * TCO_BORDER_WIDTH ); + const int tx = x_base + static_cast( ppt * t ) - 1; + if( tx < ( width() - TCO_BORDER_WIDTH*2 ) ) + { + p.drawLine( tx, TCO_BORDER_WIDTH, tx, 5 ); + p.drawLine( tx, height() - ( 4 + 2 * TCO_BORDER_WIDTH ), + tx, height() - 2 * TCO_BORDER_WIDTH ); + } } const float min = m_pat->firstObject()->minValue(); const float max = m_pat->firstObject()->maxValue(); const float y_scale = max - min; - const float h = ( height()-2*TCO_BORDER_WIDTH ) / y_scale; + const float h = ( height() - 2*TCO_BORDER_WIDTH ) / y_scale; - p.translate( 0.0f, max * height() / y_scale-1 ); + p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH ); p.scale( 1.0f, -h ); QLinearGradient lin2grad( 0, min, 0, max ); - const QColor cl = QColor( 0x99, 0xAF, 0xFF ); - if( m_pat->isMuted() || m_pat->getTrack()->isMuted() ) - { - lin2grad.setColorAt( 1, QColor( 200,200,200 ) ); - lin2grad.setColorAt( 0, QColor( 100,100,100 ) ); - } - else - { - lin2grad.setColorAt( 1, QColor( 255,255,255 ) ); - lin2grad.setColorAt( 0, cl ); - } - - // TODO: skip this part for patterns or parts of the pattern that will - // not be on the screen + lin2grad.setColorAt( 1, c.lighter( 200 ) ); + lin2grad.setColorAt( 0, c ); + for( AutomationPattern::timeMap::const_iterator it = m_pat->getTimeMap().begin(); it != m_pat->getTimeMap().end(); ++it ) @@ -275,6 +273,8 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) const float x1 = x_base + it.key() * ppt / MidiTime::ticksPerTact(); const float x2 = (float)( width() - TCO_BORDER_WIDTH ); + if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break; + p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ), lin2grad ); break; @@ -288,6 +288,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) MidiTime::ticksPerTact(); const float x2 = x_base + (i+1) * ppt / MidiTime::ticksPerTact(); + if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break; p.fillRect( QRectF( x1, 0.0f, x2-x1, value ), lin2grad ); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index e45126ee3..0afa7c015 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -329,24 +329,33 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - const QColor c = isSelected() ? QColor( 0, 0, 224 ) : - QColor( 74, 253, 133 ); + QColor c; + if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) ) + c = isSelected() ? QColor( 0, 0, 224 ) + : QColor( 74, 253, 133 ); + else c = QColor( 80, 80, 80 ); + QLinearGradient grad( 0, 0, 0, height() ); grad.setColorAt( 1, c.darker( 300 ) ); grad.setColorAt( 0, c ); - p.fillRect( _pe->rect(), grad ); + p.setBrush( grad ); + p.setPen( c.lighter( 160 ) ); + p.drawRect( 1, 1, width()-3, height()-3 ); - p.setPen( QColor( 0, 0, 0 ) ); + p.setBrush( QBrush() ); + p.setPen( c.darker( 300 ) ); p.drawRect( 0, 0, width()-1, height()-1 ); + + if( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) { p.setPen( QColor( 128, 128, 128 ) ); } else { - p.setPen( c.lighter( 300 ) ); + p.setPen( c.lighter( 200 ) ); } QRect r = QRect( 1, 1, qMax( static_cast( m_tco->sampleLength() * diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index 37f0d43a0..651fa2e33 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -48,7 +48,7 @@ bbTrack::infoMap bbTrack::s_infoMap; bbTCO::bbTCO( track * _track, unsigned int _color ) : trackContentObject( _track ), - m_color( _color > 0 ? _color : qRgb( 105, 150, 145 ) ) + m_color( _color > 0 ? _color : qRgb( 128, 182, 175 ) ) { tact_t t = engine::getBBTrackContainer()->lengthOfBB( bbTrack::numOfBBTrack( getTrack() ) ); @@ -205,12 +205,15 @@ void bbTCOView::paintEvent( QPaintEvent * ) } } - p.setPen( col.dark() ); + p.setPen( col.lighter( 130 ) ); + p.drawRect( 1, 1, rect().right()-2, rect().bottom()-2 ); + + p.setPen( col.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); p.setFont( pointSize<8>( p.font() ) ); p.setPen( QColor( 0, 0, 0 ) ); - p.drawText( 2, p.fontMetrics().height() - 1, m_bbTCO->name() ); + p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() ); if( m_bbTCO->isMuted() ) { @@ -402,7 +405,7 @@ trackContentObject * bbTrack::createTCO( const MidiTime & _pos ) if( tcos.size() > 0 && dynamic_cast( tcos.back() ) != NULL ) { return new bbTCO( this, dynamic_cast( tcos.back() )->color() ); - + } return new bbTCO( this ); } @@ -579,7 +582,7 @@ void bbTrackView::clickedTrackLabel() { tv->m_trackLabel->update(); }*/ - + } diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 2de499f6b..2aed9670e 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -184,9 +184,9 @@ note * pattern::addNote( const note & _new_note, const bool _quant_pos ) } else { - // simple algorithm for inserting the note between two + // simple algorithm for inserting the note between two // notes with smaller and greater position - // maybe it could be optimized by starting in the middle and + // maybe it could be optimized by starting in the middle and // going forward or backward but note-inserting isn't that // time-critical since it is usually not done while playing... long new_note_abs_time = new_note->pos(); @@ -245,7 +245,7 @@ void pattern::removeNote( const note * _note_to_del ) note * pattern::rearrangeNote( const note * _note_to_proc, const bool _quant_pos ) { - // just rearrange the position of the note by removing it and adding + // just rearrange the position of the note by removing it and adding // a copy of it -> addNote inserts it at the correct position note copy_of_note( *_note_to_proc ); removeNote( _note_to_proc ); @@ -257,7 +257,7 @@ note * pattern::rearrangeNote( const note * _note_to_proc, void pattern::rearrangeAllNotes() { - // sort notes by start time + // sort notes by start time qSort(m_notes.begin(), m_notes.end(), note::lessThan ); } @@ -765,7 +765,7 @@ void patternView::wheelEvent( QWheelEvent * _we ) } note * n = m_pat->m_notes[step]; int vol = n->getVolume(); - + if( n->length() == 0 && _we->delta() > 0 ) { n->setLength( -DefaultTicksPerTact ); @@ -831,25 +831,37 @@ void patternView::paintEvent( QPaintEvent * ) QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); - const QColor c = isSelected() ? QColor( 0, 0, 224 ) : - QColor( 119, 199, 216 ); - if( m_pat->m_patternType == pattern::BeatPattern ) - { - lingrad.setColorAt( 0, QColor( 16, 16, 16 ) ); - lingrad.setColorAt( 1, QColor( 80, 80, 80 ) ); - } + QColor c; + + if(( m_pat->m_patternType != pattern::BeatPattern ) && + !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) + c = isSelected() ? QColor( 0, 0, 224 ) + : QColor( 119, 199, 216 ); else + c = QColor( 80, 80, 80 ); + + if( m_pat->m_patternType != pattern::BeatPattern ) { lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); } + else + { + lingrad.setColorAt( 0, c.darker( 300 ) ); + lingrad.setColorAt( 1, c ); + } p.setBrush( lingrad ); - p.setPen( QColor( 0, 0, 0 ) ); - //p.drawRect( 0, 0, width() - 1, height() - 1 ); + p.setPen( c.darker( 300 ) ); p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) ); + p.setBrush( QBrush() ); + if( m_pat->m_patternType != pattern::BeatPattern ) + { + p.setPen( c.lighter( 130 ) ); + p.drawRect( QRect( 1, 1, width() - 3, height() - 3 ) ); + } const float ppt = fixedTCOs() ? ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) @@ -875,7 +887,7 @@ void patternView::paintEvent( QPaintEvent * ) int central_key = 0; if( m_pat->m_notes.size() > 0 ) { - // first determine the central tone so that we can + // first determine the central tone so that we can // display the area where most of the m_notes are int total_notes = 0; for( NoteVector::Iterator it = m_pat->m_notes.begin(); @@ -981,11 +993,11 @@ void patternView::paintEvent( QPaintEvent * ) } else if( ( no / 4 ) % 2 ) { - p.drawPixmap( x, y, stepoff ); + p.drawPixmap( x, y, stepoffl ); } else { - p.drawPixmap( x, y, stepoffl ); + p.drawPixmap( x, y, stepoff ); } } } @@ -993,7 +1005,7 @@ void patternView::paintEvent( QPaintEvent * ) p.setFont( pointSize<8>( p.font() ) ); if( m_pat->isMuted() || m_pat->getTrack()->isMuted() ) { - p.setPen( QColor( 50, 50, 502 ) ); + p.setPen( QColor( 30, 30, 30 ) ); } else { @@ -1002,7 +1014,7 @@ void patternView::paintEvent( QPaintEvent * ) if( m_pat->name() != m_pat->instrumentTrack()->name() ) { - p.drawText( 2, p.fontMetrics().height() - 1, m_pat->name() ); + p.drawText( 3, p.fontMetrics().height(), m_pat->name() ); } if( m_pat->isMuted() )