Skip to content

Commit

Permalink
Get rid of hardcoded colors in TCOs; Make TCO gradient configurable; …
Browse files Browse the repository at this point in the history
…Even out the color scheme
  • Loading branch information
Umcaruje committed Feb 16, 2016
1 parent 8841b89 commit 7d874fc
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 59 deletions.
23 changes: 21 additions & 2 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ PianoRoll {
qproperty-noteColor: rgb( 119, 199, 216 );
qproperty-noteBorderRadiusX: 5;
qproperty-noteBorderRadiusY: 2;
qproperty-selectedNoteColor: rgb( 0, 64, 192 );
qproperty-selectedNoteColor: rgb( 0, 125, 255 );
qproperty-barColor: #4afd85;
qproperty-markedSemitoneColor: rgba( 40, 40, 40, 200 );
/* Text on the white piano keys */
Expand Down Expand Up @@ -540,28 +540,47 @@ TrackContainerView QLabel
/* instrument pattern */
PatternView {
color: rgb( 119, 199, 216 );
qproperty-mutedColor: rgb( 80, 80, 80 );
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-fgColor: rgb( 187, 227, 236 );
qproperty-fgMutedColor: rgb( 128, 128, 128 );
qproperty-textColor: rgb( 255, 255, 255 );
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true;
}

/* sample track pattern */
SampleTCOView {
color: rgb( 74, 253, 133 );
qproperty-mutedColor: rgb( 80, 80, 80 );
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-fgColor: rgb( 187, 227, 236 );
qproperty-fgMutedColor: rgb( 128, 128, 128 );
qproperty-textColor: rgb( 255, 60, 60 );
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true;
}

/* automation pattern */
AutomationPatternView {
color: #99afff;
qproperty-fgColor: rgb( 204, 215, 255 );
qproperty-mutedColor: rgb( 80, 80, 80 );
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-fgColor: rgba( 204, 215, 255 );
qproperty-fgMutedColor: rgb( 128, 128, 128 );
qproperty-textColor: rgb( 255, 255, 255 );
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true;
}

/* bb-pattern */
BBTCOView {
color: rgb( 128, 182, 175 ); /* default colour for bb-tracks, used when the colour hasn't been defined by the user */
qproperty-mutedColor: rgb( 80, 80, 80 );
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-textColor: rgb( 255, 255, 255 );
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true;
}

/* Plugins */
Expand Down
20 changes: 20 additions & 0 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ class TrackContentObjectView : public selectableObject, public ModelView

// theming qproperties
Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor )
Q_PROPERTY( QColor fgMutedColor READ fgMutedColor WRITE setFgMutedColor )
Q_PROPERTY( QColor mutedColor READ mutedColor WRITE setMutedColor )
Q_PROPERTY( QColor selectedColor READ selectedColor WRITE setSelectedColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor )
Q_PROPERTY( bool gradient READ gradient WRITE setGradient )

public:
TrackContentObjectView( TrackContentObject * tco, TrackView * tv );
Expand All @@ -206,9 +211,19 @@ class TrackContentObjectView : public selectableObject, public ModelView
}
// qproperty access func
QColor fgColor() const;
QColor fgMutedColor() const;
QColor mutedColor() const;
QColor selectedColor() const;
QColor textColor() const;
QColor textShadowColor() const;
bool gradient() const;
void setFgColor( const QColor & c );
void setFgMutedColor( const QColor & c );
void setMutedColor( const QColor & c );
void setSelectedColor( const QColor & c );
void setTextColor( const QColor & c );
void setTextShadowColor( const QColor & c );
void setGradient( const bool & b );

public slots:
virtual bool close();
Expand Down Expand Up @@ -268,7 +283,12 @@ protected slots:

// qproperty fields
QColor m_fgColor;
QColor m_fgMutedColor;
QColor m_mutedColor;
QColor m_selectedColor;
QColor m_textColor;
QColor m_textShadowColor;
bool m_gradient;

