Displaying long track names

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Displaying long track names

Post by steve » Tue Dec 04, 2012 6:32 am

Thanks a lot Edgar. I'll get the bug report in.

Just a bit of conjecture/guesswork here:
Am I right in thinking that the problem is in TrackArtiste.cpp
line 324:

Code: Select all

   wxFont labelFont(12, wxSWISS, wxNORMAL, wxNORMAL);
   dc.SetFont(labelFont);
   dc.SetTextForeground(wxColour(255, 255, 0));
needs to be later - somewhere around line 423 so that the colour/font is set when the wavetrack is drawn?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: Displaying long track names

Post by Edgar » Tue Dec 04, 2012 5:50 pm

steve wrote:Thanks a lot Edgar. I'll get the bug report in.

Just a bit of conjecture/guesswork here:
Am I right in thinking that the problem is in TrackArtiste.cpp
line 324:

Code: Select all

   wxFont labelFont(12, wxSWISS, wxNORMAL, wxNORMAL);
   dc.SetFont(labelFont);
   dc.SetTextForeground(wxColour(255, 255, 0));
needs to be later - somewhere around line 423 so that the colour/font is set when the wavetrack is drawn?
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;
   }
}

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Displaying long track names

Post by steve » Tue Dec 04, 2012 5:56 pm

Thanks Edgar.
I've already posted a patch to bugzilla that worked on my machine (and included a disclaimer that I may not know what I'm talking about :D)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply