From e7b097d25519f6dfea8ef8db583096ee7499d7d5 Mon Sep 17 00:00:00 2001 From: Vesa Date: Tue, 25 Feb 2014 21:28:08 +0200 Subject: [PATCH 1/3] Define all pattern colours in CSS and make them stylable also coding style improvements (remove leading underscores from header guards) --- data/themes/default/style.css | 17 +++++++++++++++++ include/AutomationPattern.h | 6 +++--- include/AutomationPatternView.h | 4 ++-- include/AutomationTrack.h | 4 ++-- include/SampleTrack.h | 4 ++-- include/bb_track.h | 6 +++--- include/pattern.h | 4 ++-- include/track.h | 4 ++-- src/core/TrackContainer.cpp | 2 +- src/core/track.cpp | 6 +++--- src/gui/AutomationPatternView.cpp | 11 +++++++---- src/tracks/SampleTrack.cpp | 3 ++- src/tracks/pattern.cpp | 11 +++++++---- 13 files changed, 53 insertions(+), 29 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 2d7a22b2a..2bd7ad126 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -467,6 +467,23 @@ TrackContainerView QLabel background: none; } +/* Patterns */ + +/* instrument pattern */ +patternView { + color: rgb( 119, 199, 216 ); +} + +/* sample track pattern */ +SampleTCOView { + color: rgb( 74, 253, 133 ); +} + +/* automation pattern */ +AutomationPatternView { + color: #99afff; +} + /* Plugins */ TripleOscillatorView knob { diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 2eaaeba4d..8f9869f33 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -4,7 +4,7 @@ * * Copyright (c) 2008-2013 Tobias Doerffel * Copyright (c) 2006-2008 Javier Serrano Polo - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -24,8 +24,8 @@ * */ -#ifndef _AUTOMATION_PATTERN_H -#define _AUTOMATION_PATTERN_H +#ifndef AUTOMATION_PATTERN_H +#define AUTOMATION_PATTERN_H #include diff --git a/include/AutomationPatternView.h b/include/AutomationPatternView.h index 4fec18513..5d8bed1d4 100644 --- a/include/AutomationPatternView.h +++ b/include/AutomationPatternView.h @@ -22,8 +22,8 @@ * */ -#ifndef _AUTOMATION_PATTERN_VIEW_H -#define _AUTOMATION_PATTERN_VIEW_H +#ifndef AUTOMATION_PATTERN_VIEW_H +#define AUTOMATION_PATTERN_VIEW_H #include "track.h" diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index a4c44b302..d6af755a3 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -24,8 +24,8 @@ * */ -#ifndef _AUTOMATION_TRACK_H -#define _AUTOMATION_TRACK_H +#ifndef AUTOMATION_TRACK_H +#define AUTOMATION_TRACK_H #include "track.h" diff --git a/include/SampleTrack.h b/include/SampleTrack.h index fed785657..2afd9285b 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -22,8 +22,8 @@ * */ -#ifndef _SAMPLE_TRACK_H -#define _SAMPLE_TRACK_H +#ifndef SAMPLE_TRACK_H +#define SAMPLE_TRACK_H #include diff --git a/include/bb_track.h b/include/bb_track.h index c436477bf..d951ea963 100644 --- a/include/bb_track.h +++ b/include/bb_track.h @@ -3,7 +3,7 @@ * (which is a singleton-class) as track * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -24,8 +24,8 @@ */ -#ifndef _BB_TRACK_H -#define _BB_TRACK_H +#ifndef BB_TRACK_H +#define BB_TRACK_H #include #include diff --git a/include/pattern.h b/include/pattern.h index 71dc5606c..017a18ea9 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -23,8 +23,8 @@ * */ -#ifndef _PATTERN_H -#define _PATTERN_H +#ifndef PATTERN_H +#define PATTERN_H #include #include diff --git a/include/track.h b/include/track.h index 506e1ece6..5fc92f2f2 100644 --- a/include/track.h +++ b/include/track.h @@ -23,8 +23,8 @@ * */ -#ifndef _TRACK_H -#define _TRACK_H +#ifndef TRACK_H +#define TRACK_H #include #include diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index b2cb5df2a..c2430918e 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -3,7 +3,7 @@ * like Song-Editor, BB-Editor... * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or diff --git a/src/core/track.cpp b/src/core/track.cpp index f2d4b3a3d..3d0c563d5 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -913,7 +913,7 @@ void trackContentWidget::updateBackground() pmp.setPen( QPen( QColor( 0, 0, 0, 160 ), 1 ) ); // horizontal line pmp.drawLine( 0, 0, w*2, 0 ); - + // vertical lines for( float x = 0; x < w * 2; x += ppt ) { @@ -1850,7 +1850,7 @@ trackContentObject * track::getTCO( int _tco_num ) printf( "called track::getTCO( %d ), " "but TCO %d doesn't exist\n", _tco_num, _tco_num ); return createTCO( _tco_num * MidiTime::ticksPerTact() ); - + } @@ -2220,7 +2220,7 @@ void trackView::modelChanged() connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) ); m_trackOperationsWidget.m_muteBtn->setModel( &m_track->m_mutedModel ); m_trackOperationsWidget.m_soloBtn->setModel( &m_track->m_soloModel ); - ModelView::modelChanged(); + ModelView::modelChanged(); setFixedHeight( m_track->getHeight() ); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 85a424018..f868a071a 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -55,6 +55,7 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, toolTip::add( this, tr( "double-click to open this pattern in " "automation editor" ) ); + setStyle( QApplication::style() ); } @@ -203,6 +204,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) return; } + QPainter _p( this ); + const QColor styleColor = _p.pen().brush().color(); + m_needsUpdate = false; if( m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ) @@ -216,7 +220,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) QColor c; if( !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) ) c = isSelected() ? QColor( 0, 0, 224 ) - : QColor( 0x99, 0xAF, 0xFF ); + : styleColor; //QColor( 0x99, 0xAF, 0xFF ); else c = QColor( 80,80,80 ); @@ -274,7 +278,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) 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; @@ -317,8 +321,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) p.end(); - p.begin( this ); - p.drawPixmap( 0, 0, m_paintPixmap ); + _p.drawPixmap( 0, 0, m_paintPixmap ); } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 0afa7c015..8525f7905 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -328,11 +328,12 @@ void SampleTCOView::mouseDoubleClickEvent( QMouseEvent * ) void SampleTCOView::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); + const QColor styleColor = p.pen().brush().color(); QColor c; if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) ) c = isSelected() ? QColor( 0, 0, 224 ) - : QColor( 74, 253, 133 ); + : styleColor; //QColor( 74, 253, 133 ); else c = QColor( 80, 80, 80 ); QLinearGradient grad( 0, 0, 0, height() ); diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 2aed9670e..76476d365 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -819,6 +819,9 @@ void patternView::paintEvent( QPaintEvent * ) return; } + QPainter _p( this ); + const QColor styleColor = _p.pen().brush().color(); + m_pat->changeLength( m_pat->length() ); m_needsUpdate = false; @@ -837,7 +840,7 @@ void patternView::paintEvent( QPaintEvent * ) if(( m_pat->m_patternType != pattern::BeatPattern ) && !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) c = isSelected() ? QColor( 0, 0, 224 ) - : QColor( 119, 199, 216 ); + : styleColor;//QColor( 119, 199, 216 ); else c = QColor( 80, 80, 80 ); @@ -851,7 +854,7 @@ void patternView::paintEvent( QPaintEvent * ) lingrad.setColorAt( 0, c.darker( 300 ) ); lingrad.setColorAt( 1, c ); } - + p.setBrush( lingrad ); p.setPen( c.darker( 300 ) ); p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) ); @@ -1025,8 +1028,8 @@ void patternView::paintEvent( QPaintEvent * ) p.end(); - p.begin( this ); - p.drawPixmap( 0, 0, m_paintPixmap ); +// p.begin( this ); + _p.drawPixmap( 0, 0, m_paintPixmap ); } From 103ac21922f9358595a317910c6cc288bc0a00a9 Mon Sep 17 00:00:00 2001 From: Vesa Date: Tue, 25 Feb 2014 21:35:01 +0200 Subject: [PATCH 2/3] Some cleanup (remove temporary comments) --- src/gui/AutomationPatternView.cpp | 2 +- src/tracks/SampleTrack.cpp | 2 +- src/tracks/pattern.cpp | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index f868a071a..98a36cf62 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -220,7 +220,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) QColor c; if( !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) ) c = isSelected() ? QColor( 0, 0, 224 ) - : styleColor; //QColor( 0x99, 0xAF, 0xFF ); + : styleColor; else c = QColor( 80,80,80 ); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 8525f7905..274010bce 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -333,7 +333,7 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe ) QColor c; if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) ) c = isSelected() ? QColor( 0, 0, 224 ) - : styleColor; //QColor( 74, 253, 133 ); + : styleColor; else c = QColor( 80, 80, 80 ); QLinearGradient grad( 0, 0, 0, height() ); diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 76476d365..cbbd63d7d 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -840,7 +840,7 @@ void patternView::paintEvent( QPaintEvent * ) if(( m_pat->m_patternType != pattern::BeatPattern ) && !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) c = isSelected() ? QColor( 0, 0, 224 ) - : styleColor;//QColor( 119, 199, 216 ); + : styleColor; else c = QColor( 80, 80, 80 ); @@ -1028,7 +1028,6 @@ void patternView::paintEvent( QPaintEvent * ) p.end(); -// p.begin( this ); _p.drawPixmap( 0, 0, m_paintPixmap ); } From a89b131ecab1aadc7a9b1bc71d07fe49996c3bbf Mon Sep 17 00:00:00 2001 From: Vesa Date: Tue, 25 Feb 2014 23:35:46 +0200 Subject: [PATCH 3/3] Fix a bug where copied instrument tracks appear grey --- src/tracks/SampleTrack.cpp | 2 ++ src/tracks/pattern.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 274010bce..17d979336 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -202,6 +202,8 @@ SampleTCOView::SampleTCOView( SampleTCO * _tco, trackView * _tv ) : // track future changes of SampleTCO connect( m_tco, SIGNAL( sampleChanged() ), this, SLOT( updateSample() ) ); + + setStyle( QApplication::style() ); } diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index cbbd63d7d..ff2e2a680 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -594,6 +594,7 @@ patternView::patternView( pattern * _pattern, trackView * _parent ) : toolTip::add( this, tr( "double-click to open this pattern in piano-roll\n" "use mouse wheel to set volume of a step" ) ); + setStyle( QApplication::style() ); }