inline void setInitialMousePos( QPoint pos )
{
Expand Down
54 changes: 44 additions & 10 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
m_initialMouseGlobalPos( QPoint( 0, 0 ) ),
m_hint( NULL ),
m_fgColor( 0, 0, 0 ),
m_textColor( 0, 0, 0 )
m_fgMutedColor( 0, 0, 0 ),
m_mutedColor( 0, 0, 0 ),
m_selectedColor( 0, 0, 0 ),
m_textColor( 0, 0, 0 ),
m_textShadowColor( 0, 0, 0 ),
m_gradient( true )
{
if( s_textFloat == NULL )
{
Expand All @@ -264,10 +269,10 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
setAttribute( Qt::WA_DeleteOnClose, true );
setFocusPolicy( Qt::StrongFocus );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
move( 0, 1 );
move( 0, 0 );
show();

setFixedHeight( tv->getTrackContentWidget()->height() - 2 );
setFixedHeight( tv->getTrackContentWidget()->height() - 1);
setAcceptDrops( true );
setMouseTracking( true );

Expand Down Expand Up @@ -322,18 +327,46 @@ bool TrackContentObjectView::fixedTCOs()
QColor TrackContentObjectView::fgColor() const
{ return m_fgColor; }

//! \brief CSS theming qproperty access method
QColor TrackContentObjectView::fgMutedColor() const
{ return m_fgMutedColor; }

QColor TrackContentObjectView::mutedColor() const
{ return m_mutedColor; }

QColor TrackContentObjectView::selectedColor() const
{ return m_selectedColor; }

QColor TrackContentObjectView::textColor() const
{ return m_textColor; }

QColor TrackContentObjectView::textShadowColor() const
{ return m_textShadowColor; }

bool TrackContentObjectView::gradient() const
{ return m_gradient; }

//! \brief CSS theming qproperty access method
void TrackContentObjectView::setFgColor( const QColor & c )
{ m_fgColor = QColor( c ); }

//! \brief CSS theming qproperty access method
void TrackContentObjectView::setFgMutedColor( const QColor & c )
{ m_fgMutedColor = QColor( c ); }

void TrackContentObjectView::setMutedColor( const QColor & c )
{ m_mutedColor = QColor( c ); }

void TrackContentObjectView::setSelectedColor( const QColor & c )
{ m_selectedColor = QColor( c ); }

void TrackContentObjectView::setTextColor( const QColor & c )
{ m_textColor = QColor( c ); }

void TrackContentObjectView::setTextShadowColor( const QColor & c )
{ m_textShadowColor = QColor( c ); }

void TrackContentObjectView::setGradient( const bool & b )
{ m_gradient = b; }


/*! \brief Close a trackContentObjectView
*
Expand Down Expand Up @@ -1047,11 +1080,8 @@ void TrackContentWidget::updateBackground()
pmp.fillRect( w, 0, w , h, lighterColor() );

// draw lines
pmp.setPen( QPen( gridColor(), 1 ) );
// horizontal line
pmp.drawLine( 0, h-1, w*2, h-1 );

// vertical lines
pmp.setPen( QPen( gridColor(), 1 ) );
for( float x = 0; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
Expand All @@ -1062,6 +1092,10 @@ void TrackContentWidget::updateBackground()
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
}

// horizontal line
pmp.setPen( QPen( gridColor(), 1 ) );
pmp.drawLine( 0, h-1, w*2, h-1 );

pmp.end();

Expand Down Expand Up @@ -1122,7 +1156,7 @@ void TrackContentWidget::update()
for( tcoViewVector::iterator it = m_tcoViews.begin();
it != m_tcoViews.end(); ++it )
{
( *it )->setFixedHeight( height() - 2 );
( *it )->setFixedHeight( height() - 1 );
( *it )->update();
}
QWidget::update();
Expand Down
50 changes: 31 additions & 19 deletions src/gui/AutomationPatternView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern,
this, SLOT( update() ) );

setAttribute( Qt::WA_OpaquePaintEvent, true );
setFixedHeight( parentWidget()->height() - 2 );

ToolTip::add( this, tr( "double-click to open this pattern in "
"automation editor" ) );
Expand Down Expand Up @@ -270,17 +269,22 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
if( !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) )
c = styleColor;
else
c = QColor( 80, 80, 80 );
c = mutedColor();

if( isSelected() == true )
{
c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
c = selectedColor();
}

lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );

p.setBrush( lingrad );

if ( gradient() ) {
p.setBrush( lingrad );
} else {
p.setBrush( c );
}

if( gui->automationEditor()->currentPattern() == m_pat )
p.setPen( c.lighter( 160 ) );
else
Expand Down Expand Up @@ -317,10 +321,17 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
p.scale( 1.0f, -h );

QLinearGradient lin2grad( 0, min, 0, max );
QColor col;

if( !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) ) {
col = fgColor();
} else {
col = fgMutedColor();
}

lin2grad.setColorAt( 1, fgColor().lighter( 150 ) );
lin2grad.setColorAt( 0.5, fgColor() );
lin2grad.setColorAt( 0, fgColor().darker( 150 ) );
lin2grad.setColorAt( 1, col.lighter( 150 ) );
lin2grad.setColorAt( 0.5, col );
lin2grad.setColorAt( 0, col.darker( 150 ) );

for( AutomationPattern::timeMap::const_iterator it =
m_pat->getTimeMap().begin();
Expand All @@ -332,9 +343,11 @@ 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 );
if ( gradient() ) {
p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ), lin2grad );
} else {
p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ), col );
}
break;
}

Expand All @@ -348,8 +361,11 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
MidiTime::ticksPerTact();
if( x1 > ( width() - TCO_BORDER_WIDTH ) ) break;

p.fillRect( QRectF( x1, 0.0f, x2-x1, value ),
lin2grad );
if ( gradient() ) {
p.fillRect( QRectF( x1, 0.0f, x2-x1, value ), lin2grad );
} else {
p.fillRect( QRectF( x1, 0.0f, x2-x1, value ), col );
}
}
delete [] values;
}
Expand All @@ -373,13 +389,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
// pattern name
p.setFont( pointSize<8>( p.font() ) );

QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() )
? QColor( 30, 30, 30 )
: textColor();

p.setPen( QColor( 0, 0, 0 ) );
p.setPen( textShadowColor() );
p.drawText( 4, p.fontMetrics().height()+1, m_pat->name() );
p.setPen( text_color );
p.setPen( textColor() );
p.drawText( 3, p.fontMetrics().height(), m_pat->name() );

if( m_pat->isMuted() )
Expand Down
13 changes: 8 additions & 5 deletions src/tracks/BBTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void BBTCOView::paintEvent( QPaintEvent * )
QColor col;
if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
{
col = QColor( 160, 160, 160 );
col = mutedColor();
}
else if ( m_bbTCO->m_useStyleColor )
{
Expand All @@ -233,14 +233,17 @@ void BBTCOView::paintEvent( QPaintEvent * )

if( isSelected() == true )
{
col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 );
col = selectedColor();
}

QLinearGradient lingrad( 0, 0, 0, height() );
lingrad.setColorAt( 0, col.light( 130 ) );
lingrad.setColorAt( 1, col.light( 70 ) );
p.fillRect( rect(), lingrad );

if ( gradient() ){
p.fillRect( rect(), lingrad );
} else {
p.fillRect( rect(), col );
}
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
Expand All @@ -263,7 +266,7 @@ void BBTCOView::paintEvent( QPaintEvent * )

p.setFont( pointSize<8>( p.font() ) );

p.setPen( QColor( 0, 0, 0 ) );
p.setPen( textShadowColor() );
p.drawText( 4, p.fontMetrics().height()+1, m_bbTCO->name() );
p.setPen( textColor() );
p.drawText( 3, p.fontMetrics().height(), m_bbTCO->name() );
Expand Down
Loading

0 comments on commit 7d874fc

Please sign in to comment.