1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-18 17:10:05 +02:00

Clip (and track) colours now persists in .aup file.

This commit is contained in:
James Crook 2017-11-04 17:09:01 +00:00
parent 42c52de7f1
commit b48c6b0fd6
3 changed files with 20 additions and 2 deletions

View File

@ -1503,6 +1503,7 @@ bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
if (!wxStrcmp(tag, wxT("waveclip")))
{
double dblValue;
long longValue;
while (*attrs)
{
const wxChar *attr = *attrs++;
@ -1519,6 +1520,13 @@ bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
return false;
SetOffset(dblValue);
}
if (!wxStrcmp(attr, wxT("colorindex")))
{
if (!XMLValueChecker::IsGoodString(strValue) ||
!strValue.ToLong( &longValue))
return false;
SetColourIndex(longValue);
}
}
return true;
}
@ -1555,6 +1563,7 @@ void WaveClip::WriteXML(XMLWriter &xmlFile) const
{
xmlFile.StartTag(wxT("waveclip"));
xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
xmlFile.WriteAttr(wxT("colorindex"), mColourIndex );
mSequence->WriteXML(xmlFile);
mEnvelope->WriteXML(xmlFile);

View File

@ -1765,7 +1765,11 @@ bool WaveTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
else if (!wxStrcmp(attr, wxT("autosaveid")) &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
mAutoSaveIdent = (int) nValue;
else if (!wxStrcmp(attr, wxT("colorindex")) &&
XMLValueChecker::IsGoodString(strValue) &&
strValue.ToLong(&nValue))
// Don't use SetWaveColorIndex as it sets the clips too.
mWaveColorIndex = nValue;
} // while
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
VirtualStereoInit();
@ -1846,6 +1850,7 @@ void WaveTrack::WriteXML(XMLWriter &xmlFile) const
xmlFile.WriteAttr(wxT("rate"), mRate);
xmlFile.WriteAttr(wxT("gain"), (double)mGain);
xmlFile.WriteAttr(wxT("pan"), (double)mPan);
xmlFile.WriteAttr(wxT("colorindex"), mWaveColorIndex );
for (const auto &clip : mClips)
{
@ -2273,7 +2278,7 @@ Sequence* WaveTrack::GetSequenceAtX(int xcoord)
WaveClip* WaveTrack::CreateClip()
{
mClips.push_back(make_movable<WaveClip>(mDirManager, mFormat, mRate,0 /*colurindex*/));
mClips.push_back(make_movable<WaveClip>(mDirManager, mFormat, mRate, GetWaveColorIndex()));
return mClips.back().get();
}

View File

@ -1523,6 +1523,7 @@ bool Effect::ProcessTrack(int count,
auto chans = std::min<unsigned>(mNumAudioOut, mNumChannels);
std::unique_ptr<WaveTrack> genLeft, genRight;
decltype(len) genLength = 0;
bool isGenerator = GetType() == EffectTypeGenerate;
bool isProcessor = GetType() == EffectTypeProcess;
@ -1543,9 +1544,12 @@ bool Effect::ProcessTrack(int count,
// Create temporary tracks
genLeft = mFactory->NewWaveTrack(left->GetSampleFormat(), left->GetRate());
genLeft->SetWaveColorIndex( left->GetWaveColorIndex() );
if (right)
{
genRight = mFactory->NewWaveTrack(right->GetSampleFormat(), right->GetRate());
genRight->SetWaveColorIndex( right->GetWaveColorIndex() );
}
}