From 0a27bc180e14871d5ef376d7b9073da520e126db Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Fri, 21 Jul 2017 19:35:20 +0200 Subject: [PATCH] Expose properties for note border color and fill color to style sheets Expose properties to set the colors for note borders and note fills for patterns to the style sheets. Both properties are exposed for the muted and not muted case. Use these new properties during rendering. Adjust the style sheets for the classic and default theme. --- data/themes/classic/style.css | 5 +++++ data/themes/default/style.css | 5 +++++ include/Pattern.h | 21 +++++++++++++++++++++ src/tracks/Pattern.cpp | 17 +++++++++++------ 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 4b8132278..1ace5a8e8 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -624,6 +624,11 @@ TrackContentObjectView { PatternView { background-color: rgb( 119, 199, 216 ); color: rgb( 187, 227, 236 ); + + qproperty-noteFillColor: rgb( 187, 227, 236 ); + qproperty-noteBorderColor: rgb( 119, 199, 216 ); + qproperty-mutedNoteFillColor: rgb( 128, 128, 128 ); + qproperty-mutedNoteBorderColor: rgb( 80, 80, 80 ); } /* sample track pattern */ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 109b1a68d..73f7547b7 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -631,6 +631,11 @@ TrackContentObjectView { PatternView { background-color: #21A14F; color: rgba(255,255,255,220); + + qproperty-noteFillColor: rgba(255, 255, 255, 220); + qproperty-noteBorderColor: rgb(33, 161, 79); + qproperty-mutedNoteFillColor: rgba(100, 100, 100, 220); + qproperty-mutedNoteBorderColor: rgb(55, 61, 72); } /* sample track pattern */ diff --git a/include/Pattern.h b/include/Pattern.h index 41b76553c..189631412 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -165,6 +165,22 @@ public: PatternView( Pattern* pattern, TrackView* parent ); virtual ~PatternView(); + Q_PROPERTY(QColor noteFillColor READ getNoteFillColor WRITE setNoteFillColor) + Q_PROPERTY(QColor noteBorderColor READ getNoteBorderColor WRITE setNoteBorderColor) + Q_PROPERTY(QColor mutedNoteFillColor READ getMutedNoteFillColor WRITE setMutedNoteFillColor) + Q_PROPERTY(QColor mutedNoteBorderColor READ getMutedNoteBorderColor WRITE setMutedNoteBorderColor) + + QColor const & getNoteFillColor() const { return m_noteFillColor; } + void setNoteFillColor(QColor const & color) { m_noteFillColor = color; } + + QColor const & getNoteBorderColor() const { return m_noteBorderColor; } + void setNoteBorderColor(QColor const & color) { m_noteBorderColor = color; } + + QColor const & getMutedNoteFillColor() const { return m_mutedNoteFillColor; } + void setMutedNoteFillColor(QColor const & color) { m_mutedNoteFillColor = color; } + + QColor const & getMutedNoteBorderColor() const { return m_mutedNoteBorderColor; } + void setMutedNoteBorderColor(QColor const & color) { m_mutedNoteBorderColor = color; } public slots: virtual void update(); @@ -194,6 +210,11 @@ private: Pattern* m_pat; QPixmap m_paintPixmap; + QColor m_noteFillColor; + QColor m_noteBorderColor; + QColor m_mutedNoteFillColor; + QColor m_mutedNoteBorderColor; + QStaticText m_staticTextName; } ; diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 58737503e..19ed99d7f 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -599,7 +599,11 @@ void Pattern::changeTimeSignature() PatternView::PatternView( Pattern* pattern, TrackView* parent ) : TrackContentObjectView( pattern, parent ), m_pat( pattern ), - m_paintPixmap() + m_paintPixmap(), + m_noteFillColor(255, 255, 255, 220), + m_noteBorderColor(255, 255, 255, 220), + m_mutedNoteFillColor(100, 100, 100, 220), + m_mutedNoteBorderColor(100, 100, 100, 220) { connect( gui->pianoRoll(), SIGNAL( currentPatternChanged() ), this, SLOT( update() ) ); @@ -910,9 +914,9 @@ void PatternView::paintEvent( QPaintEvent * ) bool const isDefaultName = m_pat->name() == m_pat->instrumentTrack()->name(); bool const drawTextBox = !beatPattern && !isDefaultName; + // TODO Warning! This might cause problems if TrackContentObjectView::paintTextLabel changes int textBoxHeight = 0; const int textTop = TCO_BORDER_WIDTH + 1; - const int textLeft = TCO_BORDER_WIDTH + 3; if (drawTextBox) { QFont labelFont = this->font(); @@ -997,16 +1001,17 @@ void PatternView::paintEvent( QPaintEvent * ) p.scale(width(), height() - distanceToTop - 2 * notesBorder); // set colour based on mute status - QColor const noteColor = muted ? mutedColor() : painter.pen().brush().color(); + QColor noteFillColor = muted ? getMutedNoteFillColor() : getNoteFillColor(); + QColor noteBorderColor = muted ? getMutedNoteBorderColor() : getNoteBorderColor(); bool const drawAsLines = height() < 64; if (drawAsLines) { - p.setPen( noteColor ); + p.setPen(noteFillColor); } else { - p.setPen( noteColor.darker() ); + p.setPen(noteBorderColor); p.setRenderHint(QPainter::Antialiasing); } @@ -1038,7 +1043,7 @@ void PatternView::paintEvent( QPaintEvent * ) } else { - p.fillRect( noteRectF, noteColor ); + p.fillRect( noteRectF, noteFillColor ); p.drawRect( noteRectF ); } }