Exactly. To do it "right" it needs to look vaguely like this (we would have to rip out – or maybe not – the bits which read the color from the configuration file); note also that this code could be simplified so that there was only one call for getting the color instead of getting the color in every Case in which we desire to draw the label – personally, I would leave it as is as it makes the code more readable:
Code: Select all
void TrackArtist::DrawTrack(const Track * t,
wxDC & dc,
const wxRect & r,
const ViewInfo * viewInfo,
bool drawEnvelope,
bool drawSamples,
bool drawSliders,
bool hasSolo)
{
switch (t->GetKind()) {
case Track::Wave:
{
WaveTrack* wt = (WaveTrack*)t;
for (WaveClipList::compatibility_iterator it=wt->GetClipIterator(); it; it=it->GetNext()) {
it->GetData()->ClearDisplayRect();
}
bool muted = (hasSolo || t->GetMute()) && !t->GetSolo();
switch (wt->GetDisplay()) {
case WaveTrack::WaveformDisplay:
DrawWaveform(wt, dc, r, viewInfo,
drawEnvelope, drawSamples, drawSliders, false, muted);
break;
case WaveTrack::WaveformDBDisplay:
DrawWaveform(wt, dc, r, viewInfo,
drawEnvelope, drawSamples, drawSliders, true, muted);
break;
case WaveTrack::SpectrumDisplay:
DrawSpectrum(wt, dc, r, viewInfo, false, false);
break;
case WaveTrack::SpectrumLogDisplay:
DrawSpectrum(wt, dc, r, viewInfo, false, true);
break;
case WaveTrack::PitchDisplay:
DrawSpectrum(wt, dc, r, viewInfo, true, false);
break;
}
//efm5 start
//we want to drive on top of (thus after) the audio
if (mbShowTrackNameInWaveform && wt->GetChannel() != Track::RightChannel) {
const wxColour& originalForegroundTextColor = dc.GetTextForeground();
wxString fontColorAsString;
if (gPrefs->Read(wxT("/GUI/FontColorForNameInWaveform"), &fontColorAsString)) {
wxColour newForegroundColorFromPrefs(fontColorAsString);
dc.SetTextForeground(newForegroundColorFromPrefs);
}
else {
wxColour newForegroundColor(0, 0, 0);
dc.SetTextForeground(newForegroundColor);
}
dc.DrawText (wt->GetName(), r.x+10, r.y); // move right 10 pixels to avoid overwriting <- symbol
dc.SetTextForeground(originalForegroundTextColor);
}
//efm5 end
break; // case Wave
}
#ifdef USE_MIDI
case Track::Note:
{
bool muted = (hasSolo || t->GetMute()) && !t->GetSolo();
DrawNoteTrack((NoteTrack *)t, dc, r, viewInfo, muted);
//efm5 start
if (mbShowTrackNameInWaveform) {
const wxColour& originalForegroundTextColor = dc.GetTextForeground();
wxString fontColorAsString;
if (gPrefs->Read(wxT("/GUI/FontColorForNameInWaveform"), &fontColorAsString)) {
wxColour newForegroundColorFromPrefs(fontColorAsString);
dc.SetTextForeground(newForegroundColorFromPrefs);
}
else {
wxColour newForegroundColor(0, 0, 0);
dc.SetTextForeground(newForegroundColor);
}
dc.DrawText (t->GetName(), r.x+5, r.y); // move right 5 pixels
dc.SetTextForeground(originalForegroundTextColor);
}
//efm5 end
break;
}
#endif // USE_MIDI
case Track::Label:
DrawLabelTrack((LabelTrack *)t, dc, r, viewInfo);
break;
case Track::Time:
DrawTimeTrack((TimeTrack *)t, dc, r, viewInfo);
break;
}
}