From a42d2d2d70b5de96d1e7c2fbef603a9873b6a456 Mon Sep 17 00:00:00 2001 From: Kumar Date: Mon, 16 Nov 2020 23:02:57 +0530 Subject: [PATCH] Color mixer channels if they are made by a colored track (#5780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Color mixer channels if they are made by a coloured track using the “Assign to new FX channel option.” --- include/FxMixer.h | 8 +++++++- src/gui/widgets/FxLine.cpp | 11 ++++------- src/tracks/InstrumentTrack.cpp | 4 +++- src/tracks/SampleTrack.cpp | 4 +++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/FxMixer.h b/include/FxMixer.h index 920d4e27b..e7af1d50e 100644 --- a/include/FxMixer.h +++ b/include/FxMixer.h @@ -73,7 +73,13 @@ class FxChannel : public ThreadableJob void unmuteForSolo(); - // TODO C++17 and above: use std::optional insteads + void setColor (QColor newColor) + { + m_color = newColor; + m_hasColor = true; + } + + // TODO C++17 and above: use std::optional instead QColor m_color; bool m_hasColor; diff --git a/src/gui/widgets/FxLine.cpp b/src/gui/widgets/FxLine.cpp index 476d8773b..254e4068d 100644 --- a/src/gui/widgets/FxLine.cpp +++ b/src/gui/widgets/FxLine.cpp @@ -418,11 +418,9 @@ void FxLine::setStrokeInnerInactive( const QColor & c ) void FxLine::changeColor() { auto channel = Engine::fxMixer()->effectChannel( m_channelIndex ); - auto new_color = ColorChooser( this ).withPalette( ColorChooser::Palette::Mixer )->getColor( channel->m_color ); - if( ! new_color.isValid() ) - { return; } - channel->m_color = new_color; - channel->m_hasColor = true; + auto new_color = ColorChooser(this).withPalette(ColorChooser::Palette::Mixer)->getColor(channel->m_color); + if(!new_color.isValid()) { return; } + channel->setColor (new_color); update(); } @@ -439,7 +437,6 @@ void FxLine::resetColor() void FxLine::randomColor() { auto channel = Engine::fxMixer()->effectChannel( m_channelIndex ); - channel->m_color = ColorChooser::getPalette( ColorChooser::Palette::Mixer )[ rand() % 48 ]; - channel->m_hasColor = true; + channel->setColor (ColorChooser::getPalette(ColorChooser::Palette::Mixer)[rand() % 48]); update(); } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index c61999a0e..5c75245f3 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1098,8 +1098,10 @@ InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow() void InstrumentTrackView::createFxLine() { int channelIndex = gui->fxMixerView()->addNewChannel(); + auto channel = Engine::fxMixer()->effectChannel(channelIndex); - Engine::fxMixer()->effectChannel( channelIndex )->m_name = getTrack()->name(); + channel->m_name = getTrack()->name(); + if (getTrack()->useColor()) { channel->setColor (getTrack()->color()); } assignFxLine(channelIndex); } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index b84d29803..398fbd28a 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -1169,8 +1169,10 @@ void SampleTrackWindow::modelChanged() void SampleTrackView::createFxLine() { int channelIndex = gui->fxMixerView()->addNewChannel(); + auto channel = Engine::fxMixer()->effectChannel(channelIndex); - Engine::fxMixer()->effectChannel(channelIndex)->m_name = getTrack()->name(); + channel->m_name = getTrack()->name(); + if (getTrack()->useColor()) { channel->setColor (getTrack()->color()); } assignFxLine(channelIndex); }