diff --git a/include/FxMixerView.h b/include/FxMixerView.h index 05c5874bf..736c70615 100644 --- a/include/FxMixerView.h +++ b/include/FxMixerView.h @@ -87,6 +87,10 @@ public: // notify the view that an fx channel was deleted void deleteChannel(int index); + // move the channel to the left or right + void moveChannelLeft(int index); + void moveChannelRight(int index); + private slots: void updateFaders(); void addNewChannel(); diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index 68fba6037..488fb09d9 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -173,7 +173,7 @@ void FxMixer::deleteChannel(int index) void FxMixer::moveChannelLeft(int index) { // can't move master or first channel - if( index <= 1 ) + if( index <= 1 || index >= m_fxChannels.size() ) { return; } @@ -182,6 +182,63 @@ void FxMixer::moveChannelLeft(int index) int a = index - 1, b = 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 == a ) + { + inst->effectChannelModel()->setValue(b); + } + else if( val == b ) + { + inst->effectChannelModel()->setValue(a); + } + + } + } + } + + for(int i=0; im_sends.size(); ++j) + { + if( m_fxChannels[i]->m_sends[j] == a ) + { + m_fxChannels[i]->m_sends[j] = b; + } + else if( m_fxChannels[i]->m_sends[j] == b ) + { + m_fxChannels[i]->m_sends[j] = a; + } + } + for(int j=0; jm_receives.size(); ++j) + { + if( m_fxChannels[i]->m_receives[j] == a ) + { + m_fxChannels[i]->m_receives[j] = b; + } + else if( m_fxChannels[i]->m_receives[j] == b ) + { + m_fxChannels[i]->m_receives[j] = a; + } + } + } + + // actually do the swap + FxChannel * tmpChannel = m_fxChannels[a]; + m_fxChannels[a] = m_fxChannels[b]; + m_fxChannels[b] = tmpChannel; } diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index e3fa74212..70745ef8c 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -89,7 +89,22 @@ FxMixerView::FxMixerView() : chLayout->addWidget(m_fxChannelViews[i]->m_fxLine); } // add the scrolling section to the main layout - channelArea = new QScrollArea(this); + + // class for scroll area to pass key presses down + class ChannelArea : public QScrollArea + { + public: + ChannelArea(QWidget * parent, FxMixerView * mv) : + QScrollArea(parent), m_mv(mv) {} + ~ChannelArea() {} + virtual void keyPressEvent(QKeyEvent * e) + { + m_mv->keyPressEvent(e); + } + private: + FxMixerView * m_mv; + }; + channelArea = new ChannelArea(this, this); channelArea->setWidget(m_channelAreaWidget); channelArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); channelArea->setFrameStyle( QFrame::NoFrame ); @@ -237,13 +252,12 @@ void FxMixerView::updateFxLine(int index) void FxMixerView::deleteChannel(int index) { + // can't delete master + if( index == 0 ) return; + // remember selected line int selLine = m_currentFxLine->channelIndex(); - // can't delete master - if( index == 0 ) - return; - // delete the real channel engine::fxMixer()->deleteChannel(index); @@ -253,6 +267,7 @@ void FxMixerView::deleteChannel(int index) delete m_fxChannelViews[index]->m_muteBtn; delete m_fxChannelViews[index]->m_fxLine; delete m_fxChannelViews[index]; + m_channelAreaWidget->adjustSize(); // make sure every channel knows what index it is for(int i=0; i= m_fxChannelViews.size() ) return; + + int selIndex = m_currentFxLine->channelIndex(); + + FxMixer * mix = engine::fxMixer(); + mix->moveChannelLeft(index); + + // refresh the two mixer views + for( int i = index-1; i <= index; ++i ) + { + // delete the mixer view + int replaceIndex = chLayout->indexOf(m_fxChannelViews[i]->m_fxLine); + + chLayout->removeWidget(m_fxChannelViews[i]->m_fxLine); + delete m_fxChannelViews[i]->m_fader; + delete m_fxChannelViews[i]->m_muteBtn; + delete m_fxChannelViews[i]->m_fxLine; + delete m_fxChannelViews[i]; + + // add it again + m_fxChannelViews[i] = new FxChannelView(m_channelAreaWidget, this, i); + chLayout->insertWidget(replaceIndex, m_fxChannelViews[i]->m_fxLine); + } + + // keep selected channel + if( selIndex == index ) + { + selIndex = index-1; + } + else if( selIndex == index - 1 ) + { + selIndex = index; + } + setCurrentFxLine(selIndex); +} + + + +void FxMixerView::moveChannelRight(int index) +{ + moveChannelLeft(index+1); +} + + + void FxMixerView::keyPressEvent(QKeyEvent * e) { switch(e->key()) @@ -281,6 +345,18 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) case Qt::Key_Delete: deleteChannel(m_currentFxLine->channelIndex()); break; + case Qt::Key_Left: + if( e->modifiers() & Qt::AltModifier ) + { + moveChannelLeft( m_currentFxLine->channelIndex() ); + } + break; + case Qt::Key_Right: + if( e->modifiers() & Qt::AltModifier ) + { + moveChannelRight( m_currentFxLine->channelIndex() ); + } + break; } }