Skip to content

Commit

Permalink
Use font properties from CSS to draw the pattern labels
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelgregorius committed Jul 11, 2017
1 parent c0a4f67 commit a70d255
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ TrackContentObjectView {
PatternView {
background-color: rgb( 119, 199, 216 );
color: rgb( 187, 227, 236 );
font-size: 11px;
}

/* sample track pattern */
Expand Down
1 change: 1 addition & 0 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ TrackContentObjectView {
PatternView {
background-color: #21A14F;
color: rgba(255,255,255,220);
font-size: 11px;
}

/* sample track pattern */
Expand Down
11 changes: 5 additions & 6 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit a70d255

Please sign in to comment.