TCOView: Make patternviews foreground elements stylable with qproperties

This commit is contained in:
Vesa
2014-04-05 17:22:45 +03:00
parent 3bcffcdf5b
commit 994dcd3964
9 changed files with 79 additions and 15 deletions

View File

@@ -249,7 +249,9 @@ trackContentObjectView::trackContentObjectView( trackContentObject * _tco,
m_action( NoAction ),
m_autoResize( false ),
m_initialMouseX( 0 ),
m_hint( NULL )
m_hint( NULL ),
m_fgColor( NULL ),
m_textColor( NULL )
{
if( s_textFloat == NULL )
{
@@ -275,6 +277,9 @@ trackContentObjectView::trackContentObjectView( trackContentObject * _tco,
connect( m_tco, SIGNAL( destroyedTCO() ), this, SLOT( close() ) );
setModel( m_tco );
setFgColor( QColor( 0,0,0 ) );
setTextColor( QColor( 0,0,0 ) );
m_trackView->getTrackContentWidget()->addTCOView( this );
}
@@ -314,6 +319,23 @@ bool trackContentObjectView::fixedTCOs()
// qproperty access functions, to be inherited & used by TCOviews
//! \brief CSS theming qproperty access method
QColor trackContentObjectView::fgColor() const
{ if( m_fgColor ) return *m_fgColor; else return QColor( 0,0,0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentObjectView::textColor() const
{ if( m_textColor ) return *m_textColor; else return QColor( 0,0,0 ); }
//! \brief CSS theming qproperty access method
void trackContentObjectView::setFgColor( const QColor & _c )
{ if( m_fgColor ) *m_fgColor = _c; else m_fgColor = new QColor( 0,0,0 ); }
//! \brief CSS theming qproperty access method
void trackContentObjectView::setTextColor( const QColor & _c )
{ if( m_textColor ) *m_textColor = _c; else m_textColor = new QColor( 0,0,0 ); }
/*! \brief Close a trackContentObjectView
*
@@ -1213,46 +1235,59 @@ MidiTime trackContentWidget::endPosition( const MidiTime & _pos_start )
// qproperty access methods
//! \brief CSS theming qproperty access method
QColor trackContentWidget::darkerColor1() const
{ if( m_darkerColor1 ) return *m_darkerColor1; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentWidget::darkerColor2() const
{ if( m_darkerColor2 ) return *m_darkerColor2; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentWidget::darkerColor3() const
{ if( m_darkerColor3 ) return *m_darkerColor3; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentWidget::lighterColor1() const
{ if( m_lighterColor1 ) return *m_lighterColor1; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentWidget::lighterColor2() const
{ if( m_lighterColor2 ) return *m_lighterColor2; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
QColor trackContentWidget::lighterColor3() const
{ if( m_lighterColor3 ) return *m_lighterColor3; else return QColor( 0, 0, 0 ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setDarkerColor1( const QColor & _c )
{ if( m_darkerColor1 ) *m_darkerColor1 = _c; else m_darkerColor1 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setDarkerColor2( const QColor & _c )
{ if( m_darkerColor2 ) *m_darkerColor2 = _c; else m_darkerColor2 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setDarkerColor3( const QColor & _c )
{ if( m_darkerColor3 ) *m_darkerColor3 = _c; else m_darkerColor3 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setLighterColor1( const QColor & _c )
{ if( m_lighterColor1 ) *m_lighterColor1 = _c; else m_lighterColor1 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setLighterColor2( const QColor & _c )
{ if( m_lighterColor2 ) *m_lighterColor2 = _c; else m_lighterColor2 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
void trackContentWidget::setLighterColor3( const QColor & _c )
{ if( m_lighterColor3 ) *m_lighterColor3 = _c; else m_lighterColor3 = new QColor( _c ); }
//! \brief CSS theming qproperty access method
float trackContentWidget::gradMidPoint() const
{ return m_gradMidPoint; }
//! \brief CSS theming qproperty access method
void trackContentWidget::setGradMidPoint( float _g )
{ m_gradMidPoint = _g; }

View File

@@ -273,8 +273,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
QLinearGradient lin2grad( 0, min, 0, max );
lin2grad.setColorAt( 1, c.lighter( 200 ) );
lin2grad.setColorAt( 0, c );
lin2grad.setColorAt( 1, fgColor().lighter( 150 ) );
lin2grad.setColorAt( 0.5, fgColor() );
lin2grad.setColorAt( 0, fgColor().darker( 150 ) );
for( AutomationPattern::timeMap::const_iterator it =
m_pat->getTimeMap().begin();
@@ -313,7 +314,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() )
? QColor( 30, 30, 30 )
: QColor( 255, 255, 255 );
: textColor();
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 4, p.fontMetrics().height()+1, m_pat->name() );

View File

@@ -358,7 +358,7 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
}
else
{
p.setPen( c.lighter( 200 ) );
p.setPen( fgColor() );
}
QRect r = QRect( 1, 1,
qMax( static_cast<int>( m_tco->sampleLength() *
@@ -383,10 +383,10 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 10, p.fontMetrics().height()+1, "Rec" );
p.setPen( QColor( 255, 60, 60 ) );
p.setPen( textColor() );
p.drawText( 9, p.fontMetrics().height(), "Rec" );
p.setBrush( QBrush( QColor( 255, 60, 60 ) ) );
p.setBrush( QBrush( textColor() ) );
p.drawEllipse( 4, 5, 4, 4 );
}
}

View File

@@ -1019,7 +1019,7 @@ void patternView::paintEvent( QPaintEvent * )
}
else
{
p.setPen( QColor( 255, 255, 255 ) ); /// \todo make this a qproperty
p.setPen( fgColor() );
}
// scan through all the notes and draw them on the pattern
@@ -1133,7 +1133,7 @@ void patternView::paintEvent( QPaintEvent * )
QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() )
? QColor( 30, 30, 30 )
: QColor( 255, 255, 255 );
: textColor();
if( m_pat->name() != m_pat->instrumentTrack()->name() )
{