Skip to content

Commit

Permalink
Automatic mixer strip management LMMS#1215 - bugfix for 'frozen' mixe…
Browse files Browse the repository at this point in the history
…r line color
  • Loading branch information
spechtstatt committed Jun 23, 2022
1 parent 9a2f342 commit 6d650f4
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ void MixerView::updateAfterTrackStyleModify(Track * track)
if (channel->m_autoTrackLinkModel.value())
{
channel->m_name = track->name();
if (track->useColor()) { channel->setColor (track->color()); }
channel->setColor (track->color());
channel->m_hasColor = track->useColor();
setCurrentMixerLine(channelIndex);
}
}
Expand All @@ -219,8 +220,7 @@ void MixerView::updateAfterTrackMixerLineModify(Track * track)
if (model != nullptr)
{
// check if there are more than one track pointing to the same mixer channel
// if yes disable the autotracklink
std::vector<bool> used(m_mixerChannelViews.size(), false);
// if yes disable the autotracklink
bool needUpdate = false;
std::vector<int> usedChannelCounts = mix->getUsedChannelCounts();
for(unsigned long i = 0; i < usedChannelCounts.size(); i++)
Expand Down Expand Up @@ -295,15 +295,16 @@ int MixerView::addNewChannel()

void MixerView::updateAutoTrackSortOrder()
{
Mixer * mix = Engine::mixer();
QList<int> *list = new QList<int>();
Mixer * mix = Engine::mixer();
std::vector<int> list(m_mixerChannelViews.size(), 0);

int c = 0;
// add all non auto track first
for( int i = 1; i<m_mixerChannelViews.size(); ++i )
{
if (!mix->mixerChannel(i)->m_autoTrackLinkModel.value())
{
list->append(i);
list[c++] = i;
}
}

Expand All @@ -313,27 +314,30 @@ void MixerView::updateAutoTrackSortOrder()
if (channel == nullptr) return;
if (channel->m_autoTrackLinkModel.value())
{
list->append(model->value());
list[c++] = model->value();
}
});
return;


// bubblesort here because the list is normally almost ordered
int n = list->length();
bool swapped = false;
do
{
for (int i=0; i<n-1; ++i)
swapped = false;
for (int i=0; i<c-1; ++i)
{
if (list->value(i) > list->value(i+1))
if (list[i] > list[i+1])
{
// a (+1) because we didn't include master track in our list
swapChannels(list->value(i+1), list->value(i+2));
list->swap(i,i+1);
swapChannels(list[i+1], list[i+2]);
int t = list[i];
list[i] = list[i+1];
list[i+1] = t;
swapped = true;
}
}
n = n-1;
c = c-1;
} while (swapped);

// TODO: think about focus
Expand Down

0 comments on commit 6d650f4

Please sign in to comment.