From 994dcd3964d0f6c7d6049dc07fb6cbaa7f18aa2b Mon Sep 17 00:00:00 2001 From: Vesa Date: Sat, 5 Apr 2014 17:22:45 +0300 Subject: [PATCH] TCOView: Make patternviews foreground elements stylable with qproperties --- data/themes/default/style.css | 6 +++++ include/AutomationPatternView.h | 7 ++++-- include/SampleTrack.h | 6 ++++- include/pattern.h | 5 +++- include/track.h | 14 ++++++++++- src/core/track.cpp | 39 +++++++++++++++++++++++++++++-- src/gui/AutomationPatternView.cpp | 7 +++--- src/tracks/SampleTrack.cpp | 6 ++--- src/tracks/pattern.cpp | 4 ++-- 9 files changed, 79 insertions(+), 15 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index ff340bf9d..66f4f7cb0 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -484,16 +484,22 @@ TrackContainerView QLabel /* instrument pattern */ patternView { color: rgb( 119, 199, 216 ); + qproperty-fgColor: rgb( 187, 227, 236 ); + qproperty-textColor: rgb( 255, 255, 255 ); } /* sample track pattern */ SampleTCOView { color: rgb( 74, 253, 133 ); + qproperty-fgColor: rgb( 187, 227, 236 ); + qproperty-textColor: rgb( 255, 60, 60 ); } /* automation pattern */ AutomationPatternView { color: #99afff; + qproperty-fgColor: rgb( 204, 215, 255 ); + qproperty-textColor: rgb( 255, 255, 255 ); } /* Plugins */ diff --git a/include/AutomationPatternView.h b/include/AutomationPatternView.h index 5d8bed1d4..73b2a7d9e 100644 --- a/include/AutomationPatternView.h +++ b/include/AutomationPatternView.h @@ -33,11 +33,15 @@ class AutomationPattern; class AutomationPatternView : public trackContentObjectView { Q_OBJECT + +// theming qproperties + Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor ) + Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) + public: AutomationPatternView( AutomationPattern * _pat, trackView * _parent ); virtual ~AutomationPatternView(); - public slots: virtual void update(); @@ -67,7 +71,6 @@ private: bool m_needsUpdate; void scaleTimemapToFit( float oldMin, float oldMax ); - } ; diff --git a/include/SampleTrack.h b/include/SampleTrack.h index 2afd9285b..a2e8f5b75 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -88,6 +88,11 @@ signals: class SampleTCOView : public trackContentObjectView { Q_OBJECT + +// theming qproperties + Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor ) + Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) + public: SampleTCOView( SampleTCO * _tco, trackView * _tv ); virtual ~SampleTCOView(); @@ -108,7 +113,6 @@ protected: private: SampleTCO * m_tco; - } ; diff --git a/include/pattern.h b/include/pattern.h index c3985ff7c..2fff9697e 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -147,6 +147,10 @@ private: class patternView : public trackContentObjectView { Q_OBJECT + +// theming qproperties + Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor ) + Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) public: patternView( pattern * _pattern, trackView * _parent ); virtual ~patternView(); @@ -185,7 +189,6 @@ private: pattern * m_pat; QPixmap m_paintPixmap; bool m_needsUpdate; - } ; diff --git a/include/track.h b/include/track.h index abd760f79..f1baa570d 100644 --- a/include/track.h +++ b/include/track.h @@ -163,6 +163,11 @@ private: class trackContentObjectView : public selectableObject, public ModelView { Q_OBJECT + +// theming qproperties + Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor ) + Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor ) + public: trackContentObjectView( trackContentObject * _tco, trackView * _tv ); virtual ~trackContentObjectView(); @@ -173,7 +178,11 @@ public: { return m_tco; } - +// qproperty access func + QColor fgColor() const; + QColor textColor() const; + void setFgColor( const QColor & _c ); + void setTextColor( const QColor & _c ); public slots: virtual bool close(); @@ -228,6 +237,9 @@ private: MidiTime m_oldTime;// used for undo/redo while mouse-button is pressed +// qproperty fields + QColor * m_fgColor; + QColor * m_textColor; } ; diff --git a/src/core/track.cpp b/src/core/track.cpp index b0335f0df..0f2dabc4f 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -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; } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 9cec7920c..baa19376c 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -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() ); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index a886b5303..e71479ad4 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -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( 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 ); } } diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index c1022d991..6310eb7b7 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -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() ) {