Example #1
0
void ControlToolBar::EnableDisableButtons()
{
   AudacityProject *p = GetActiveProject();
   bool tracks = false;

   bool playing = mPlay->IsDown();
   bool recording = mRecord->IsDown();
   bool busy = gAudioIO->IsBusy();

   // Only interested in audio type tracks
   if (p) {
      TrackListIterator iter( p->GetTracks() );
      for (Track *t = iter.First(); t; t = iter.Next()) {
         if (t->GetKind() == Track::Wave
#if defined(USE_MIDI)
         || t->GetKind() == Track::Note
#endif
         ) {
            tracks = true;
            break;
         }
      }
   }

   if (p) {
      TranscriptionToolBar *const playAtSpeedTB = p->GetTranscriptionToolBar();
      if (playAtSpeedTB)
         playAtSpeedTB->SetEnabled(CanStopAudioStream() && tracks && !recording);
   }

   mPlay->SetEnabled(CanStopAudioStream() && tracks && !recording);
   mRecord->SetEnabled(
      CanStopAudioStream() &&
      !(busy && !recording) &&
      !playing
   );
   mStop->SetEnabled(CanStopAudioStream() && (playing || recording));
   mRewind->SetEnabled(!playing && !recording);
   mFF->SetEnabled(tracks && !playing && !recording);

   auto pProject = GetActiveProject();
   mPause->SetEnabled(CanStopAudioStream());
}
Example #2
0
void ControlToolBar::EnableDisableButtons()
{
   //TIDY-ME: Button logic could be neater.
   AudacityProject *p = GetActiveProject();
   bool tracks = false;
   bool playing = mPlay->IsDown();
   bool recording = mRecord->IsDown();
   bool busy = gAudioIO->IsBusy() || playing || recording;

   // Only interested in audio type tracks
   if (p) {
      TrackListIterator iter( p->GetTracks() );
      for (Track *t = iter.First(); t; t = iter.Next()) {
         if (t->GetKind() == Track::Wave
#if defined(USE_MIDI)
         || t->GetKind() == Track::Note
#endif
         ) {
            tracks = true;
            break;
         }
      }
   }

   const bool enablePlay = (!recording) || (tracks && !busy);
   mPlay->SetEnabled(enablePlay);
   // Enable and disable the other play button 
   if (p)
   {
      TranscriptionToolBar *const pttb = p->GetTranscriptionToolBar();
      if (pttb)
         pttb->SetEnabled(enablePlay);
   }

   mRecord->SetEnabled(!busy && !playing);

   mStop->SetEnabled(busy);
   mRewind->SetEnabled(!busy);
   mFF->SetEnabled(tracks && !busy);
   mPause->SetEnabled(true);
}