diff --git a/include/FxLine.h b/include/FxLine.h index 1700ebba3..70def8637 100644 --- a/include/FxLine.h +++ b/include/FxLine.h @@ -21,11 +21,11 @@ public: virtual void mouseDoubleClickEvent( QMouseEvent * ); inline int channelIndex() { return m_channelIndex; } + inline void setChannelIndex(int index) { m_channelIndex = index; } knob * m_sendKnob; SendButtonIndicator * m_sendBtn; - private: FxMixerView * m_mv; diff --git a/include/FxMixer.h b/include/FxMixer.h index b53045015..19caa1479 100644 --- a/include/FxMixer.h +++ b/include/FxMixer.h @@ -109,6 +109,13 @@ public: // returns the index of the channel that was just added int createChannel(); + // delete a channel from the FX mixer. + void deleteChannel(int index); + + // re-arrange channels + void moveChannelLeft(int index); + void moveChannelRight(int index); + // reset a channel's name, fx, sends, etc void clearChannel(fx_ch_t channelIndex); diff --git a/include/FxMixerView.h b/include/FxMixerView.h index 5c4c2e0c8..05c5874bf 100644 --- a/include/FxMixerView.h +++ b/include/FxMixerView.h @@ -52,15 +52,16 @@ public: FxChannelView(QWidget * _parent, FxMixerView * _mv, int _chIndex ); FxLine * m_fxLine; - //EffectRackView * m_rackView; pixmapButton * m_muteBtn; fader * m_fader; - } ; + }; FxMixerView(); virtual ~FxMixerView(); + virtual void keyPressEvent(QKeyEvent * e); + virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ); virtual void loadSettings( const QDomElement & _this ); @@ -81,7 +82,10 @@ public: // display the send button and knob correctly - void updateFxLine(int i); + void updateFxLine(int index); + + // notify the view that an fx channel was deleted + void deleteChannel(int index); private slots: void updateFaders(); diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index 8306b28c4..68fba6037 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -30,6 +30,9 @@ #include "Effect.h" #include "song.h" +#include "InstrumentTrack.h" +#include "bb_track_container.h" + FxChannel::FxChannel( Model * _parent ) : m_fxChain( NULL ), @@ -97,6 +100,98 @@ int FxMixer::createChannel() } +void FxMixer::deleteChannel(int index) +{ + // go through every instrument and adjust for the channel index change + QVector songTrackList = engine::getSong()->tracks(); + QVector bbTrackList = engine::getBBTrackContainer()->tracks(); + + QVector trackLists[] = {songTrackList, bbTrackList}; + for(int tl=0; tl<2; ++tl) + { + QVector trackList = trackLists[tl]; + for(int i=0; itype() == track::InstrumentTrack ) + { + InstrumentTrack * inst = (InstrumentTrack *) trackList[i]; + int val = inst->effectChannelModel()->value(0); + if( val == index ) + { + // we are deleting this track's fx send + // send to master + inst->effectChannelModel()->setValue(0); + } + else if( val > index ) + { + // subtract 1 to make up for the missing channel + inst->effectChannelModel()->setValue(val-1); + } + + } + } + } + + // delete all of this channel's sends and receives + for(int i=0; im_sends.size(); ++i) + { + deleteChannelSend(index, m_fxChannels[index]->m_sends[i]); + } + for(int i=0; im_receives.size(); ++i) + { + deleteChannelSend(m_fxChannels[index]->m_receives[i], index); + } + + for(int i=0; im_sends.size(); ++j) + { + if( m_fxChannels[i]->m_sends[j] > index ) + { + // subtract 1 to make up for the missing channel + --m_fxChannels[i]->m_sends[j]; + } + } + for(int j=0; jm_receives.size(); ++j) + { + if( m_fxChannels[i]->m_receives[j] > index ) + { + // subtract 1 to make up for the missing channel + --m_fxChannels[i]->m_receives[j]; + } + } + + } + + // actually delete the channel + m_fxChannels.remove(index); +} + + + +void FxMixer::moveChannelLeft(int index) +{ + // can't move master or first channel + if( index <= 1 ) + { + return; + } + + // channels to swap + int a = index - 1, b = index; + + // go through every instrument and adjust for the channel index change +} + + + +void FxMixer::moveChannelRight(int index) +{ + moveChannelLeft(index+1); +} + + void FxMixer::createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel, float amount) diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index 63a23c891..e3fa74212 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -63,9 +64,6 @@ FxMixerView::FxMixerView() : // main-layout QHBoxLayout * ml = new QHBoxLayout; - //ml->setMargin( 0 ); - //ml->setSpacing( 0 ); - //ml->addSpacing( 6 ); // Channel area m_channelAreaWidget = new QWidget; @@ -237,6 +235,56 @@ void FxMixerView::updateFxLine(int index) } +void FxMixerView::deleteChannel(int index) +{ + // remember selected line + int selLine = m_currentFxLine->channelIndex(); + + // can't delete master + if( index == 0 ) + return; + + // delete the real channel + engine::fxMixer()->deleteChannel(index); + + // delete the view + chLayout->removeWidget(m_fxChannelViews[index]->m_fxLine); + delete m_fxChannelViews[index]->m_fader; + delete m_fxChannelViews[index]->m_muteBtn; + delete m_fxChannelViews[index]->m_fxLine; + delete m_fxChannelViews[index]; + + // make sure every channel knows what index it is + for(int i=0; i index ) + { + m_fxChannelViews[i]->m_fxLine->setChannelIndex(i-1); + } + } + m_fxChannelViews.remove(index); + + // select the next channel + if( selLine >= m_fxChannelViews.size() ) + { + selLine = m_fxChannelViews.size()-1; + } + setCurrentFxLine(selLine); + +} + + +void FxMixerView::keyPressEvent(QKeyEvent * e) +{ + switch(e->key()) + { + case Qt::Key_Delete: + deleteChannel(m_currentFxLine->channelIndex()); + break; + } +} + + void FxMixerView::setCurrentFxLine( int _line ) { @@ -245,7 +293,6 @@ void FxMixerView::setCurrentFxLine( int _line ) - void FxMixerView::clear() { m_rackView->clearViews();