From f19e6401cdb506a002f4cef8f73d10810c41e296 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Sun, 2 Sep 2018 17:21:35 +0200 Subject: [PATCH 1/9] * Added basic ghost notes feature. * Changed `int m_noteOpacity` to `unsigned char m_noteOpacity` (aslo converted the relative functions (`noteOpacity` and `setNoteOpacity`) to `unsigned char`) since the maximum value will be 255 and minimum 0. --- data/themes/classic/clear_ghost_note.png | Bin 0 -> 1088 bytes data/themes/classic/ghost_note.png | Bin 0 -> 452 bytes data/themes/classic/style.css | 4 + data/themes/default/clear_ghost_note.png | Bin 0 -> 1088 bytes data/themes/default/ghost_note.png | Bin 0 -> 452 bytes data/themes/default/style.css | 4 + include/Pattern.h | 1 + include/PianoRoll.h | 32 +++++-- src/gui/editors/PianoRoll.cpp | 109 ++++++++++++++++++++++- src/tracks/Pattern.cpp | 25 +++++- 10 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 data/themes/classic/clear_ghost_note.png create mode 100644 data/themes/classic/ghost_note.png create mode 100644 data/themes/default/clear_ghost_note.png create mode 100644 data/themes/default/ghost_note.png diff --git a/data/themes/classic/clear_ghost_note.png b/data/themes/classic/clear_ghost_note.png new file mode 100644 index 0000000000000000000000000000000000000000..c9f85a2b4ab54a5b206823b56116d87a6936d8d7 GIT binary patch literal 1088 zcmV-G1i$-3$EDcV9eqd5WEs3QhATg7e zc0n;HX;{@=1r}{+L!Gjz57bm5h1jGiNt+Ud5H`>zf+kvH7h)rADUueNG8qs=s1}@z z<1o(0J6$l7j8nn(zqz^Zob!9YD9yShY&g@3_2!J@-Ye@#xta)ToBu83ra zNVAAU5?FUd%TV9sqDJi1ESZpjBfEPY^Zujoja(3;Cy{la*^_5b}tCZ>hdgJ=| zP$`uIqyc}dx?FUZln@C90ZM@;0Mn#V0 z%Bsr+z_Ud~f8U#)7Qm@Pw-$sNz*baSI~@noMZ^psA~xW?=yOd(>e^r*FtO@#Rj8yS z_8mJ${lvsL@Ht=uYD@yvz*>HJ`J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1styKUsx^ zoAm)8rfBO0z-)XZ=<_jf-~h8%uc9=Kilawyw6&onCqE6k4Y*?heg_h0wPhvR8L^mS++Fr+Cs57_2MN9_`caH+YOugl5^`Te|d@F0yh zZ~iA}R5gH7a9%}!5ciAw_eVT#clLd^n`En%H#U}@>>_fF@-$===^U(hxNG85){u z=mSVweSwCCYH)6}1`!(q8;aJ#QCu8)(UKxauHGdwqG zfCaq7CVrG}6ECpP_SeQqymdO(aiuj+V`l(!A3M0-H;>@U5avEU<9zU-5IsD^n4@vt zG=@)D#bL$W58jtzr5Wo24vO}y;uoucjbN`7&zpb_z7=i0(S8tMPxpU;%&rHDGy|fbI#} zyCiF;_&)~UF@@b``)=a~ewTWy(zeT m_zoomLevels; Pattern* m_pattern; + Pattern* m_ghostPattern; QScrollBar * m_leftRightScroll; QScrollBar * m_topBottomScroll; @@ -388,14 +404,18 @@ protected slots: QColor m_noteModeColor; QColor m_noteColor; QColor m_noteTextColor; + QColor m_ghostNoteColor; + QColor m_ghostNoteTextColor; QColor m_barColor; QColor m_selectedNoteColor; QColor m_textColor; QColor m_textColorLight; QColor m_textShadow; QColor m_markedSemitoneColor; - int m_noteOpacity; + unsigned char m_noteOpacity; + unsigned char m_ghostNoteOpacity; bool m_noteBorders; + bool m_ghostNoteBorders; QColor m_backgroundShade; signals: @@ -412,7 +432,8 @@ class PianoRollWindow : public Editor, SerializingObject PianoRollWindow(); const Pattern* currentPattern() const; - void setCurrentPattern(Pattern* pattern); + void setCurrentPattern( Pattern* pattern ); + void setGhostPattern( Pattern* newPattern ); int quantization() const; @@ -456,6 +477,7 @@ private slots: ComboBox * m_noteLenComboBox; ComboBox * m_scaleComboBox; ComboBox * m_chordComboBox; + QPushButton * m_clearGhostButton; }; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index e5f6458b55e..3b11db3989c 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -182,6 +182,8 @@ PianoRoll::PianoRoll() : m_lineColor( 0, 0, 0 ), m_noteModeColor( 0, 0, 0 ), m_noteColor( 0, 0, 0 ), + m_ghostNoteColor( 0, 0, 0 ), + m_ghostNoteTextColor( 0, 0, 0 ), m_barColor( 0, 0, 0 ), m_selectedNoteColor( 0, 0, 0 ), m_textColor( 0, 0, 0 ), @@ -189,7 +191,9 @@ PianoRoll::PianoRoll() : m_textShadow( 0, 0, 0 ), m_markedSemitoneColor( 0, 0, 0 ), m_noteOpacity( 255 ), + m_ghostNoteOpacity( 255 ), m_noteBorders( true ), + m_ghostNoteBorders( true ), m_backgroundShade( 0, 0, 0 ) { // gui names of edit modes @@ -599,6 +603,19 @@ PianoRoll::~PianoRoll() } +void PianoRoll::setGhostPattern( Pattern* newPattern ) +{ + m_ghostPattern = newPattern; +} + + +void PianoRoll::clearGhostPattern() +{ + setGhostPattern( nullptr ); + update(); +} + + void PianoRoll::setCurrentPattern( Pattern* newPattern ) { if( hasValidPattern() ) @@ -789,10 +806,10 @@ QColor PianoRoll::markedSemitoneColor() const void PianoRoll::setMarkedSemitoneColor( const QColor & c ) { m_markedSemitoneColor = c; } -int PianoRoll::noteOpacity() const +unsigned char PianoRoll::noteOpacity() const { return m_noteOpacity; } -void PianoRoll::setNoteOpacity( const int i ) +void PianoRoll::setNoteOpacity( const unsigned char i ) { m_noteOpacity = i; } bool PianoRoll::noteBorders() const @@ -801,6 +818,30 @@ bool PianoRoll::noteBorders() const void PianoRoll::setNoteBorders( const bool b ) { m_noteBorders = b; } +QColor PianoRoll::ghostNoteColor() const +{ return m_ghostNoteColor; } + +void PianoRoll::setGhostNoteColor( const QColor & c ) +{ m_ghostNoteColor = c; } + +QColor PianoRoll::ghostNoteTextColor() const +{ return m_ghostNoteTextColor; } + +void PianoRoll::setGhostNoteTextColor( const QColor & c ) +{ m_ghostNoteTextColor = c; } + +unsigned char PianoRoll::ghostNoteOpacity() const +{ return m_ghostNoteOpacity; } + +void PianoRoll::setGhostNoteOpacity( const unsigned char i ) +{ m_ghostNoteOpacity = i; } + +bool PianoRoll::ghostNoteBorders() const +{ return m_ghostNoteBorders; } + +void PianoRoll::setGhostNoteBorders( const bool b ) +{ m_ghostNoteBorders = b; } + QColor PianoRoll::backgroundShade() const { return m_backgroundShade; } @@ -810,7 +851,6 @@ void PianoRoll::setBackgroundShade( const QColor & c ) - void PianoRoll::drawNoteRect( QPainter & p, int x, int y, int width, const Note * n, const QColor & noteCol, const QColor & noteTextColor, const QColor & selCol, const int noteOpc, const bool borders, bool drawNoteName ) @@ -3024,6 +3064,50 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) QPolygonF editHandles; + // -- Begin ghost pattern + if( m_ghostPattern != nullptr ) + { + for( const Note *note : m_ghostPattern->notes() ) + { + int len_ticks = note->length(); + + if( len_ticks == 0 ) + { + continue; + } + else if( len_ticks < 0 ) + { + len_ticks = 4; + } + const int key = note->key() - m_startKey + 1; + + int pos_ticks = note->pos(); + + int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact(); + const int x = ( pos_ticks - m_currentPosition ) * + m_ppt / MidiTime::ticksPerTact(); + // skip this note if not in visible area at all + if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) ) + { + continue; + } + + // is the note in visible area? + if( key > 0 && key <= visible_keys ) + { + + // we've done and checked all, let's draw the + // note + drawNoteRect( p, x + WHITE_KEY_WIDTH, + y_base - key * KEY_LINE_HEIGHT, + note_width, note, ghostNoteColor(), ghostNoteTextColor(), selectedNoteColor(), + ghostNoteOpacity(), ghostNoteBorders(), drawNoteNames ); + } + + } + } + // -- End ghost pattern + for( const Note *note : m_pattern->notes() ) { int len_ticks = note->length(); @@ -4221,8 +4305,13 @@ PianoRollWindow::PianoRollWindow() : m_chordComboBox = new ComboBox( m_toolBar ); m_chordComboBox->setModel( &m_editor->m_chordModel ); m_chordComboBox->setFixedSize( 105, 22 ); - m_chordComboBox->setToolTip( tr( "Chord") ); + m_chordComboBox->setToolTip( tr( "Chord" ) ); + // -- Clear ghost pattern button + m_clearGhostButton = new QPushButton( m_toolBar ); + m_clearGhostButton->setIcon( embed::getIconPixmap( "clear_ghost_note" ) ); + m_clearGhostButton->setToolTip( tr( "Clear ghost notes" ) ); + connect( m_clearGhostButton, SIGNAL( clicked() ), m_editor, SLOT( clearGhostPattern() ) ); zoomAndNotesToolBar->addWidget( zoom_lbl ); zoomAndNotesToolBar->addWidget( m_zoomingComboBox ); @@ -4243,6 +4332,9 @@ PianoRollWindow::PianoRollWindow() : zoomAndNotesToolBar->addWidget( chord_lbl ); zoomAndNotesToolBar->addWidget( m_chordComboBox ); + zoomAndNotesToolBar->addSeparator(); + zoomAndNotesToolBar->addWidget( m_clearGhostButton ); + // setup our actual window setFocusPolicy( Qt::StrongFocus ); setFocus(); @@ -4265,8 +4357,17 @@ const Pattern* PianoRollWindow::currentPattern() const +void PianoRollWindow::setGhostPattern( Pattern* pattern ) +{ + m_editor->setGhostPattern( pattern ); +} + + + + void PianoRollWindow::setCurrentPattern( Pattern* pattern ) { + m_editor->clearGhostPattern(); m_editor->setCurrentPattern( pattern ); if ( pattern ) diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 8218d16f631..f0b6b35e303 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -637,6 +637,19 @@ void PatternView::openInPianoRoll() + +void PatternView::setGhostInPianoRoll() +{ + gui->pianoRoll()->setGhostPattern( m_pat ); + gui->pianoRoll()->parentWidget()->show(); + gui->pianoRoll()->show(); + gui->pianoRoll()->setFocus(); +} + + + + + void PatternView::resetName() { m_pat->setName( m_pat->m_instrumentTrack->name() ); @@ -663,7 +676,17 @@ void PatternView::constructContextMenu( QMenu * _cm ) _cm->insertAction( _cm->actions()[0], a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInPianoRoll() ) ); - _cm->insertSeparator( _cm->actions()[1] ); + + if( gui->pianoRoll()->currentPattern() and gui->pianoRoll()->currentPattern() != m_pat ){ + QAction * b = new QAction( embed::getIconPixmap( "ghost_note" ), + tr( "Set as ghost in piano-roll" ), _cm ); + _cm->insertAction( _cm->actions()[1], b ); + connect( b, SIGNAL( triggered( bool ) ), + this, SLOT( setGhostInPianoRoll() ) ); + _cm->insertSeparator( _cm->actions()[2] ); + } else { + _cm->insertSeparator( _cm->actions()[1] ); + } _cm->addSeparator(); From 43459e5dadb04d669c3dae279577fd478a7f8c80 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Sun, 2 Sep 2018 17:39:04 +0200 Subject: [PATCH 2/9] * changed setGhostPattern parameter name from `newPattern` to `pattern` in the PianoRoll header since we defined it as `pattern` in the cpp file as well. --- include/PianoRoll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index be8f17b2896..0105c60f5b9 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -433,7 +433,7 @@ class PianoRollWindow : public Editor, SerializingObject const Pattern* currentPattern() const; void setCurrentPattern( Pattern* pattern ); - void setGhostPattern( Pattern* newPattern ); + void setGhostPattern( Pattern* pattern ); int quantization() const; From e103e761d48cf3f7b788842258a83f8f5909f2bf Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Mon, 3 Sep 2018 21:56:19 +0200 Subject: [PATCH 3/9] * set ghost pattern `m_ghostPattern` to `nullptr` on `destroyedPattern` signal. * changed `and` to `&&` for MSVC support. - Thanks to PhysSong for the review. --- src/gui/editors/PianoRoll.cpp | 5 +++++ src/tracks/Pattern.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 3b11db3989c..c70656d881b 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -606,6 +606,11 @@ PianoRoll::~PianoRoll() void PianoRoll::setGhostPattern( Pattern* newPattern ) { m_ghostPattern = newPattern; + if( newPattern != nullptr ) + { + // make sure to always get informed about the pattern being destroyed + connect( m_ghostPattern, SIGNAL( destroyedPattern( Pattern* ) ), this, SLOT( clearGhostPattern() ) ); + } } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index f0b6b35e303..43b9242bee7 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -677,7 +677,7 @@ void PatternView::constructContextMenu( QMenu * _cm ) connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInPianoRoll() ) ); - if( gui->pianoRoll()->currentPattern() and gui->pianoRoll()->currentPattern() != m_pat ){ + if( gui->pianoRoll()->currentPattern() && gui->pianoRoll()->currentPattern() != m_pat ){ QAction * b = new QAction( embed::getIconPixmap( "ghost_note" ), tr( "Set as ghost in piano-roll" ), _cm ); _cm->insertAction( _cm->actions()[1], b ); From a05223e672ae8713b710452979eb044b31c4d378 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Mon, 3 Sep 2018 22:16:44 +0200 Subject: [PATCH 4/9] resized ghost note icon so it is aligned with the rest of the icons in the pattern context-menu. --- data/themes/default/ghost_note.png | Bin 452 -> 3915 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/themes/default/ghost_note.png b/data/themes/default/ghost_note.png index 532245e11f5e4bd6547da4e5b54547f353a6182e..073442659782a12383b536f4f1984f7ae892f867 100644 GIT binary patch literal 3915 zcmV-R547-!P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+U=QFawI#lME|jhSprl*EC9zkhG@FMeVv#YD*^)s!qhvBv5fUy8kcuA{T@{Js83_cizN zym`CeITbjD>)*8Q`y1!w{ec|s^Zny_lgB+yxd*y0JO&Ipv**iwU%3Yg{yOjO|4qH0 zYw>A2kKb_?ud`o2pZ<>-Fs3kG@W!v;g5_`0Spq8vB{Yup{0({&pT>FNZ`AuB|QaN57E#hrQUnQyql%+qnFcMRr^9Y1}{tCRnq z&)YzIkAtu+Z&S)u?FmeBxW;V0TI@@v!Dy_I=rIlA%b+rxGcGz*tPCM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yS%JT7kRi%6$wkiHuyCB+qf0Jmsu{ffe)j3zvf6I?X^-4$e2u_2YU=aU zv1#vFP8-n>F17jobOpiJYg|xY|NZ0dPn&=C`1{l5*T;c%_M0UsC`;CSBZ=YwGu}xu z_@gW{hb8(}H)(XuH%or^G7TG4R`4Iibv7{tq+x#m000JJOGiWiCjc-23ppEfa{vGU z32;bRa{vGi{Qv+C{Q{Of>5cc?Q*If2>-2U$&+~qId+R($iUcSEo4^(DWX~0_0Th)rKp${OdJcfzMy10* zg~n3>hSH>Mz$Mvp0kp=%C2On$3qankWiJq&17+advH6(z#F};j-VVH3ZO!o+Cq9me z@2qJ(;0bVVwTYniY`hi|*R81v^gBN1PPXKD!QYQ}C85}{M@eN#U6LjpuS?pNbSr6A zQpcApNs>mynd8MRYEu5ie@Fb$Eb-QFh^ybQBT4%yuCv%D{QwLCwP2b}0i(dHyUp; ZA)oDt9LV^L_F(`3002ovPDHLkV1h83oofI9 literal 452 zcmV;#0XzPQP)(hxNG85){u z=mSVweSwCCYH)6}1`!(q8;aJ#QCu8)(UKxauHGdwqG zfCaq7CVrG}6ECpP_SeQqymdO(aiuj+V`l(!A3M0-H;>@U5avEU<9zU-5IsD^n4@vt zG=@)D#bL$W58jtzr5Wo24vO}y;uoucjbN`7&zpb_z7=i0(S8tMPxpU;%&rHDGy|fbI#} zyCiF;_&)~UF@@b``)=a~ewTWy(zeT Date: Fri, 7 Sep 2018 19:01:20 +0200 Subject: [PATCH 5/9] Changed opacity variables data types back to `int` from `unsigned char`. --- include/PianoRoll.h | 16 ++++++++-------- src/gui/editors/PianoRoll.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 0105c60f5b9..df5a903460c 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -68,9 +68,9 @@ class PianoRoll : public QWidget Q_PROPERTY( QColor textColorLight READ textColorLight WRITE setTextColorLight ) Q_PROPERTY( QColor textShadow READ textShadow WRITE setTextShadow ) Q_PROPERTY( QColor markedSemitoneColor READ markedSemitoneColor WRITE setMarkedSemitoneColor ) - Q_PROPERTY( unsigned char noteOpacity READ noteOpacity WRITE setNoteOpacity ) + Q_PROPERTY( int noteOpacity READ noteOpacity WRITE setNoteOpacity ) Q_PROPERTY( bool noteBorders READ noteBorders WRITE setNoteBorders ) - Q_PROPERTY( unsigned char ghostNoteOpacity READ ghostNoteOpacity WRITE setGhostNoteOpacity ) + Q_PROPERTY( int ghostNoteOpacity READ ghostNoteOpacity WRITE setGhostNoteOpacity ) Q_PROPERTY( bool ghostNoteBorders READ ghostNoteBorders WRITE setGhostNoteBorders ) Q_PROPERTY( QColor backgroundShade READ backgroundShade WRITE setBackgroundShade ) public: @@ -142,16 +142,16 @@ class PianoRoll : public QWidget void setTextShadow( const QColor & c ); QColor markedSemitoneColor() const; void setMarkedSemitoneColor( const QColor & c ); - unsigned char noteOpacity() const; - void setNoteOpacity( const unsigned char i ); + int noteOpacity() const; + void setNoteOpacity( const int i ); bool noteBorders() const; void setNoteBorders( const bool b ); QColor ghostNoteColor() const; void setGhostNoteColor( const QColor & c ); QColor ghostNoteTextColor() const; void setGhostNoteTextColor( const QColor & c ); - unsigned char ghostNoteOpacity() const; - void setGhostNoteOpacity( const unsigned char i ); + int ghostNoteOpacity() const; + void setGhostNoteOpacity( const int i ); bool ghostNoteBorders() const; void setGhostNoteBorders( const bool b ); QColor backgroundShade() const; @@ -412,8 +412,8 @@ protected slots: QColor m_textColorLight; QColor m_textShadow; QColor m_markedSemitoneColor; - unsigned char m_noteOpacity; - unsigned char m_ghostNoteOpacity; + int m_noteOpacity; + int m_ghostNoteOpacity; bool m_noteBorders; bool m_ghostNoteBorders; QColor m_backgroundShade; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index c70656d881b..6f3777f322f 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -811,10 +811,10 @@ QColor PianoRoll::markedSemitoneColor() const void PianoRoll::setMarkedSemitoneColor( const QColor & c ) { m_markedSemitoneColor = c; } -unsigned char PianoRoll::noteOpacity() const +int PianoRoll::noteOpacity() const { return m_noteOpacity; } -void PianoRoll::setNoteOpacity( const unsigned char i ) +void PianoRoll::setNoteOpacity( const int i ) { m_noteOpacity = i; } bool PianoRoll::noteBorders() const @@ -835,10 +835,10 @@ QColor PianoRoll::ghostNoteTextColor() const void PianoRoll::setGhostNoteTextColor( const QColor & c ) { m_ghostNoteTextColor = c; } -unsigned char PianoRoll::ghostNoteOpacity() const +int PianoRoll::ghostNoteOpacity() const { return m_ghostNoteOpacity; } -void PianoRoll::setGhostNoteOpacity( const unsigned char i ) +void PianoRoll::setGhostNoteOpacity( const int i ) { m_ghostNoteOpacity = i; } bool PianoRoll::ghostNoteBorders() const From 4e5493f23d738848a61622273d0ab53f8017fda6 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Mon, 7 Jan 2019 00:52:26 +0100 Subject: [PATCH 6/9] =?UTF-8?q?*=20Don=E2=80=99t=20show=20`Set=20as=20ghos?= =?UTF-8?q?t=20in=20piano-roll`=20on=20empty=20pattern.=20*=20Small=20chan?= =?UTF-8?q?ge=20to=20comply=20more=20with=20the=20rest=20of=20the=20coding?= =?UTF-8?q?=20style.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tracks/Pattern.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 43b9242bee7..be0f46a421a 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -677,14 +677,19 @@ void PatternView::constructContextMenu( QMenu * _cm ) connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInPianoRoll() ) ); - if( gui->pianoRoll()->currentPattern() && gui->pianoRoll()->currentPattern() != m_pat ){ + if( gui->pianoRoll()->currentPattern() && + gui->pianoRoll()->currentPattern() != m_pat && + not m_pat->empty() ) + { QAction * b = new QAction( embed::getIconPixmap( "ghost_note" ), tr( "Set as ghost in piano-roll" ), _cm ); _cm->insertAction( _cm->actions()[1], b ); connect( b, SIGNAL( triggered( bool ) ), this, SLOT( setGhostInPianoRoll() ) ); _cm->insertSeparator( _cm->actions()[2] ); - } else { + } + else + { _cm->insertSeparator( _cm->actions()[1] ); } From 0da2a15fdb7771c33f7f26dc2fbd3189324d95df Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Mon, 7 Jan 2019 01:03:51 +0100 Subject: [PATCH 7/9] Disable `clear ghost notes` button in `Piano-Roll` when there is no ghost set. --- include/PianoRoll.h | 2 ++ src/gui/editors/PianoRoll.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index df5a903460c..168036245ad 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -224,6 +224,7 @@ protected slots: signals: void currentPatternChanged(); + void ghostPatternSet(bool); void semiToneMarkerMenuScaleSetEnabled(bool); void semiToneMarkerMenuChordSetEnabled(bool); @@ -466,6 +467,7 @@ class PianoRollWindow : public Editor, SerializingObject private slots: void patternRenamed(); + void ghostPatternSet( bool state ); private: void focusInEvent(QFocusEvent * event); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 6f3777f322f..87b751c4eaf 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -610,6 +610,7 @@ void PianoRoll::setGhostPattern( Pattern* newPattern ) { // make sure to always get informed about the pattern being destroyed connect( m_ghostPattern, SIGNAL( destroyedPattern( Pattern* ) ), this, SLOT( clearGhostPattern() ) ); + emit ghostPatternSet( true ); } } @@ -617,6 +618,7 @@ void PianoRoll::setGhostPattern( Pattern* newPattern ) void PianoRoll::clearGhostPattern() { setGhostPattern( nullptr ); + emit ghostPatternSet( false ); update(); } @@ -4316,7 +4318,9 @@ PianoRollWindow::PianoRollWindow() : m_clearGhostButton = new QPushButton( m_toolBar ); m_clearGhostButton->setIcon( embed::getIconPixmap( "clear_ghost_note" ) ); m_clearGhostButton->setToolTip( tr( "Clear ghost notes" ) ); + m_clearGhostButton->setEnabled( false ); connect( m_clearGhostButton, SIGNAL( clicked() ), m_editor, SLOT( clearGhostPattern() ) ); + connect( m_editor, SIGNAL( ghostPatternSet( bool ) ), this, SLOT( ghostPatternSet( bool ) ) ); zoomAndNotesToolBar->addWidget( zoom_lbl ); zoomAndNotesToolBar->addWidget( m_zoomingComboBox ); @@ -4493,6 +4497,14 @@ void PianoRollWindow::patternRenamed() +void PianoRollWindow::ghostPatternSet( bool state ) +{ + m_clearGhostButton->setEnabled( state ); +} + + + + void PianoRollWindow::focusInEvent( QFocusEvent * event ) { // when the window is given focus, also give focus to the actual piano roll From e45525358de1dfe0d0488e25fa6e71f8bed96463 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Thu, 10 Jan 2019 10:37:38 +0100 Subject: [PATCH 8/9] =?UTF-8?q?*=20Don=E2=80=99t=20clear=20ghost=20automat?= =?UTF-8?q?icly.=20*=20Don=E2=80=99t=20paint=20ghost=20if=20it=E2=80=99s?= =?UTF-8?q?=20the=20same=20pattern.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/editors/PianoRoll.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 87b751c4eaf..116159a51e0 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -3072,7 +3072,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) QPolygonF editHandles; // -- Begin ghost pattern - if( m_ghostPattern != nullptr ) + if( m_ghostPattern != nullptr && m_ghostPattern != m_pattern ) { for( const Note *note : m_ghostPattern->notes() ) { @@ -4376,7 +4376,6 @@ void PianoRollWindow::setGhostPattern( Pattern* pattern ) void PianoRollWindow::setCurrentPattern( Pattern* pattern ) { - m_editor->clearGhostPattern(); m_editor->setCurrentPattern( pattern ); if ( pattern ) From 86812695181ac97cdef51b5081a89aa3c07ebbd5 Mon Sep 17 00:00:00 2001 From: CYBERDEViLNL Date: Thu, 10 Jan 2019 10:40:35 +0100 Subject: [PATCH 9/9] remove empty line. --- src/tracks/Pattern.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index be0f46a421a..13f0bad9f93 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -649,7 +649,6 @@ void PatternView::setGhostInPianoRoll() - void PatternView::resetName() { m_pat->setName( m_pat->m_instrumentTrack->name() );