Audacity  2.2.2
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ControlToolBar Class Referencefinal

A ToolBar that has the main Transport buttons. More...

#include <ControlToolBar.h>

Inheritance diagram for ControlToolBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Types

enum  PlayAppearance {
  PlayAppearance::Straight, PlayAppearance::Looped, PlayAppearance::CutPreview, PlayAppearance::Scrub,
  PlayAppearance::Seek
}
 
- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 

Public Member Functions

 ControlToolBar ()
 Methods for ControlToolBar. More...
 
virtual ~ControlToolBar ()
 
void Create (wxWindow *parent) override
 
void UpdatePrefs () override
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnRewind (wxCommandEvent &evt)
 
void OnPlay (wxCommandEvent &evt)
 
void OnStop (wxCommandEvent &evt)
 
void OnRecord (wxCommandEvent &evt)
 
bool DoRecord (AudacityProject &project, const TransportTracks &transportTracks, double t0, double t1, bool altAppearance, const AudioIOStartStreamOptions &options)
 
void OnFF (wxCommandEvent &evt)
 
void OnPause (wxCommandEvent &evt)
 
void SetPlay (bool down, PlayAppearance appearance=PlayAppearance::Straight)
 
void SetStop (bool down)
 
void SetRecord (bool down, bool altAppearance=false)
 
bool IsPauseDown () const
 
bool IsRecordDown () const
 
bool CanStopAudioStream ()
 
void PlayCurrentRegion (bool looped=false, bool cutpreview=false)
 
int PlayPlayRegion (const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
 
void PlayDefault ()
 
void StopPlaying (bool stopStream=true)
 
void Pause ()
 
void Populate () override
 
void Repaint (wxDC *dc) override
 
void EnableDisableButtons () override
 
void ReCreateButtons () override
 
void RegenerateTooltips () override
 
int WidthForStatusBar (wxStatusBar *const)
 
void UpdateStatusBar (AudacityProject *pProject)
 
void StartScrollingIfPreferred ()
 
void StartScrolling ()
 
void StopScrolling ()
 
void CommitRecording ()
 
void CancelRecording ()
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static bool IsTransportingPinned ()
 
static WaveTrackArray ChooseExistingRecordingTracks (AudacityProject &proj, bool selectedOnly)
 
static bool UseDuplex ()
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 

Private Types

enum  {
  ID_PAUSE_BUTTON = 11000, ID_PLAY_BUTTON, ID_STOP_BUTTON, ID_FF_BUTTON,
  ID_REW_BUTTON, ID_RECORD_BUTTON, BUTTON_COUNT
}
 

Private Member Functions

void ArrangeButtons ()
 
void SetupCutPreviewTracks (double playStart, double cutStart, double cutEnd, double playEnd)
 
void ClearCutPreviewTracks ()
 
wxString StateForStatusBar ()
 

Static Private Member Functions

static AButtonMakeButton (ControlToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const wxChar *label)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled)
 

Private Attributes

AButtonmRewind
 
AButtonmPlay
 
AButtonmRecord
 
AButtonmPause
 
AButtonmStop
 
AButtonmFF
 
bool mPaused
 
bool mErgonomicTransportButtons
 
wxString mStrLocale
 
wxBoxSizer * mSizer
 
std::shared_ptr< TrackListmCutPreviewTracks
 
wxString mStatePlay
 
wxString mStateStop
 
wxString mStateRecord
 
wxString mStatePause
 

Static Private Attributes

static AudacityProjectmBusyProject = NULL
 

Additional Inherited Members

- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A ToolBar that has the main Transport buttons.

In the GUI, this is referred to as "Transport Toolbar", as it corresponds to commands in the Transport menu. "Control Toolbar" is historic. This class, which is a child of Toolbar, creates the window containing the Transport (rewind/play/stop/record/ff) buttons. The window can be embedded within a normal project window, or within a ToolbarFrame that is managed by a global ToolBarStub called gControlToolBarStub.

All of the controls in this window were custom-written for Audacity - they are not native controls on any platform - however, it is intended that the images could be easily replaced to allow "skinning" or just customization to match the look and feel of each platform.

Definition at line 47 of file ControlToolBar.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
ID_PAUSE_BUTTON 
ID_PLAY_BUTTON 
ID_STOP_BUTTON 
ID_FF_BUTTON 
ID_REW_BUTTON 
ID_RECORD_BUTTON 
BUTTON_COUNT 

Definition at line 159 of file ControlToolBar.h.

Enumerator
Straight 
Looped 
CutPreview 
Scrub 
Seek 

Definition at line 82 of file ControlToolBar.h.

82  {
83  Straight, Looped, CutPreview, Scrub, Seek
84  };

Constructor & Destructor Documentation

ControlToolBar::ControlToolBar ( )

Methods for ControlToolBar.

Definition at line 103 of file ControlToolBar.cpp.

References gPrefs, and XO.

