Skip to content

Commit

Permalink
Automatic mixer strip management LMMS#1215 - fix some issues with tra…
Browse files Browse the repository at this point in the history
…ck naming and track delete
  • Loading branch information
spechtstatt committed May 24, 2022
1 parent 8c6076d commit ec1c8a2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
4 changes: 2 additions & 2 deletions include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class LMMS_EXPORT MixerView : public QWidget, public ModelView,
// useful for loading projects
void refreshDisplay();

// Auto track link support
void updateAfterTrackAdd(Track * track);
// Auto track link support
void updateAfterTrackAdd(Track * track, QString name = "");
void updateAfterTrackStyleModify(Track * track);
void updateAfterTrackMixerLineModify(Track * track);
void updateAfterTrackMove(Track * track);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void Mixer::deleteChannel( int index )
else if ( curIndex > index )
{
// subtract 1 to make up for the missing channel
model->setValue(-1);
model->setValue(curIndex-1);
}
});

Expand Down
64 changes: 39 additions & 25 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ MixerView::~MixerView()
}
}

void MixerView::updateAfterTrackAdd(Track * track)
void MixerView::updateAfterTrackAdd(Track * track, QString name)
{
// TODO: check if an autotrack mode is enabled (still missing)
Mixer * mix = Engine::mixer();
Expand All @@ -181,6 +181,7 @@ void MixerView::updateAfterTrackAdd(Track * track)
model->setValue( channelIndex );
mix->mixerChannel(channelIndex)->m_autoTrackLinkModel.setValue(true);

if (name != "") track->setName(name);
updateAfterTrackStyleModify(track);

setCurrentMixerLine( channelIndex );
Expand All @@ -193,13 +194,16 @@ void MixerView::updateAfterTrackStyleModify(Track * track)
IntModel * model = mix->getChannelModelByTrack(track);
if (model != NULL)
{
int index = model->value();
MixerChannel * channel = mix->mixerChannel(index);
if (channel->m_autoTrackLinkModel.value())
int channelIndex = model->value();
if (channelIndex>0)
{
channel->m_name = track->name();
if (track->useColor()) { channel->setColor (track->color()); }
setCurrentMixerLine(index);
MixerChannel * channel = mix->mixerChannel(channelIndex);
if (channel->m_autoTrackLinkModel.value())
{
channel->m_name = track->name();
if (track->useColor()) { channel->setColor (track->color()); }
setCurrentMixerLine(channelIndex);
}
}
}
}
Expand Down Expand Up @@ -233,10 +237,14 @@ void MixerView::updateAfterTrackMove(Track * track)
IntModel * model = Engine::mixer()->getChannelModelByTrack(track);
if (model != NULL)
{
MixerChannel * channel = mix->mixerChannel(model->value());
if (channel->m_autoTrackLinkModel.value())
int channelIndex = model->value();
if (channelIndex>0)
{
updateAutoTrackSortOrder();
MixerChannel * channel = mix->mixerChannel(channelIndex);
if (channel->m_autoTrackLinkModel.value())
{
updateAutoTrackSortOrder();
}
}
}
}
Expand All @@ -247,12 +255,15 @@ void MixerView::updateAfterTrackDelete(Track * track)
IntModel * model = mix->getChannelModelByTrack(track);
if ( model != NULL)
{
int channelIndex = mix->getChannelModelByTrack(track)->value();
MixerChannel * channel = mix->mixerChannel(channelIndex);
if (channel->m_autoTrackLinkModel.value())
int channelIndex = model->value();
if (channelIndex>0)
{
deleteChannel(channelIndex);
updateAutoTrackSortOrder();
MixerChannel * channel = mix->mixerChannel(channelIndex);
if (channel->m_autoTrackLinkModel.value())
{
deleteChannel(channelIndex);
updateAutoTrackSortOrder();
}
}
}
}
Expand Down Expand Up @@ -280,7 +291,6 @@ int MixerView::addNewChannel()

void MixerView::updateAutoTrackSortOrder()
{

Mixer * mix = Engine::mixer();
QList<int> *list = new QList<int>();

Expand Down Expand Up @@ -501,7 +511,20 @@ void MixerView::updateMixerLine(int index)

void MixerView::deleteChannel(int index)
{
if( index == 0 ) return;

// remember selected line
int selLine = m_currentMixerLine->channelIndex();

deleteChannelInternal(index);

// select the next channel
if( selLine >= m_mixerChannelViews.size() )
{
selLine = m_mixerChannelViews.size()-1;
}
setCurrentMixerLine(selLine);

updateMaxChannelSelector();
}

Expand All @@ -511,9 +534,6 @@ void MixerView::deleteChannelInternal(int index)
// can't delete master
if( index == 0 ) return;

// remember selected line
int selLine = m_currentMixerLine->channelIndex();

// in case the deleted channel is soloed or the remaining
// channels will be left in a muted state
Engine::mixer()->clearChannel(index);
Expand Down Expand Up @@ -541,12 +561,6 @@ void MixerView::deleteChannelInternal(int index)
}
m_mixerChannelViews.remove(index);

// select the next channel
if( selLine >= m_mixerChannelViews.size() )
{
selLine = m_mixerChannelViews.size()-1;
}
setCurrentMixerLine(selLine);
}


Expand Down
6 changes: 3 additions & 3 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
m_tc ) );
getGUI()->mixerView()->updateAfterTrackAdd(it);
InstrumentLoaderThread *ilt = new InstrumentLoaderThread(
this, it, value );
getGUI()->mixerView()->updateAfterTrackAdd(it, value);
ilt->start();
//it->toggledInstrumentTrackButton( true );
_de->accept();
Expand All @@ -392,10 +392,10 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
m_tc ) );
getGUI()->mixerView()->updateAfterTrackAdd(it);
PluginFactory::PluginInfoAndKey piakn =
getPluginFactory()->pluginSupportingExtension(FileItem::extension(value));
Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key);
getGUI()->mixerView()->updateAfterTrackAdd(it);
i->loadFile( value );
//it->toggledInstrumentTrackButton( true );
_de->accept();
Expand All @@ -406,9 +406,9 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
m_tc ) );
getGUI()->mixerView()->updateAfterTrackAdd(it);
it->setSimpleSerializing();
it->loadSettings( dataFile.content().toElement() );
getGUI()->mixerView()->updateAfterTrackAdd(it);
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
Expand Down

0 comments on commit ec1c8a2

Please sign in to comment.