From a70d25541897f7bc513265e28a79c250aa297b17 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Mon, 10 Jul 2017 18:40:02 +0200 Subject: [PATCH] Use font properties from CSS to draw the pattern labels Use the font properties that are defined in the CSS to draw the pattern labels. This provides flexibility with regards to the font properties that are used (size, font family, etc.). Adjust the CSS for the default theme and the classic theme. --- data/themes/classic/style.css | 1 + data/themes/default/style.css | 1 + src/tracks/Pattern.cpp | 11 +++++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 03e24ebcf..63d72e94a 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -596,6 +596,7 @@ TrackContentObjectView { PatternView { background-color: rgb( 119, 199, 216 ); color: rgb( 187, 227, 236 ); + font-size: 11px; } /* sample track pattern */ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 035ed7a5f..7e96d8ba0 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -615,6 +615,7 @@ TrackContentObjectView { PatternView { background-color: #21A14F; color: rgba(255,255,255,220); + font-size: 11px; } /* sample track pattern */ diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index d4780f2b7..720a2bf6a 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -1076,15 +1076,14 @@ void PatternView::paintEvent( QPaintEvent * ) { p.setRenderHint( QPainter::TextAntialiasing ); - QFont font; - font.setHintingPreference( QFont::PreferFullHinting ); - font.setPointSize( 8 ); - p.setFont( font ); + QFont labelFont = this->font(); + labelFont.setHintingPreference( QFont::PreferFullHinting ); + p.setFont( labelFont ); const int textTop = TCO_BORDER_WIDTH + 1; const int textLeft = TCO_BORDER_WIDTH + 3; - QFontMetrics fontMetrics(font); + QFontMetrics fontMetrics(labelFont); QString elidedPatternName = fontMetrics.elidedText(m_pat->name(), Qt::ElideMiddle, width() - 2 * textLeft); QColor transparentBlack(0, 0, 0, 75); @@ -1110,7 +1109,7 @@ void PatternView::paintEvent( QPaintEvent * ) p.setPen( ( current && !beatPattern ) ? c.lighter( 130 ) : c.darker( 300 ) ); p.drawRect( 0, 0, rect().right(), rect().bottom() ); } - // draw the 'muted' pixmap only if the pattern was manualy muted + // draw the 'muted' pixmap only if the pattern was manually muted if( m_pat->isMuted() ) { const int spacing = TCO_BORDER_WIDTH;