104 : ToolBar(TransportBarID, _("Transport"), wxT("Control"))
105 {
106  mPaused = false;
107 
108  gPrefs->Read(wxT("/GUI/ErgonomicTransportButtons"), &mErgonomicTransportButtons, true);
109  mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
110 
111  mSizer = NULL;
112 
113  /* i18n-hint: These are strings for the status bar, and indicate whether Audacity
114  is playing or recording or stopped, and whether it is paused. */
115  mStatePlay = XO("Playing");
116  mStateStop = XO("Stopped");
117  mStateRecord = XO("Recording");
118  mStatePause = XO("Paused");
119 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
wxString mStateRecord
#define XO(s)
Definition: Internat.h:33
wxString mStateStop
wxString mStatePause
wxString mStrLocale
wxBoxSizer * mSizer
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ToolBar(int type, const wxString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:311
bool mErgonomicTransportButtons
wxString mStatePlay
ControlToolBar::~ControlToolBar ( )
virtual

Definition at line 121 of file ControlToolBar.cpp.

122 {
123 }

Member Function Documentation

void ControlToolBar::ArrangeButtons ( )
private

Definition at line 333 of file ControlToolBar.cpp.

References ToolBar::Add(), ToolBar::Detach(), ToolBar::GetSizer(), mErgonomicTransportButtons, mFF, mPause, mPlay, mRecord, mRewind, mSizer, mStop, and safenew.

Referenced by Populate().

334 {
335  int flags = wxALIGN_CENTER | wxRIGHT;
336 
337  // (Re)allocate the button sizer
338  if( mSizer )
339  {
340  Detach( mSizer );
341  std::unique_ptr < wxSizer > {mSizer}; // DELETE it
342  }
343 
344  Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
345 
346  // Start with a little extra space
347  mSizer->Add( 5, 55 );
348 
349  // Add the buttons in order based on ergonomic setting
351  {
352  mPause->MoveBeforeInTabOrder( mRecord );
353  mPlay->MoveBeforeInTabOrder( mRecord );
354  mStop->MoveBeforeInTabOrder( mRecord );
355  mRewind->MoveBeforeInTabOrder( mRecord );
356  mFF->MoveBeforeInTabOrder( mRecord );
357 
358  mSizer->Add( mPause, 0, flags, 2 );
359  mSizer->Add( mPlay, 0, flags, 2 );
360  mSizer->Add( mStop, 0, flags, 2 );
361  mSizer->Add( mRewind, 0, flags, 2 );
362  mSizer->Add( mFF, 0, flags, 10 );
363  mSizer->Add( mRecord, 0, flags, 5 );
364  }
365  else
366  {
367  mRewind->MoveBeforeInTabOrder( mFF );
368  mPlay->MoveBeforeInTabOrder( mFF );
369  mRecord->MoveBeforeInTabOrder( mFF );
370  mPause->MoveBeforeInTabOrder( mFF );
371  mStop->MoveBeforeInTabOrder( mFF );
372 
373  mSizer->Add( mRewind, 0, flags, 2 );
374  mSizer->Add( mPlay, 0, flags, 2 );
375  mSizer->Add( mRecord, 0, flags, 2 );
376  mSizer->Add( mPause, 0, flags, 2 );
377  mSizer->Add( mStop, 0, flags, 2 );
378  mSizer->Add( mFF, 0, flags, 5 );
379  }
380 
381  // Layout the sizer
382  mSizer->Layout();
383 
384  // Layout the toolbar
385  Layout();
386 
387  // (Re)Establish the minimum size
388  SetMinSize( GetSizer()->GetMinSize() );
389 }
AButton * mRecord
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:606
AButton * mPause
void Detach(wxWindow *window)
Definition: ToolBar.cpp:680
#define safenew
Definition: Audacity.h:230
wxBoxSizer * mSizer
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:614
AButton * mRewind
bool mErgonomicTransportButtons
void ControlToolBar::CancelRecording ( )

Definition at line 1585 of file ControlToolBar.cpp.

References GetActiveProject().

Referenced by DoRecord().

1586 {
1587  const auto project = GetActiveProject();
1588  project->GetTracks()->ClearPendingTracks();
1589 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
bool ControlToolBar::CanStopAudioStream ( )

Definition at line 820 of file ControlToolBar.cpp.

References gAudioIO, GetActiveProject(), AudioIO::GetOwningProject(), AudioIO::IsMonitoring(), and AudioIO::IsStreamActive().

Referenced by DoRecord(), EnableDisableButtons(), OnPause(), OnPlay(), OnStop(), Pause(), PlayCurrentRegion(), PlayPlayRegion(), and StopPlaying().

821 {
822  return (!gAudioIO->IsStreamActive() ||
823  gAudioIO->IsMonitoring() ||
825 }
bool IsStreamActive() const
Returns true if the audio i/o is running at all, but not during cleanup.
Definition: AudioIO.cpp:2753
AudacityProject * GetOwningProject() const
Definition: AudioIO.h:390
bool IsMonitoring() const
Returns true if we're monitoring input (but not recording or playing actual audio) ...
Definition: AudioIO.cpp:2777
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
WaveTrackArray ControlToolBar::ChooseExistingRecordingTracks ( AudacityProject proj,
bool  selectedOnly 
)
static

Definition at line 900 of file ControlToolBar.cpp.

References TrackListIterator::First(), Track::GetLink(), Track::GetLinked(), Track::GetSelected(), AudacityProject::GetTracks(), gPrefs, TrackListIterator::Next(), and Track::Wave.

Referenced by OnRecord().

902 {
903  auto p = &proj;
904  size_t recordingChannels =
905  std::max(0L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
906  bool strictRules = (recordingChannels <= 2);
907 
908  // Iterate over all wave tracks, or over selected wave tracks only.
909  //
910  // In the usual cases of one or two recording channels, seek a first-fit
911  // unbroken sub-sequence for which the total number of channels matches the
912  // required number exactly. Never drop inputs or fill only some channels
913  // of a track.
914  //
915  // In case of more than two recording channels, choose tracks only among the
916  // selected. Simply take the earliest wave tracks, until the number of
917  // channels is enough. If there are fewer channels than inputs, but at least
918  // one channel, then some of the input channels will be dropped.
919  //
920  // Resulting tracks may be non-consecutive within the list of all tracks
921  // (there may be non-wave tracks between, or non-selected tracks when
922  // considering selected tracks only.)
923 
924  if (!strictRules && !selectedOnly)
925  return {};
926 
927  auto trackList = p->GetTracks();
928  TrackListIterator it(trackList);
929  std::vector<unsigned> channelCounts;
930  WaveTrackArray candidates;
931  for (Track *tt = it.First(); tt; tt = it.Next()) {
932  // Eliminate certain tracks from consideration
933  if (tt->GetKind() != Track::Wave)
934  continue;
935  WaveTrack *candidate = static_cast<WaveTrack *>(tt);
936  if (candidate->GetLink() && !candidate->GetLinked())
937  // Don't re-consider right channel apart from the left
938  continue;
939  if (selectedOnly && !candidate->GetSelected())
940  continue;
941 
942  // count channels in this track
943  unsigned nChannels = 0;
944  // This is written with odd seeming generality, looking forward to
945  // the rewrite that removes assumption of at-most-stereo
946  for (auto channel = candidate; channel;
947  channel = channel->GetLinked()
948  ? static_cast<WaveTrack*>(channel->GetLink()) : nullptr)
949  ++nChannels;
950 
951  if (strictRules && nChannels > recordingChannels) {
952  // The recording would under-fill this track's channels
953  // Can't use any partial accumulated results
954  // either. Keep looking.
955  candidates.clear();
956  channelCounts.clear();
957  continue;
958  }
959  else {
960  // Might use this but may have to discard some of the accumulated
961  while(strictRules &&
962  nChannels + candidates.size() > recordingChannels) {
963  auto nOldChannels = channelCounts[0];
964  wxASSERT(nOldChannels > 0);
965  channelCounts.erase(channelCounts.begin());
966  candidates.erase(candidates.begin(),
967  candidates.begin() + nOldChannels);
968  }
969  channelCounts.push_back(nChannels);
970  for (auto channel = candidate; channel;
971  channel = channel->GetLinked()
972  ? static_cast<WaveTrack*>(channel->GetLink()) : nullptr) {
973  candidates.push_back(Track::Pointer<WaveTrack>(channel));
974  if(candidates.size() == recordingChannels)
975  // Done!
976  return candidates;
977  }
978  }
979  }
980 
981  if (!strictRules && !candidates.empty())
982  // good enough
983  return candidates;
984 
985  // If the loop didn't exit early, we could not find enough channels
986  return {};
987 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool GetSelected() const
Definition: Track.h:284
bool GetLinked() const
Definition: Track.h:287
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:67
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:410
Track * GetLink() const
Definition: Track.cpp:269
TrackList * GetTracks()
Definition: Project.h:193
void ControlToolBar::ClearCutPreviewTracks ( )
private

Definition at line 1439 of file ControlToolBar.cpp.

References mCutPreviewTracks.

Referenced by SetupCutPreviewTracks(), and StopPlaying().

1440 {
1441  if (mCutPreviewTracks)
1442  mCutPreviewTracks->Clear();
1443  mCutPreviewTracks.reset();
1444 }
std::shared_ptr< TrackList > mCutPreviewTracks
void ControlToolBar::CommitRecording ( )

Definition at line 1579 of file ControlToolBar.cpp.

References GetActiveProject().

Referenced by AudioIO::StopStream().

1580 {
1581  const auto project = GetActiveProject();
1582  project->GetTracks()->ApplyPendingTracks();
1583 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void ControlToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 126 of file ControlToolBar.cpp.

References ToolBar::Create().

127 {
128  ToolBar::Create(parent);
129 }
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:441
bool ControlToolBar::DoRecord ( AudacityProject project,
const TransportTracks transportTracks,
double  t0,
double  t1,
bool  altAppearance,
const AudioIOStartStreamOptions options 
)

Definition at line 1102 of file ControlToolBar.cpp.

References _(), AlwaysEnabledFlag, AudioIONotBusyFlag, CancelRecording(), CanStopAudioStream(), CanStopAudioStreamFlag, TransportTracks::captureTracks, TrackListIterator::First(), gAudioIO, GetActiveProject(), TracksPrefs::GetDefaultAudioTrackNamePreference(), AudioIO::GetNumCaptureChannels(), gPrefs, AudioIO::IsBusy(), AudioIO::LastPaErrorString(), Track::LeftChannel, make_iterator_range(), mBusyProject, Track::MonoChannel, mRecord, TrackListIterator::Next(), AButton::PopUp(), AButton::PushDown(), WaveTrack::Reinit(), Track::RightChannel, SetPlay(), SetRecord(), SetStop(), ShowErrorDialog(), StartScrollingIfPreferred(), AudioIO::StartStream(), AudacityProject::TryToMakeActionAllowed(), UpdateStatusBar(), and Track::Wave.

Referenced by AudacityProject::OnPunchAndRoll(), and OnRecord().

1107 {
1108  CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
1109 
1110  // NB: The call may have the side effect of changing flags.
1111  bool allowed = project.TryToMakeActionAllowed(
1112  flags,
1115 
1116  if (!allowed)
1117  return false;
1118  // ...end of code from CommandHandler.
1119 
1120  if (gAudioIO->IsBusy()) {
1122  mRecord->PopUp();
1123  else
1124  mRecord->PushDown();
1125  return false;
1126  }
1127 
1128  SetRecord(true, altAppearance);
1129 
1130  bool success = false;
1131  auto cleanup = finally([&] {
1132  if (!success) {
1133  SetPlay(false);
1134  SetStop(false);
1135  SetRecord(false);
1136  }
1137 
1138  // Success or not:
1140  });
1141 
1142  auto transportTracks = tracks;
1143 
1144  // Will replace any given capture tracks with temporaries
1145  transportTracks.captureTracks.clear();
1146 
1147  const auto p = &project;
1148 
1149  bool appendRecord = !tracks.captureTracks.empty();
1150 
1151  {
1152  if (appendRecord) {
1153  // Append recording:
1154  // Pad selected/all wave tracks to make them all the same length
1155  for (const auto &wt : tracks.captureTracks)
1156  {
1157  auto endTime = wt->GetEndTime();
1158 
1159  // If the track was chosen for recording and playback both,
1160  // remember the original in preroll tracks, before making the
1161  // pending replacement.
1162  bool prerollTrack = make_iterator_range(transportTracks.playbackTracks).contains(wt);
1163  if (prerollTrack)
1164  transportTracks.prerollTracks.push_back(wt);
1165 
1166  // A function that copies all the non-sample data between
1167  // wave tracks; in case the track recorded to changes scale
1168  // type (for instance), during the recording.
1169  auto updater = [](Track &d, const Track &s){
1170  auto &dst = static_cast<WaveTrack&>(d);
1171  auto &src = static_cast<const WaveTrack&>(s);
1172  dst.Reinit(src);
1173  };
1174 
1175  // Get a copy of the track to be appended, to be pushed into
1176  // undo history only later.
1177  auto pending = std::static_pointer_cast<WaveTrack>(
1178  p->GetTracks()->RegisterPendingChangedTrack(
1179  updater, wt.get() ) );
1180 
1181  // End of current track is before or at recording start time.
1182  // Less than or equal, not just less than, to ensure a clip boundary.
1183  // when append recording.
1184  if (endTime <= t0) {
1185 
1186  // Pad the recording track with silence, up to the
1187  // maximum time.
1188  auto newTrack = p->GetTrackFactory()->NewWaveTrack();
1189  newTrack->SetWaveColorIndex( wt->GetWaveColorIndex() );
1190  newTrack->InsertSilence(0.0, t0 - endTime);
1191  newTrack->Flush();
1192  pending->Clear(endTime, t0);
1193  pending->Paste(endTime, newTrack.get());
1194  }
1195  transportTracks.captureTracks.push_back(pending);
1196  }
1197  p->GetTracks()->UpdatePendingTracks();
1198  }
1199 
1200  if( transportTracks.captureTracks.empty() )
1201  { // recording to NEW track(s).
1202  bool recordingNameCustom, useTrackNumber, useDateStamp, useTimeStamp;
1203  wxString defaultTrackName, defaultRecordingTrackName;
1204 
1205  // Count the tracks.
1206  int numTracks = 0;
1207 
1208  TrackList *trackList = p->GetTracks();
1209  TrackListIterator it(trackList);
1210  for (Track *tt = it.First(); tt; tt = it.Next()) {
1211  if (tt->GetKind() == Track::Wave && !tt->GetLinked())
1212  numTracks++;
1213  }
1214  numTracks++;
1215 
1216  auto recordingChannels = std::max(1L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
1217 
1218  gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &recordingNameCustom, false);
1219  gPrefs->Read(wxT("/GUI/TrackNames/TrackNumber"), &useTrackNumber, false);
1220  gPrefs->Read(wxT("/GUI/TrackNames/DateStamp"), &useDateStamp, false);
1221  gPrefs->Read(wxT("/GUI/TrackNames/TimeStamp"), &useTimeStamp, false);
1223  gPrefs->Read(wxT("/GUI/TrackNames/RecodingTrackName"), &defaultRecordingTrackName, defaultTrackName);
1224 
1225  wxString baseTrackName = recordingNameCustom? defaultRecordingTrackName : defaultTrackName;
1226 
1227  for (int c = 0; c < recordingChannels; c++) {
1228  std::shared_ptr<WaveTrack> newTrack{
1229  p->GetTrackFactory()->NewWaveTrack().release()
1230  };
1231 
1232  // Quantize bounds to the rate of the new track.
1233  if (c == 0) {
1234  if (t0 < DBL_MAX)
1235  t0 = newTrack->LongSamplesToTime(newTrack->TimeToLongSamples(t0));
1236  if (t1 < DBL_MAX)
1237  t1 = newTrack->LongSamplesToTime(newTrack->TimeToLongSamples(t1));
1238  }
1239 
1240  newTrack->SetOffset(t0);
1241  wxString nameSuffix = wxString(wxT(""));
1242 
1243  if (useTrackNumber) {
1244  nameSuffix += wxString::Format(wxT("%d"), numTracks + c);
1245  }
1246 
1247  if (useDateStamp) {
1248  if (!nameSuffix.IsEmpty()) {
1249  nameSuffix += wxT("_");
1250  }
1251  nameSuffix += wxDateTime::Now().FormatISODate();
1252  }
1253 
1254  if (useTimeStamp) {
1255  if (!nameSuffix.IsEmpty()) {
1256  nameSuffix += wxT("_");
1257  }
1258  nameSuffix += wxDateTime::Now().FormatISOTime();
1259  }
1260 
1261  // ISO standard would be nice, but ":" is unsafe for file name.
1262  nameSuffix.Replace(wxT(":"), wxT("-"));
1263 
1264  if (baseTrackName.IsEmpty()) {
1265  newTrack->SetName(nameSuffix);
1266  }
1267  else if (nameSuffix.IsEmpty()) {
1268  newTrack->SetName(baseTrackName);
1269  }
1270  else {
1271  newTrack->SetName(baseTrackName + wxT("_") + nameSuffix);
1272  }
1273 
1274  if ((recordingChannels > 2) && !(p->GetTracksFitVerticallyZoomed())) {
1275  newTrack->SetMinimized(true);
1276  }
1277 
1278  if (recordingChannels == 2) {
1279  if (c == 0) {
1280  newTrack->SetChannel(Track::LeftChannel);
1281  newTrack->SetLinked(true);
1282  }
1283  else {
1284  newTrack->SetChannel(Track::RightChannel);
1285  }
1286  }
1287  else {
1288  newTrack->SetChannel( Track::MonoChannel );
1289  }
1290 
1291  p->GetTracks()->RegisterPendingNewTrack( newTrack );
1292  transportTracks.captureTracks.push_back(newTrack);
1293  // Bug 1548. New track needs the focus.
1294  p->GetTrackPanel()->SetFocusedTrack( newTrack.get() );
1295  }
1296  }
1297 
1298  //Automated Input Level Adjustment Initialization
1299  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
1300  gAudioIO->AILAInitialize();
1301  #endif
1302 
1303  int token = gAudioIO->StartStream(transportTracks, t0, t1, options);
1304 
1305  success = (token != 0);
1306 
1307  if (success) {
1308  p->SetAudioIOToken(token);
1309  mBusyProject = p;
1310 
1312  }
1313  else {
1314  CancelRecording();
1315 
1316  // Show error message if stream could not be opened
1317  wxString msg = wxString::Format(_("Error opening recording device.\nError code: %s"), gAudioIO->LastPaErrorString());
1318  ShowErrorDialog(this, _("Error"), msg, wxT("Error_opening_sound_device"));
1319  }
1320  }
1321 
1322  return success;
1323 }
int StartStream(const TransportTracks &tracks, double t0, double t1, const AudioIOStartStreamOptions &options)
Start recording or playing back audio.
Definition: AudioIO.cpp:1711
AButton * mRecord
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
A list of TrackListNode items.
Definition: Track.h:627
void PopUp()
Definition: AButton.cpp:525
WaveTrackConstArray prerollTracks
Definition: AudioIO.h:166
void Reinit(const WaveTrack &orig)
Definition: WaveTrack.cpp:170
WaveTrackArray playbackTracks
Definition: AudioIO.h:159
static wxString GetDefaultAudioTrackNamePreference()
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:542
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2745
void ShowErrorDialog(wxWindow *parent, const wxString &dlogTitle, const wxString &message, const wxString &helpPage, const bool Close)
Displays an error dialog with a button that offers help.
void UpdateStatusBar(AudacityProject *pProject)
wxString LastPaErrorString()
Definition: AudioIO.cpp:1660
void SetStop(bool down)
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:596
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:410
void StartScrollingIfPreferred()
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static AudacityProject * mBusyProject
CommandFlag
Definition: CommandFlag.h:16
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void PushDown()
Definition: AButton.cpp:517
void SetRecord(bool down, bool altAppearance=false)
WaveTrackArray captureTracks
Definition: AudioIO.h:160
bool TryToMakeActionAllowed(CommandFlag &flags, CommandFlag flagsRqd, CommandFlag mask)
Definition: Project.cpp:2340
void ControlToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 451 of file ControlToolBar.cpp.

References CanStopAudioStream(), gAudioIO, GetActiveProject(), AudacityProject::GetTracks(), AudacityProject::GetTranscriptionToolBar(), AudioIO::IsBusy(), AButton::IsDown(), IsPauseDown(), mFF, mPause, mPlay, mRecord, mRewind, mStop, AButton::SetEnabled(), and TranscriptionToolBar::SetEnabled().

Referenced by ReCreateButtons(), SetPlay(), SetRecord(), and SetStop().

452 {
454  bool tracks = false;
455 
456  bool paused = mPause->IsDown();
457  bool playing = mPlay->IsDown();
458  bool recording = mRecord->IsDown();
459  bool busy = gAudioIO->IsBusy();
460 
461  // Only interested in audio type tracks
462  if (p) {
463  TrackListIterator iter( p->GetTracks() );
464  for (Track *t = iter.First(); t; t = iter.Next()) {
465  if (dynamic_cast<const AudioTrack*>(t)) {
466  tracks = true;
467  break;
468  }
469  }
470  }
471 
472  if (p) {
473  TranscriptionToolBar *const playAtSpeedTB = p->GetTranscriptionToolBar();
474  if (playAtSpeedTB)
475  playAtSpeedTB->SetEnabled(CanStopAudioStream() && tracks && !recording);
476  }
477 
478  mPlay->SetEnabled(CanStopAudioStream() && tracks && !recording);
480  CanStopAudioStream() &&
481  !(busy && !recording && !paused) &&
482  !(playing && !paused)
483  );
484  mStop->SetEnabled(CanStopAudioStream() && (playing || recording));
485  mRewind->SetEnabled(IsPauseDown() || (!playing && !recording));
486  mFF->SetEnabled(tracks && (IsPauseDown() || (!playing && !recording)));
487 
488  //auto pProject = GetActiveProject();
490 }
AButton * mRecord
bool IsDown()
Definition: AButton.h:123
AButton * mPause
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2745
bool IsPauseDown() const
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetEnabled(bool state)
Definition: AButton.h:98
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
TranscriptionToolBar * GetTranscriptionToolBar()
Definition: Project.cpp:5120
void SetEnabled(bool enabled)
An iterator for a TrackList.
Definition: Track.h:410
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
AButton * mRewind
TrackList * GetTracks()
Definition: Project.h:193
A kind of ToolBar used to help with analysing voice recordings.
bool ControlToolBar::IsPauseDown ( ) const

Definition at line 535 of file ControlToolBar.cpp.

References AButton::IsDown(), and mPause.

Referenced by EnableDisableButtons(), and Scrubber::OnActivateOrDeactivateApp().

536 {
537  return mPause->IsDown();
538 }
bool IsDown()
Definition: AButton.h:123
AButton * mPause
bool ControlToolBar::IsRecordDown ( ) const

Definition at line 540 of file ControlToolBar.cpp.

References AButton::IsDown(), and mRecord.

541 {
542  return mRecord->IsDown();
543 }
AButton * mRecord
bool IsDown()
Definition: AButton.h:123
bool ControlToolBar::IsTransportingPinned ( )
static

Definition at line 1504 of file ControlToolBar.cpp.

References GetActiveProject(), TracksPrefs::GetPinnedHeadPreference(), AudacityProject::GetScrubber(), and Scrubber::ShouldScrubPinned().

Referenced by AdornedRulerPanel::DoDrawIndicator(), and StartScrollingIfPreferred().

1505 {
1507  return false;
1508  const auto &scrubber = ::GetActiveProject()->GetScrubber();
1509  return
1510  !(scrubber.HasMark() &&
1511  !scrubber.WasSpeedPlaying() &&
1513 }
Scrubber & GetScrubber()
Definition: Project.h:805
static bool ShouldScrubPinned()
Definition: Scrubbing.cpp:166
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
static bool GetPinnedHeadPreference()
void ControlToolBar::MakeAlternateImages ( AButton button,
int  idx,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled 
)
staticprivate

Definition at line 159 of file ControlToolBar.cpp.

References ThemeBase::ImageSize(), ToolBar::MakeAlternateImages(), and theTheme.

Referenced by Populate().

163 {
164  ToolBar::MakeAlternateImages(button, idx,
165  bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
166  eEnabledUp, eEnabledDown, eDisabled,
167  theTheme.ImageSize( bmpRecoloredUpLarge ));
168 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static void MakeAlternateImages(AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
Definition: ToolBar.cpp:801
AButton * ControlToolBar::MakeButton ( ControlToolBar pBar,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
bool  processdownevents,
const wxChar *  label 
)
staticprivate

Definition at line 133 of file ControlToolBar.cpp.

References ThemeBase::ImageSize(), ToolBar::MakeButton(), AButton::SetFocusRect(), and theTheme.

Referenced by Populate().

138 {
139  AButton *r = ToolBar::MakeButton(pBar,
140  bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
141  eEnabledUp, eEnabledDown, eDisabled,
142  wxWindowID(id),
143  wxDefaultPosition, processdownevents,
144  theTheme.ImageSize( bmpRecoloredUpLarge ));
145  r->SetLabel(label);
146  enum { deflation =
147 #ifdef __WXMAC__
148  6
149 #else
150  12
151 #endif
152  };
153  r->SetFocusRect( r->GetClientRect().Deflate( deflation, deflation ) );
154 
155  return r;
156 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void SetFocusRect(wxRect &r)
Definition: AButton.cpp:264
wxString label
Definition: Tags.cpp:733
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:768
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void ControlToolBar::OnFF ( wxCommandEvent &  evt)

Definition at line 1381 of file ControlToolBar.cpp.

References GetActiveProject(), mFF, AButton::PopUp(), AButton::PushDown(), AudacityProject::SkipEnd(), AudacityProject::StopIfPaused(), and AButton::WasShiftDown().

Referenced by AudacityProject::OnSkipEnd().

1382 {
1383  mFF->PushDown();
1384  mFF->PopUp();
1385 
1387 
1388  if (p) {
1389  p->StopIfPaused();
1390  p->SkipEnd(mFF->WasShiftDown());
1391  }
1392 }
void PopUp()
Definition: AButton.cpp:525
bool WasShiftDown()
Definition: AButton.cpp:485
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void StopIfPaused()
Definition: Menus.cpp:2382
void PushDown()
Definition: AButton.cpp:517
void SkipEnd(bool shift)
Definition: Project.cpp:5023
void ControlToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 772 of file ControlToolBar.cpp.

References gAudioIO, GetActiveProject(), AudioIO::IsBusy(), AudioIO::IsStreamActive(), PlayCurrentRegion(), SetPlay(), SetStop(), and StopPlaying().

773 {
774  if (event.ControlDown() || event.AltDown()) {
775  event.Skip();
776  return;
777  }
778 
779  // Does not appear to be needed on Linux. Perhaps on some other platform?
780  // If so, "!CanStopAudioStream()" should probably apply.
781  if (event.GetKeyCode() == WXK_SPACE) {
782  if (gAudioIO->IsStreamActive(GetActiveProject()->GetAudioIOToken())) {
783  SetPlay(false);
784  SetStop(true);
785  StopPlaying();
786  }
787  else if (!gAudioIO->IsBusy()) {
788  //SetPlay(true);// Not needed as done in PlayPlayRegion
789  SetStop(false);
791  }
792  return;
793  }
794  event.Skip();
795 }
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
void PlayCurrentRegion(bool looped=false, bool cutpreview=false)
void StopPlaying(bool stopStream=true)
bool IsStreamActive() const
Returns true if the audio i/o is running at all, but not during cleanup.
Definition: AudioIO.cpp:2753
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2745
void SetStop(bool down)
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void ControlToolBar::OnPause ( wxCommandEvent &  evt)

Definition at line 1326 of file ControlToolBar.cpp.

References CanStopAudioStream(), gAudioIO, GetActiveProject(), AudacityProject::GetScrubber(), AudioIO::IsScrubbing(), Scrubber::IsSpeedPlaying(), mPause, mPaused, OnStop(), Scrubber::Pause(), AButton::PopUp(), AButton::PushDown(), AudioIO::SetPaused(), and UpdateStatusBar().

Referenced by AudacityProject::OnPause(), and Pause().

1327 {
1328  if (!CanStopAudioStream()) {
1329  return;
1330  }
1331 
1332 
1333  if(mPaused)
1334  {
1335  mPause->PopUp();
1336  mPaused=false;
1337  }
1338  else
1339  {
1340  mPause->PushDown();
1341  mPaused=true;
1342  }
1343 
1344 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
1345 
1346  // Bug 1494 - Pausing a seek or scrub should just STOP as
1347  // it is confusing to be in a paused scrub state.
1348  bool bStopInstead = mPaused &&
1349  gAudioIO->IsScrubbing() &&
1351 
1352  if (bStopInstead) {
1353  wxCommandEvent dummy;
1354  OnStop(dummy);
1355  return;
1356  }
1357 
1358  if (gAudioIO->IsScrubbing())
1360  else
1361 #endif
1362  {
1364  }
1365 
1367 }
void Pause(bool paused)
Definition: Scrubbing.cpp:813
void PopUp()
Definition: AButton.cpp:525
Scrubber & GetScrubber()
Definition: Project.h:805
AButton * mPause
bool IsSpeedPlaying() const
Definition: Scrubbing.h:97
void UpdateStatusBar(AudacityProject *pProject)
void OnStop(wxCommandEvent &evt)
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
bool IsScrubbing() const
Definition: AudioIO.h:358
void PushDown()
Definition: AButton.cpp:517
void SetPaused(bool state)
Pause and un-pause playback and recording.
Definition: AudioIO.cpp:2696
void ControlToolBar::OnPlay ( wxCommandEvent &  evt)

Definition at line 797 of file ControlToolBar.cpp.

References CanStopAudioStream(), GetActiveProject(), PlayDefault(), StopPlaying(), and UpdateStatusBar().

798 {
799  auto p = GetActiveProject();
800 
801  if (!CanStopAudioStream())
802  return;
803 
804  StopPlaying();
805 
806  if (p) p->TP_DisplaySelection();
807 
808  auto cleanup = finally( [&]{ UpdateStatusBar(p); } );
809  PlayDefault();
810 }
void StopPlaying(bool stopStream=true)
void UpdateStatusBar(AudacityProject *pProject)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void ControlToolBar::OnRecord ( wxCommandEvent &  evt)

Definition at line 989 of file ControlToolBar.cpp.

References TransportTracks::captureTracks, ChooseExistingRecordingTracks(), DoRecord(), TrackListIterator::First(), GetActiveProject(), GetAllPlaybackTracks(), AudacityProject::GetDefaultPlayOptions(), WaveTrack::GetEndTime(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), Track::GetSelected(), AudacityProject::GetTracks(), gPrefs, mRecord, TrackListIterator::Next(), TransportTracks::playbackTracks, UseDuplex(), AButton::WasShiftDown(), and Track::Wave.

Referenced by AudacityProject::OnRecord(), and AudacityProject::OnRecord2ndChoice().

991 {
992  // TODO: It would be neater if Menu items and Toolbar buttons used the same code for
993  // enabling/disabling, and all fell into the same action routines.
994  // Here instead we reduplicate some logic (from CommandHandler) because it isn't
995  // normally used for buttons.
996 
997  // Code from CommandHandler start...
999  wxASSERT(p);
1000  if (!p)
1001  return;
1002 
1003  bool altAppearance = mRecord->WasShiftDown();
1004  if (evt.GetInt() == 1) // used when called by keyboard shortcut. Default (0) ignored.
1005  altAppearance = true;
1006  if (evt.GetInt() == 2)
1007  altAppearance = false;
1008 
1009  bool bPreferNewTrack;
1010  gPrefs->Read("/GUI/PreferNewTrackRecord", &bPreferNewTrack, false);
1011  const bool appendRecord = (altAppearance == bPreferNewTrack);
1012 
1013  if (p) {
1014  double t0 = p->GetSel0();
1015  double t1 = p->GetSel1();
1016  // When no time selection, recording duration is 'unlimited'.
1017  if (t1 == t0)
1018  t1 = DBL_MAX;
1019 
1020  double allt0 = t0;
1021 
1022  WaveTrackArray existingTracks;
1023 
1024  double selt0 = t0;
1025  if (appendRecord) {
1026  TrackList *trackList = p->GetTracks();
1027  TrackListIterator it(trackList);
1028 
1029  // Find the maximum end time of selected and all wave tracks
1030  for (Track *tt = it.First(); tt; tt = it.Next()) {
1031  if (tt->GetKind() == Track::Wave) {
1032  WaveTrack *wt = static_cast<WaveTrack *>(tt);
1033  if (wt->GetEndTime() > allt0)
1034  allt0 = wt->GetEndTime();
1035 
1036  if (wt->GetSelected()) {
1037  if (wt->GetEndTime() > selt0)
1038  selt0 = wt->GetEndTime();
1039  }
1040  }
1041  }
1042 
1043  // Try to find wave tracks to record into. (If any are selected,
1044  // try to choose only from them; else if wave tracks exist, may record into any.)
1045  existingTracks = ChooseExistingRecordingTracks(*p, true);
1046  if (!existingTracks.empty()) {
1047  // selt0 is now: max(selection-start, end-of-selected-wavetracks)
1048  t0 = selt0;
1049  }
1050  else {
1051  // allt0 is: max(selection-start, end-of-all-tracks)
1052  // Use end time of all wave tracks if recording to non-selected
1053  t0 = allt0;
1054  existingTracks = ChooseExistingRecordingTracks(*p, false);
1055  // If suitable tracks still not found, will record into NEW ones,
1056  // but the choice of t0 does not depend on that.
1057  }
1058 
1059  // Whether we decided on NEW tracks or not:
1060  if (t1 <= p->GetSel0() && p->GetSel1() > p->GetSel0()) {
1061  t1 = p->GetSel1(); // record within the selection
1062  }
1063  else {
1064  t1 = DBL_MAX; // record for a long, long time
1065  }
1066  }
1067 
1068  TransportTracks transportTracks;
1069  if (UseDuplex()) {
1070  // Remove recording tracks from the list of tracks for duplex ("overdub")
1071  // playback.
1072  /* TODO: set up stereo tracks if that is how the user has set up
1073  * their preferences, and choose sample format based on prefs */
1074  transportTracks = GetAllPlaybackTracks(*p->GetTracks(), false, true);
1075  for (const auto &wt : existingTracks) {
1076  auto end = transportTracks.playbackTracks.end();
1077  auto it = std::find(transportTracks.playbackTracks.begin(), end, wt);
1078  if (it != end)
1079  transportTracks.playbackTracks.erase(it);
1080  }
1081  }
1082 
1083  transportTracks.captureTracks = existingTracks;
1085  DoRecord(*p, transportTracks, t0, t1, altAppearance, options);
1086  }
1087 }
AButton * mRecord
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
A list of TrackListNode items.
Definition: Track.h:627
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1301
double GetSel0() const
Definition: Project.h:205
bool WasShiftDown()
Definition: AButton.cpp:485
bool GetSelected() const
Definition: Track.h:284
WaveTrackArray playbackTracks
Definition: AudioIO.h:159
bool DoRecord(AudacityProject &project, const TransportTracks &transportTracks, double t0, double t1, bool altAppearance, const AudioIOStartStreamOptions &options)
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1889
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi)
Definition: Track.cpp:1585
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:67
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:410
static WaveTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
static bool UseDuplex()
double GetSel1() const
Definition: Project.h:206
TrackList * GetTracks()
Definition: Project.h:193
WaveTrackArray captureTracks
Definition: AudioIO.h:160
void ControlToolBar::OnRewind ( wxCommandEvent &  evt)

Definition at line 1369 of file ControlToolBar.cpp.

References GetActiveProject(), mRewind, AButton::PopUp(), AButton::PushDown(), AudacityProject::Rewind(), AudacityProject::StopIfPaused(), and AButton::WasShiftDown().

Referenced by AudacityProject::OnSkipStart().

1370 {
1371  mRewind->PushDown();
1372  mRewind->PopUp();
1373 
1375  if (p) {
1376  p->StopIfPaused();
1377  p->Rewind(mRewind->WasShiftDown());
1378  }
1379 }
void PopUp()
Definition: AButton.cpp:525
bool WasShiftDown()
Definition: AButton.cpp:485
void Rewind(bool shift)
Definition: Project.cpp:5005
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void StopIfPaused()
Definition: Menus.cpp:2382
AButton * mRewind
void PushDown()
Definition: AButton.cpp:517
void ControlToolBar::OnStop ( wxCommandEvent &  evt)
void ControlToolBar::Pause ( )

Definition at line 890 of file ControlToolBar.cpp.

References CanStopAudioStream(), gAudioIO, AudioIO::IsPaused(), OnPause(), and AudioIO::SetPaused().

Referenced by AudioIO::AudioCallback().

891 {
892  if (!CanStopAudioStream())
894  else {
895  wxCommandEvent dummy;
896  OnPause(dummy);
897  }
898 }
bool IsPaused() const
Find out if playback / recording is currently paused.
Definition: AudioIO.cpp:2713
void OnPause(wxCommandEvent &evt)
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
void SetPaused(bool state)
Pause and un-pause playback and recording.
Definition: AudioIO.cpp:2696
void ControlToolBar::PlayCurrentRegion ( bool  looped = false,
bool  cutpreview = false 
)

Definition at line 743 of file ControlToolBar.cpp.

References CanStopAudioStream(), CutPreview, GetActiveProject(), AudacityProject::GetDefaultPlayOptions(), AudacityProject::GetPlayRegion(), Looped, loopedPlay, normalPlay, AudioIOStartStreamOptions::playLooped, PlayPlayRegion(), and Straight.

Referenced by OnKeyEvent(), AudacityProject::OnPlayCutPreview(), AudacityProject::OnPlayLooped(), AudacityProject::OnPlayStop(), AudacityProject::OnPlayStopSelect(), and PlayDefault().

745 {
746  if (!CanStopAudioStream())
747  return;
748 
750 
751  if (p)
752  {
753 
754  double playRegionStart, playRegionEnd;
755  p->GetPlayRegion(&playRegionStart, &playRegionEnd);
756 
758  options.playLooped = looped;
759  if (cutpreview)
760  options.timeTrack = NULL;
761  ControlToolBar::PlayAppearance appearance =
765  PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd),
766  options,
768  appearance);
769  }
770 }
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1301
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
Defines a selected portion of a project.
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Project.cpp:5498
void ControlToolBar::PlayDefault ( )

Definition at line 827 of file ControlToolBar.cpp.

References mPlay, PlayCurrentRegion(), AButton::WasControlDown(), and AButton::WasShiftDown().

Referenced by OnPlay().

828 {
829  // Let control have precedence over shift
830  const bool cutPreview = mPlay->WasControlDown();
831  const bool looped = !cutPreview &&
832  mPlay->WasShiftDown();
833  PlayCurrentRegion(looped, cutPreview);
834 }
bool WasShiftDown()
Definition: AButton.cpp:485
void PlayCurrentRegion(bool looped=false, bool cutpreview=false)
bool WasControlDown()
Definition: AButton.cpp:490
int ControlToolBar::PlayPlayRegion ( const SelectedRegion selectedRegion,
const AudioIOStartStreamOptions options,
PlayMode  playMode,
PlayAppearance  appearance = PlayAppearance::Straight,
bool  backwards = false,
bool  playWhiteSpace = false 
)

Definition at line 545 of file ControlToolBar.cpp.

References _(), CanStopAudioStream(), CutPreview, AudioIOStartStreamOptions::cutPreviewGapLen, AudioIOStartStreamOptions::cutPreviewGapStart, AdornedRulerPanel::DrawBothOverlays(), TrackListIterator::First(), gAudioIO, GetActiveProject(), GetAllPlaybackTracks(), TrackList::GetEndTime(), AudacityProject::GetRulerPanel(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), TrackList::GetStartTime(), AudacityProject::GetTracks(), gPrefs, AudioIO::IsBusy(), mBusyProject, mCutPreviewTracks, min(), AudacityProject::mLastPlayMode, TrackListIterator::Next(), AudioIOStartStreamOptions::playLooped, AudioIOStartStreamOptions::pScrubbingOptions, AudioIO::SeekStream(), AudacityProject::SetAudioIOToken(), SetPlay(), SetRecord(), SetStop(), SetupCutPreviewTracks(), ShowErrorDialog(), StartScrollingIfPreferred(), AudioIO::StartStream(), SelectedRegion::t0(), SelectedRegion::t1(), and Track::Wave.

Referenced by Scrubber::MaybeStartScrubbing(), EffectUIHost::OnPlay(), AudacityProject::OnPlayAfterSelectionEnd(), AudacityProject::OnPlayAfterSelectionStart(), AudacityProject::OnPlayBeforeAndAfterSelectionEnd(), AudacityProject::OnPlayBeforeAndAfterSelectionStart(), AudacityProject::OnPlayBeforeSelectionEnd(), AudacityProject::OnPlayBeforeSelectionStart(), AudacityProject::OnPlayOneSecond(), AudacityProject::OnPlayToSelection(), TranscriptionToolBar::PlayAtSpeed(), PlayCurrentRegion(), AdornedRulerPanel::StartQPPlay(), and Scrubber::StartSpeedPlay().

552 {
553  if (!CanStopAudioStream())
554  return -1;
555 
556  bool useMidi = true;
557 
558  // Remove these lines to experiment with scrubbing/seeking of note tracks
559  if (options.pScrubbingOptions)
560  useMidi = false;
561 
562  // Uncomment this for laughs!
563  // backwards = true;
564 
565  double t0 = selectedRegion.t0();
566  double t1 = selectedRegion.t1();
567  // SelectedRegion guarantees t0 <= t1, so we need another boolean argument
568  // to indicate backwards play.
569  const bool looped = options.playLooped;
570 
571  if (backwards)
572  std::swap(t0, t1);
573 
574  SetPlay(true, appearance);
575 
576  bool success = false;
577  auto cleanup = finally( [&] {
578  if (!success) {
579  SetPlay(false);
580  SetStop(false);
581  SetRecord(false);
582  }
583  } );
584 
585  if (gAudioIO->IsBusy())
586  return -1;
587 
588  const bool cutpreview = appearance == PlayAppearance::CutPreview;
589  if (cutpreview && t0==t1)
590  return -1; /* msmeyer: makes no sense */
591 
593  if (!p)
594  return -1; // Should never happen, but...
595 
596  TrackList *t = p->GetTracks();
597  if (!t)
598  return -1; // Should never happen, but...
599 
600  p->mLastPlayMode = mode;
601 
602  bool hasaudio = false;
603  TrackListIterator iter(t);
604  for (Track *trk = iter.First(); trk; trk = iter.Next()) {
605  if (trk->GetKind() == Track::Wave
606 #ifdef EXPERIMENTAL_MIDI_OUT
607  || (trk->GetKind() == Track::Note && useMidi)
608 #endif
609  ) {
610  hasaudio = true;
611  break;
612  }
613  }
614 
615  double latestEnd = (playWhiteSpace)? t1 : t->GetEndTime();
616 
617  if (!hasaudio)
618  return -1; // No need to continue without audio tracks
619 
620 #if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
621  double init_seek = 0.0;
622 #endif
623 
624  if (t1 == t0) {
625  if (looped) {
626  // play selection if there is one, otherwise
627  // set start of play region to project start,
628  // and loop the project from current play position.
629 
630  if ((t0 > p->GetSel0()) && (t0 < p->GetSel1())) {
631  t0 = p->GetSel0();
632  t1 = p->GetSel1();
633  }
634  else {
635  // loop the entire project
636  t0 = t->GetStartTime();
637  t1 = t->GetEndTime();
638  }
639  } else {
640  // move t0 to valid range
641  if (t0 < 0) {
642  t0 = t->GetStartTime();
643  }
644  else if (t0 > t->GetEndTime()) {
645  t0 = t->GetEndTime();
646  }
647 #if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
648  else {
649  init_seek = t0; //AC: init_seek is where playback will 'start'
650  t0 = t->GetStartTime();
651  }
652 #endif
653  }
654  t1 = t->GetEndTime();
655  }
656  else {
657  // maybe t1 < t0, with backwards scrubbing for instance
658  if (backwards)
659  std::swap(t0, t1);
660 
661  t0 = std::max(0.0, std::min(t0, latestEnd));
662  t1 = std::max(0.0, std::min(t1, latestEnd));
663 
664  if (backwards)
665  std::swap(t0, t1);
666  }
667 
668  int token = -1;
669 
670  if (t1 != t0) {
671  if (cutpreview) {
672  const double tless = std::min(t0, t1);
673  const double tgreater = std::max(t0, t1);
674  double beforeLen, afterLen;
675  gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
676  gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
677  double tcp0 = tless-beforeLen;
678  double diff = tgreater - tless;
679  double tcp1 = (tgreater+afterLen) - diff;
680  SetupCutPreviewTracks(tcp0, tless, tgreater, tcp1);
681  if (backwards)
682  std::swap(tcp0, tcp1);
683  if (mCutPreviewTracks)
684  {
685  AudioIOStartStreamOptions myOptions = options;
686  myOptions.cutPreviewGapStart = t0;
687  myOptions.cutPreviewGapLen = t1 - t0;
688  token = gAudioIO->StartStream(
689  GetAllPlaybackTracks(*mCutPreviewTracks, false, useMidi),
690  tcp0, tcp1, myOptions);
691  }
692  else
693  // Cannot create cut preview tracks, clean up and exit
694  return -1;
695  }
696  else {
697  // Lifted the following into AudacityProject::GetDefaultPlayOptions()
698  /*
699  if (!timetrack) {
700  timetrack = t->GetTimeTrack();
701  }
702  */
703  token = gAudioIO->StartStream(
704  GetAllPlaybackTracks(*t, false, useMidi),
705  t0, t1, options);
706  }
707  if (token != 0) {
708  success = true;
709  p->SetAudioIOToken(token);
710  mBusyProject = p;
711 #if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
712  //AC: If init_seek was set, now's the time to make it happen.
713  gAudioIO->SeekStream(init_seek);
714 #endif
715  }
716  else {
717  // Bug1627 (part of it):
718  // infinite error spew when trying to start scrub:
719  // Problem was that the error dialog yields to events,
720  // causing recursion to this function in the scrub timer
721  // handler! Easy fix, just delay the user alert instead.
722  CallAfter( [=]{
723  // Show error message if stream could not be opened
724  ShowErrorDialog(this, _("Error"),
725  _("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
726  wxT("Error_opening_sound_device"));
727  });
728  }
729  }
730 
731  if (!success)
732  return -1;
733 
735 
736  // Let other UI update appearance
737  if (p)
739 
740  return token;
741 }
int StartStream(const TransportTracks &tracks, double t0, double t1, const AudioIOStartStreamOptions &options)
Start recording or playing back audio.
Definition: AudioIO.cpp:1711
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
A list of TrackListNode items.
Definition: Track.h:627
double t0() const
double GetSel0() const
Definition: Project.h:205
double GetStartTime() const
Definition: Track.cpp:1413
void DrawBothOverlays()
Definition: Ruler.cpp:3278
double GetEndTime() const
Definition: Track.cpp:1418
void SetAudioIOToken(int token)
Definition: Project.cpp:1481
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2745
ScrubbingOptions * pScrubbingOptions
Definition: AudioIO.h:151
double t1() const
void ShowErrorDialog(wxWindow *parent, const wxString &dlogTitle, const wxString &message, const wxString &helpPage, const bool Close)
Displays an error dialog with a button that offers help.
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi)
Definition: Track.cpp:1585
void SetStop(bool down)
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
AdornedRulerPanel * GetRulerPanel()
Definition: Project.cpp:1471
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void SetupCutPreviewTracks(double playStart, double cutStart, double cutEnd, double playEnd)
int min(int a, int b)
PlayMode mLastPlayMode
Definition: Project.h:559
An iterator for a TrackList.
Definition: Track.h:410
void StartScrollingIfPreferred()
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static AudacityProject * mBusyProject
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void SetRecord(bool down, bool altAppearance=false)
double GetSel1() const
Definition: Project.h:206
TrackList * GetTracks()
Definition: Project.h:193
void SeekStream(double seconds)
Move the playback / recording position of the current stream by the specified amount from where it is...
Definition: AudioIO.h:355
std::shared_ptr< TrackList > mCutPreviewTracks
void ControlToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 170 of file ControlToolBar.cpp.

References _(), ArrangeButtons(), ThemeBase::Colour(), AButton::FollowModifierKeys(), gPrefs, ID_FF_BUTTON, ID_PAUSE_BUTTON, ID_PLAY_BUTTON, ID_RECORD_BUTTON, ID_REW_BUTTON, ID_STOP_BUTTON, MakeAlternateImages(), MakeButton(), ToolBar::MakeButtonBackgroundsLarge(), mFF, mPause, mPlay, mRecord, mRewind, mStop, RegenerateTooltips(), and theTheme.

171 {
172  SetBackgroundColour( theTheme.Colour( clrMedium ) );
174 
175  mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled,
176  ID_PAUSE_BUTTON, true, _("Pause"));
177 
178  mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled,
179  ID_PLAY_BUTTON, true, _("Play"));
180  MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled);
182  bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled);
184  bmpScrub, bmpScrub, bmpScrubDisabled);
186  bmpSeek, bmpSeek, bmpSeekDisabled);
188 
189  mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled ,
190  ID_STOP_BUTTON, false, _("Stop"));
191 
192  mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled,
193  ID_REW_BUTTON, false, _("Skip to Start"));
194 
195  mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled,
196  ID_FF_BUTTON, false, _("Skip to End"));
197 
198  mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled,
199  ID_RECORD_BUTTON, false, _("Record"));
200 
201  bool bPreferNewTrack;
202  gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
203  if( !bPreferNewTrack )
204  MakeAlternateImages(*mRecord, 1, bmpRecordBelow, bmpRecordBelow,
205  bmpRecordBelowDisabled);
206  else
207  MakeAlternateImages(*mRecord, 1, bmpRecordBeside, bmpRecordBeside,
208  bmpRecordBesideDisabled);
209 
211 
212 #if wxUSE_TOOLTIPS
214  wxToolTip::Enable(true);
215  wxToolTip::SetDelay(1000);
216 #endif
217 
218  // Set default order and mode
219  ArrangeButtons();
220 }
AButton * mRecord
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void MakeButtonBackgroundsLarge()
Definition: ToolBar.cpp:704
void RegenerateTooltips() override
static AButton * MakeButton(ControlToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const wxChar *label)
AButton * mPause
void FollowModifierKeys()
Definition: AButton.cpp:258
static void MakeAlternateImages(AButton &button, int idx, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AButton * mRewind
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void ControlToolBar::ReCreateButtons ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 391 of file ControlToolBar.cpp.

References ToolBar::Detach(), EnableDisableButtons(), AButton::IsDown(), Looped, mPause, mPlay, mRecord, mSizer, AButton::PushDown(), ToolBar::ReCreateButtons(), RegenerateTooltips(), SetPlay(), SetRecord(), Straight, and AButton::WasShiftDown().

Referenced by UpdatePrefs().

392 {
393  bool playDown = false;
394  bool playShift = false;
395  bool pauseDown = false;
396  bool recordDown = false;
397  bool recordShift = false;
398 
399  // ToolBar::ReCreateButtons() will get rid of its sizer and
400  // since we've attached our sizer to it, ours will get deleted too
401  // so clean ours up first.
402  if( mSizer )
403  {
404  playDown = mPlay->IsDown();
405  playShift = mPlay->WasShiftDown();
406  pauseDown = mPause->IsDown();
407  recordDown = mRecord->IsDown();
408  recordShift = mRecord->WasShiftDown();
409  Detach( mSizer );
410 
411  std::unique_ptr < wxSizer > {mSizer}; // DELETE it
412  mSizer = NULL;
413  }
414 
416 
417  if (playDown)
418  {
419  ControlToolBar::PlayAppearance appearance =
422  SetPlay(playDown, appearance);
423  }
424 
425  if (pauseDown)
426  {
427  mPause->PushDown();
428  }
429 
430  if (recordDown)
431  {
432  SetRecord(recordDown, recordShift);
433  }
434 
436 
438 }
AButton * mRecord
void EnableDisableButtons() override
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
bool IsDown()
Definition: AButton.h:123
bool WasShiftDown()
Definition: AButton.cpp:485
void RegenerateTooltips() override
virtual void ReCreateButtons()
Definition: ToolBar.cpp:462
AButton * mPause
void Detach(wxWindow *window)
Definition: ToolBar.cpp:680
wxBoxSizer * mSizer
void PushDown()
Definition: AButton.cpp:517
void SetRecord(bool down, bool altAppearance=false)
void ControlToolBar::RegenerateTooltips ( )
overridevirtual

Implements ToolBar.

Definition at line 222 of file ControlToolBar.cpp.

References _(), BUTTON_COUNT, gPrefs, ID_FF_BUTTON, ID_PAUSE_BUTTON, ID_PLAY_BUTTON, ID_RECORD_BUTTON, ID_REW_BUTTON, ID_STOP_BUTTON, name, and ToolBar::SetButtonToolTip().

Referenced by Populate(), ReCreateButtons(), and UpdatePrefs().

223 {
224 #if wxUSE_TOOLTIPS
225  for (long iWinID = ID_PLAY_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
226  {
227  auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
228  const wxChar *name = nullptr;
229  switch (iWinID)
230  {
231  case ID_PLAY_BUTTON:
232  // Without shift
233  name = wxT("PlayStop");
234  break;
235  case ID_RECORD_BUTTON:
236  // Without shift
237  //name = wxT("Record");
238  name = wxT("Record1stChoice");
239  break;
240  case ID_PAUSE_BUTTON:
241  name = wxT("Pause");
242  break;
243  case ID_STOP_BUTTON:
244  name = wxT("Stop");
245  break;
246  case ID_FF_BUTTON:
247  name = wxT("CursProjectEnd");
248  break;
249  case ID_REW_BUTTON:
250  name = wxT("CursProjectStart");
251  break;
252  }
253  std::vector<TranslatedInternalString> commands(
254  1u, { name, pCtrl->GetLabel() } );
255 
256  // Some have a second
257  switch (iWinID)
258  {
259  case ID_PLAY_BUTTON:
260  // With shift
261  commands.push_back( { wxT("PlayLooped"), _("Loop Play") } );
262  break;
263  case ID_RECORD_BUTTON:
264  // With shift
265  { bool bPreferNewTrack;
266  gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);
267  // For the shortcut tooltip.
268  commands.push_back( {
269  wxT("Record2ndChoice"),
270  !bPreferNewTrack
271  ? _("Record New Track")
272  : _("Append Record")
273  } );
274  }
275  break;
276  case ID_PAUSE_BUTTON:
277  break;
278  case ID_STOP_BUTTON:
279  break;
280  case ID_FF_BUTTON:
281  // With shift
282  commands.push_back( {
283  wxT("SelEnd"), _("Select to End") } );
284  break;
285  case ID_REW_BUTTON:
286  // With shift
287  commands.push_back( {
288  wxT("SelStart"), _("Select to Start") } );
289  break;
290  }
291  ToolBar::SetButtonToolTip(*pCtrl, commands.data(), commands.size());
292  }
293 #endif
294 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:826
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void ControlToolBar::Repaint ( wxDC *  dc)
overridevirtual

Implements ToolBar.

Definition at line 440 of file ControlToolBar.cpp.

References AColor::Bevel(), and mSizer.

441 {
442 #ifndef USE_AQUA_THEME
443  wxSize s = mSizer->GetSize();
444  wxPoint p = mSizer->GetPosition();
445 
446  wxRect bevelRect( p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1 );
447  AColor::Bevel( *dc, true, bevelRect );
448 #endif
449 }
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:202
wxBoxSizer * mSizer
void ControlToolBar::SetPlay ( bool  down,
PlayAppearance  appearance = PlayAppearance::Straight 
)

Definition at line 492 of file ControlToolBar.cpp.

References CutPreview, EnableDisableButtons(), GetActiveProject(), Looped, mPlay, AButton::PopUp(), AButton::PushDown(), AButton::SetAlternateIdx(), AButton::SetControl(), AButton::SetShift(), and UpdateStatusBar().

Referenced by AudacityProject::DoPlayStopSelect(), DoRecord(), AudacityProject::MakeReadyToPlay(), Scrubber::MarkScrubStart(), OnKeyEvent(), AudacityProject::OnPlayStop(), PlayPlayRegion(), ReCreateButtons(), StopPlaying(), and Scrubber::StopScrubbing().

493 {
494  if (down) {
495  mPlay->SetShift(appearance == PlayAppearance::Looped);
497  mPlay->SetAlternateIdx(static_cast<int>(appearance));
498  mPlay->PushDown();
499  }
500  else {
501  mPlay->PopUp();
503  }
506 }
void EnableDisableButtons() override
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
void SetShift(bool shift)
Definition: AButton.cpp:546
void UpdateStatusBar(AudacityProject *pProject)
void SetControl(bool control)
Definition: AButton.cpp:551
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void PushDown()
Definition: AButton.cpp:517
void ControlToolBar::SetRecord ( bool  down,
bool  altAppearance = false 
)

Definition at line 520 of file ControlToolBar.cpp.

References EnableDisableButtons(), mRecord, AButton::PopUp(), AButton::PushDown(), and AButton::SetAlternateIdx().

Referenced by DoRecord(), PlayPlayRegion(), ReCreateButtons(), and StopPlaying().

521 {
522  if (down)
523  {
524  mRecord->SetAlternateIdx(altAppearance ? 1 : 0);
525  mRecord->PushDown();
526  }
527  else
528  {
530  mRecord->PopUp();
531  }
533 }
AButton * mRecord
void EnableDisableButtons() override
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void ControlToolBar::SetStop ( bool  down)

Definition at line 508 of file ControlToolBar.cpp.

References EnableDisableButtons(), mPlay, mStop, AButton::PopUp(), and AButton::PushDown().

Referenced by AudacityProject::DoPlayStopSelect(), DoRecord(), AudacityProject::MakeReadyToPlay(), OnKeyEvent(), AudacityProject::OnPlayStop(), AudacityProject::OnPlayStopSelect(), PlayPlayRegion(), and StopPlaying().

509 {
510  if (down)
511  mStop->PushDown();
512  else {
513  if(FindFocus() == mStop)
514  mPlay->SetFocus();
515  mStop->PopUp();
516  }
518 }
void EnableDisableButtons() override
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void ControlToolBar::SetupCutPreviewTracks ( double  playStart,
double  cutStart,
double  cutEnd,
double  playEnd 
)
private

Definition at line 1394 of file ControlToolBar.cpp.

References ClearCutPreviewTracks(), TrackList::Create(), Track::Duplicate(), GetActiveProject(), Track::GetLink(), AudacityProject::GetTracks(), mCutPreviewTracks, and Track::Wave.

Referenced by PlayPlayRegion().

1398 {
1401  if (p) {
1402  auto cutPreviewTracks = TrackList::Create();
1403  // Find first selected track (stereo or mono) and duplicate it
1404  const Track *track1 = NULL, *track2 = NULL;
1405  TrackListIterator it(p->GetTracks());
1406  for (Track *t = it.First(); t; t = it.Next())
1407  {
1408  if (t->GetSelected() &&
1409  (t->GetKind() == Track::Wave
1410 #ifdef EXPERIMENTAL_MIDI_OUT
1411  || t->GetKind() == Track::Note
1412 #endif
1413  ))
1414  {
1415  track1 = t;
1416  track2 = t->GetLink();
1417  // Duplicate and change tracks
1418  // Clear has a very small chance of throwing
1419  auto new1 = track1->Duplicate();
1420  new1->Clear(cutStart, cutEnd);
1421  decltype(new1) new2{};
1422  if (track2)
1423  {
1424  new2 = track2->Duplicate();
1425  new2->Clear(cutStart, cutEnd);
1426  }
1427 
1428  // use NOTHROW-GUARANTEE:
1429  cutPreviewTracks->Add(std::move(new1));
1430  if (track2)
1431  cutPreviewTracks->Add(std::move(new2));
1432  }
1433  }
1434  if( track1 )
1435  mCutPreviewTracks = cutPreviewTracks;
1436  }
1437 }
static std::shared_ptr< TrackList > Create()
Definition: Track.cpp:792
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void ClearCutPreviewTracks()
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:410
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
TrackList * GetTracks()
Definition: Project.h:193
virtual Holder Duplicate() const =0
std::shared_ptr< TrackList > mCutPreviewTracks
void ControlToolBar::StartScrolling ( )

Definition at line 1533 of file ControlToolBar.cpp.

References gAudioIO, GetActiveProject(), AudioIO::GetNumCaptureChannels(), AudioIO::GetNumPlaybackChannels(), and gPrefs.

Referenced by StartScrollingIfPreferred().

1534 {
1536  const auto project = GetActiveProject();
1537  if (project) {
1538  auto mode = Mode::Pinned;
1539 
1540 #if 0
1541  // Enable these lines to pin the playhead right instead of center,
1542  // when recording but not overdubbing.
1543  if (gAudioIO->GetNumCaptureChannels() > 0) {
1544  // recording
1545 
1546  // Display a fixed recording head while scrolling the waves continuously.
1547  // If you overdub, you may want to anticipate some context in existing tracks,
1548  // so center the head. If not, put it rightmost to display as much wave as we can.
1549  bool duplex;
1550 #ifdef EXPERIMENTAL_DA
1551  gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, false);
1552 #else
1553  gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
1554 #endif
1555  if (duplex) {
1556  // See if there is really anything being overdubbed
1557  if (gAudioIO->GetNumPlaybackChannels() == 0)
1558  // No.
1559  duplex = false;
1560  }
1561 
1562  if (!duplex)
1563  mode = Mode::Right;
1564  }
1565 #endif
1566 
1567  project->GetPlaybackScroller().Activate(mode);
1568  }
1569 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:542
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
unsigned GetNumPlaybackChannels() const
Definition: AudioIO.h:541
void ControlToolBar::StartScrollingIfPreferred ( )

Definition at line 1515 of file ControlToolBar.cpp.

References AudacityProject::PlaybackScroller::Activate(), GetActiveProject(), AudacityProject::GetPlaybackScroller(), IsTransportingPinned(), AudacityProject::PlaybackScroller::Refresh, StartScrolling(), and StopScrolling().

Referenced by DoRecord(), AudacityProject::OnTogglePinnedHead(), and PlayPlayRegion().

1516 {
1517  if (IsTransportingPinned())
1518  StartScrolling();
1519 #ifdef __WXMAC__
1520  else if (::GetActiveProject()->GetScrubber().HasMark()) {
1521  // PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
1522  // doing this causes wheel rotation events (mapped from the double finger vertical
1523  // swipe) to be delivered more uniformly to the application, so that speed control
1524  // works better.
1527  }
1528 #endif
1529  else
1530  StopScrolling();
1531 }
PlaybackScroller & GetPlaybackScroller()
Definition: Project.h:836
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
static bool IsTransportingPinned()
wxString ControlToolBar::StateForStatusBar ( )
private

Definition at line 1472 of file ControlToolBar.cpp.

References GetActiveProject(), AButton::IsDown(), mPause, mPlay, mRecord, mStatePause, mStatePlay, mStateRecord, and mStateStop.

Referenced by UpdateStatusBar().

1473 {
1474  wxString state;
1475 
1476  auto pProject = GetActiveProject();
1477  auto scrubState =
1478  pProject ? pProject->GetScrubber().GetUntranslatedStateString() : wxString();
1479  if (!scrubState.IsEmpty())
1480  state = wxGetTranslation(scrubState);
1481  else if (mPlay->IsDown())
1482  state = wxGetTranslation(mStatePlay);
1483  else if (mRecord->IsDown())
1484  state = wxGetTranslation(mStateRecord);
1485  else
1486  state = wxGetTranslation(mStateStop);
1487 
1488  if (mPause->IsDown())
1489  {
1490  state.Append(wxT(" "));
1491  state.Append(wxGetTranslation(mStatePause));
1492  }
1493 
1494  state.Append(wxT("."));
1495 
1496  return state;
1497 }
AButton * mRecord
bool IsDown()
Definition: AButton.h:123
wxString mStateRecord
AButton * mPause
wxString mStateStop
wxString mStatePause
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
wxString mStatePlay
void ControlToolBar::StopPlaying ( bool  stopStream = true)

Definition at line 836 of file ControlToolBar.cpp.

References CanStopAudioStream(), MeterPanel::Clear(), ClearCutPreviewTracks(), ToolBar::EnableDisableButtons(), gAudioIO, GetActiveProject(), AudacityProject::GetCaptureMeter(), AudacityProject::GetPlaybackMeter(), AudacityProject::GetScrubber(), ToolManager::GetToolBar(), AudacityProject::GetToolManager(), AudacityProject::MayStartMonitoring(), mBusyProject, mPause, mPaused, mStop, AButton::PopUp(), AButton::PushDown(), ScrubbingBarID, AudioIO::SetPaused(), SetPlay(), SetRecord(), SetStop(), StopScrolling(), Scrubber::StopScrubbing(), and AudioIO::StopStream().

Referenced by AdornedRulerPanel::ClearPlayRegion(), Scrubber::DoScrub(), Scrubber::MarkScrubStart(), Scrubber::MaybeStartScrubbing(), OnKeyEvent(), OnPlay(), EffectUIHost::OnPlay(), AudacityProject::OnPlayStop(), OnStop(), TrackPanel::OnTimer(), TranscriptionToolBar::PlayAtSpeed(), AdornedRulerPanel::StartQPPlay(), and Scrubber::StartSpeedPlay().

837 {
838  StopScrolling();
839 
840  AudacityProject *project = GetActiveProject();
841 
842  if(project) {
843  // Let scrubbing code do some appearance change
844  project->GetScrubber().StopScrubbing();
845  }
846 
847  if (!CanStopAudioStream())
848  return;
849 
850  mStop->PushDown();
851 
852  SetStop(false);
853  if(stopStream)
854  gAudioIO->StopStream();
855  SetPlay(false);
856  SetRecord(false);
857 
858  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
859  gAudioIO->AILADisable();
860  #endif
861 
862  mPause->PopUp();
863  mPaused=false;
864  //Make sure you tell gAudioIO to unpause
866 
868 
869  mBusyProject = NULL;
870  // So that we continue monitoring after playing or recording.
871  // also clean the MeterQueues
872  if( project ) {
873  project->MayStartMonitoring();
874 
875  MeterPanel *meter = project->GetPlaybackMeter();
876  if( meter ) {
877  meter->Clear();
878  }
879 
880  meter = project->GetCaptureMeter();
881  if( meter ) {
882  meter->Clear();
883  }
884  }
885 
886  const auto toolbar = project->GetToolManager()->GetToolBar(ScrubbingBarID);
887  toolbar->EnableDisableButtons();
888 }
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
void StopStream()
Stop recording, playback or input monitoring.
Definition: AudioIO.cpp:2408
void PopUp()
Definition: AButton.cpp:525
Scrubber & GetScrubber()
Definition: Project.h:805
void Clear()
Definition: Meter.cpp:335
AButton * mPause
void MayStartMonitoring()
Definition: Project.cpp:5584
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: Meter.h:97
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void StopScrubbing()
Definition: Scrubbing.cpp:677
void ClearCutPreviewTracks()
MeterPanel * GetCaptureMeter()
Definition: Project.cpp:5142
void SetStop(bool down)
virtual void EnableDisableButtons()=0
ToolManager * GetToolManager()
Definition: Project.h:707
static AudacityProject * mBusyProject
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
MeterPanel * GetPlaybackMeter()
Definition: Project.cpp:5128
void PushDown()
Definition: AButton.cpp:517
void SetRecord(bool down, bool altAppearance=false)
void SetPaused(bool state)
Pause and un-pause playback and recording.
Definition: AudioIO.cpp:2696
ToolBar * GetToolBar(int type) const
void ControlToolBar::StopScrolling ( )

Definition at line 1571 of file ControlToolBar.cpp.

References GetActiveProject(), and AudacityProject::PlaybackScroller::Off.

Referenced by StartScrollingIfPreferred(), and StopPlaying().

1572 {
1573  const auto project = GetActiveProject();
1574  if(project)
1575  project->GetPlaybackScroller().Activate
1577 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
void ControlToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 296 of file ControlToolBar.cpp.

References _(), gPrefs, mErgonomicTransportButtons, mStrLocale, ReCreateButtons(), RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::Updated(), and ToolBar::UpdatePrefs().

297 {
298  bool updated = false;
299  bool active;
300 
301  gPrefs->Read( wxT("/GUI/ErgonomicTransportButtons"), &active, true );
302  if( mErgonomicTransportButtons != active )
303  {
305  updated = true;
306  }
307  wxString strLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
308  if (mStrLocale != strLocale)
309  {
310  mStrLocale = strLocale;
311  updated = true;
312  }
313 
314  if( updated )
315  {
316  ReCreateButtons(); // side effect: calls RegenerateTooltips()
317  Updated();
318  }
319  else
320  // The other reason to regenerate tooltips is if keyboard shortcuts for
321  // transport buttons changed, but that's too much work to check for, so just
322  // always do it. (Much cheaper than calling ReCreateButtons() in all cases.
324 
325 
326  // Set label to pull in language change
327  SetLabel(_("Transport"));
328 
329  // Give base class a chance
331 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:377
void RegenerateTooltips() override
void ReCreateButtons() override
wxString mStrLocale
void Updated()
Definition: ToolBar.cpp:595
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
bool mErgonomicTransportButtons
void ControlToolBar::UpdateStatusBar ( AudacityProject pProject)
bool ControlToolBar::UseDuplex ( )
static

Definition at line 1089 of file ControlToolBar.cpp.

References gPrefs.

Referenced by AudacityProject::OnPunchAndRoll(), and OnRecord().

1090 {
1091  bool duplex;
1092  gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex,
1093 #ifdef EXPERIMENTAL_DA
1094  false
1095 #else
1096  true
1097 #endif
1098  );
1099  return duplex;
1100 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
int ControlToolBar::WidthForStatusBar ( wxStatusBar * const  sb)

Definition at line 1447 of file ControlToolBar.cpp.

References Scrubber::GetAllUntranslatedStatusStrings(), mStatePause, mStatePlay, mStateRecord, and mStateStop.

Referenced by AudacityProject::OnAudioIORate().

1448 {
1449  int xMax = 0;
1450  const auto pauseString = wxT(" ") + wxGetTranslation(mStatePause);
1451 
1452  auto update = [&] (const wxString &state) {
1453  int x, y;
1454  sb->GetTextExtent(
1455  wxGetTranslation(state) + pauseString + wxT("."),
1456  &x, &y
1457  );
1458  xMax = std::max(x, xMax);
1459  };
1460 
1461  update(mStatePlay);
1462  update(mStateStop);
1463  update(mStateRecord);
1464 
1465  // Note that Scrubbing + Paused is not allowed.
1466  for(const auto &state : Scrubber::GetAllUntranslatedStatusStrings())
1467  update(state);
1468 
1469  return xMax + 30; // added constant needed because xMax isn't large enough for some reason, plus some space.
1470 }
wxString mStateRecord
wxString mStateStop
static std::vector< wxString > GetAllUntranslatedStatusStrings()
Definition: Scrubbing.cpp:1131
wxString mStatePause
wxString mStatePlay

Member Data Documentation

AudacityProject * ControlToolBar::mBusyProject = NULL
staticprivate

Definition at line 177 of file ControlToolBar.h.

Referenced by DoRecord(), PlayPlayRegion(), and StopPlaying().

std::shared_ptr<TrackList> ControlToolBar::mCutPreviewTracks
private

Definition at line 189 of file ControlToolBar.h.

Referenced by ClearCutPreviewTracks(), PlayPlayRegion(), and SetupCutPreviewTracks().

bool ControlToolBar::mErgonomicTransportButtons
private

Definition at line 183 of file ControlToolBar.h.

Referenced by ArrangeButtons(), and UpdatePrefs().

AButton* ControlToolBar::mFF
private

Definition at line 175 of file ControlToolBar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), OnFF(), and Populate().

AButton* ControlToolBar::mPause
private
bool ControlToolBar::mPaused
private

Definition at line 180 of file ControlToolBar.h.

Referenced by OnPause(), and StopPlaying().

AButton* ControlToolBar::mPlay
private
AButton* ControlToolBar::mRecord
private
AButton* ControlToolBar::mRewind
private

Definition at line 170 of file ControlToolBar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), OnRewind(), and Populate().

wxBoxSizer* ControlToolBar::mSizer
private

Definition at line 187 of file ControlToolBar.h.

Referenced by ArrangeButtons(), ReCreateButtons(), and Repaint().

wxString ControlToolBar::mStatePause
private

Definition at line 195 of file ControlToolBar.h.

Referenced by StateForStatusBar(), and WidthForStatusBar().

wxString ControlToolBar::mStatePlay
private

Definition at line 192 of file ControlToolBar.h.

Referenced by StateForStatusBar(), and WidthForStatusBar().

wxString ControlToolBar::mStateRecord
private

Definition at line 194 of file ControlToolBar.h.

Referenced by StateForStatusBar(), and WidthForStatusBar().

wxString ControlToolBar::mStateStop
private

Definition at line 193 of file ControlToolBar.h.

Referenced by StateForStatusBar(), and WidthForStatusBar().

AButton* ControlToolBar::mStop
private
wxString ControlToolBar::mStrLocale
private

Definition at line 185 of file ControlToolBar.h.

Referenced by UpdatePrefs().


The documentation for this class was generated from the following files: