From fa5c0c1569f2c1c08319a3b2982b650a2e55cfba Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Thu, 30 Jul 2015 22:32:38 +0200 Subject: [PATCH] Fixes the rendering of the tact numbers in the timeline Fixed the rendering of the tact numbers in the timeline widget. Before this fix they were not readable because they were too big. Interestingly in this case the fix is to use a font size in pixels (half the height of the widget). The numbers are now also rendered a bit darker than the lines. Also removed the pixmap for the timeline from the code and from the filesystem. It was only used to determine the fixed height of the widget but not rendered. Therefore it was removed and the height is now directly set to 18 pixels which was the height of the pixmap. --- data/themes/default/timeline.png | Bin 212 -> 0 bytes include/TimeLineWidget.h | 1 - src/gui/TimeLineWidget.cpp | 21 ++++++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) delete mode 100644 data/themes/default/timeline.png diff --git a/data/themes/default/timeline.png b/data/themes/default/timeline.png deleted file mode 100644 index b942d72d16b4e8f4f23b086b70577b5af0f97cdd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex0VEjY7dQ6-DW)WEcNc~RchdzzKwht>i(`m{ zWbMJ*o-B+Et{dm9dwYQG%2(EZH=mVG6BRk)xhr1zvv+phuQ|^yY>CLun`JlW_1cq( zhLMvM!}4_|Z(X+VslgXJlm9QT?u_$^$X?s}H0^8FldQFwDH$)0hJNm!_jlu;7nh16 zrgbU`U)#J;v2EJLn9{;^>Zi{}b*Jj;*jin8K3z0pM#R3g*3b7bB<>Aaek#sH0OVXx LS3j3^P6height() ); + setFixedHeight( 18 ); m_xOffset -= s_posMarkerPixmap->width() / 2; @@ -250,10 +244,18 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) int x = m_xOffset + s_posMarkerPixmap->width() / 2 - ( ( static_cast( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast( m_ppt ) ); - p.setPen( QColor( 192, 192, 192 ) ); + QColor lineColor( 192, 192, 192 ); + QColor tactColor( lineColor.darker( 120 ) ); + + // Set font to half of the widgets size (in pixels) + QFont font = p.font(); + font.setPixelSize( this->height() * 0.5 ); + p.setFont( font ); + for( int i = 0; x + i * m_ppt < width(); ++i ) { const int cx = x + qRound( i * m_ppt ); + p.setPen( lineColor ); p.drawLine( cx, 5, cx, height() - 6 ); ++tact_num; if( ( tact_num - 1 ) % @@ -261,9 +263,10 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) MidiTime::ticksPerTact() / m_ppt ) ) == 0 ) { const QString s = QString::number( tact_num ); + p.setPen( tactColor ); p.drawText( cx + qRound( ( m_ppt - p.fontMetrics(). width( s ) ) / 2 ), - height() - p.fontMetrics().height() / 2, s ); + height() - p.fontMetrics().ascent() / 2, s ); } }