From 642aa971984755d5c5bc1982c959e7f94f2a43a5 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Mon, 15 Dec 2008 22:55:06 +0000 Subject: [PATCH] Attempt to fix caching bug in track backgrounds git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1933 0778d3d1-df1d-0410-868b-ea421aaaa00d Conflicts: ChangeLog.old src/core/track.cpp --- ChangeLog.old | 6 ++++ src/core/track.cpp | 70 ++++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/ChangeLog.old b/ChangeLog.old index dc103749c..9e33959c4 100644 --- a/ChangeLog.old +++ b/ChangeLog.old @@ -247,6 +247,12 @@ * src/tracks/pattern.cpp: backport: added support for panning editing of notes +2008-12-15 Paul Giblock + + * src/core/track.cpp: + * include/track.h: + Cache background per-object instead of per-class. + 2008-12-14 Tobias Doerffel * CMakeLists.txt: diff --git a/src/core/track.cpp b/src/core/track.cpp index 8f47dee16..82694aaf5 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -895,46 +895,46 @@ void trackContentWidget::updateBackground() // Assume even-pixels-per-tact. Makes sense, should be like this anyways int ppt = static_cast( tcv->pixelsPerTact() ); - int w = ppt * tactsPerBar; - int h = height(); - m_background = QPixmap( w * 2, height() ); - QPainter pmp( &m_background ); + int w = ppt * tactsPerBar; + int h = height(); + m_background = QPixmap( w * 2, height() ); + QPainter pmp( &m_background ); - QLinearGradient grad( 0, 1, 0, h-2 ); - pmp.fillRect( 0, 0, 1, h, QColor( 96, 96, 96 ) ); - pmp.fillRect( 1, 0, w+1, h, QColor( 128, 128, 128 ) ); - grad.setColorAt( 0.0, QColor( 64, 64, 64 ) ); - grad.setColorAt( 0.3, QColor( 128, 128, 128 ) ); - grad.setColorAt( 0.5, QColor( 128, 128, 128 ) ); - grad.setColorAt( 0.95, QColor( 160, 160, 160 ) ); - pmp.fillRect( 0, 1, w, h-2, grad ); + QLinearGradient grad( 0, 1, 0, h-2 ); + pmp.fillRect( 0, 0, 1, h, QColor( 96, 96, 96 ) ); + pmp.fillRect( 1, 0, w+1, h, QColor( 128, 128, 128 ) ); + grad.setColorAt( 0.0, QColor( 64, 64, 64 ) ); + grad.setColorAt( 0.3, QColor( 128, 128, 128 ) ); + grad.setColorAt( 0.5, QColor( 128, 128, 128 ) ); + grad.setColorAt( 0.95, QColor( 160, 160, 160 ) ); + pmp.fillRect( 0, 1, w, h-2, grad ); - QLinearGradient grad2( 0,1, 0, h-2 ); - pmp.fillRect( w+1, 0, w , h, QColor( 96, 96, 96 ) ); - grad2.setColorAt( 0.0, QColor( 48, 48, 48 ) ); - grad2.setColorAt( 0.3, QColor( 96, 96, 96 ) ); - grad2.setColorAt( 0.5, QColor( 96, 96, 96 ) ); - grad2.setColorAt( 0.95, QColor( 120, 120, 120 ) ); - pmp.fillRect( w, 1, w , h-2, grad2 ); + QLinearGradient grad2( 0,1, 0, h-2 ); + pmp.fillRect( w+1, 0, w , h, QColor( 96, 96, 96 ) ); + grad2.setColorAt( 0.0, QColor( 48, 48, 48 ) ); + grad2.setColorAt( 0.3, QColor( 96, 96, 96 ) ); + grad2.setColorAt( 0.5, QColor( 96, 96, 96 ) ); + grad2.setColorAt( 0.95, QColor( 120, 120, 120 ) ); + pmp.fillRect( w, 1, w , h-2, grad2 ); - // draw vertical lines - pmp.setPen( QPen( QColor( 0, 0, 0, 112 ), 1 ) ); - for( float x = 0.5; x < w * 2; x += ppt ) - { - pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) ); - } - pmp.drawLine( 0, 1, w*2, 1 ); + // draw vertical lines + pmp.setPen( QPen( QColor( 0, 0, 0, 112 ), 1 ) ); + for( float x = 0.5; x < w * 2; x += ppt ) + { + pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) ); + } + pmp.drawLine( 0, 1, w*2, 1 ); - pmp.setPen( QPen( QColor( 255, 255, 255, 32 ), 1 ) ); - for( float x = 1.5; x < w * 2; x += ppt ) - { - pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) ); - } - pmp.drawLine( 0, h-2, w*2, h-2 ); + pmp.setPen( QPen( QColor( 255, 255, 255, 32 ), 1 ) ); + for( float x = 1.5; x < w * 2; x += ppt ) + { + pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) ); + } + pmp.drawLine( 0, h-2, w*2, h-2 ); - pmp.end(); + pmp.end(); - // Force redraw + // Force redraw update(); } @@ -1206,7 +1206,9 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe ) */ void trackContentWidget::resizeEvent( QResizeEvent * resizeEvent ) { + // Update backgroud updateBackground(); + // Force redraw QWidget::resizeEvent( resizeEvent ); }