Audacity  2.2.0
ControlToolBar.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5 
6  ControlToolbar.h
7 
8  Dominic Mazzoni
9  Shane T. Mueller
10  Leland Lucius
11 
12 **********************************************************************/
13 
14 #ifndef __AUDACITY_CONTROL_TOOLBAR__
15 #define __AUDACITY_CONTROL_TOOLBAR__
16 
17 #include "../MemoryX.h"
18 #include "ToolBar.h"
19 #include "../Theme.h"
20 
21 class wxBoxSizer;
22 class wxCommandEvent;
23 class wxDC;
24 class wxKeyEvent;
25 class wxTimer;
26 class wxTimerEvent;
27 class wxWindow;
28 class wxStatusBar;
29 
30 class AButton;
31 class AudacityProject;
32 class TrackList;
33 class TimeTrack;
34 
36 class SelectedRegion;
37 
38 // Defined in Project.h
39 enum class PlayMode : int;
40 
41 // In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
42 class ControlToolBar final : public ToolBar {
43 
44  public:
45 
47  virtual ~ControlToolBar();
48 
49  void Create(wxWindow *parent) override;
50 
51  void UpdatePrefs() override;
52  void OnKeyEvent(wxKeyEvent & event);
53 
54  // msmeyer: These are public, but it's far better to
55  // call the "real" interface functions like PlayCurrentRegion() and
56  // StopPlaying() which are defined below.
57  void OnRewind(wxCommandEvent & evt);
58  void OnPlay(wxCommandEvent & evt);
59  void OnStop(wxCommandEvent & evt);
60  void OnRecord(wxCommandEvent & evt);
61  void OnFF(wxCommandEvent & evt);
62  void OnPause(wxCommandEvent & evt);
63 
64  // Choice among the appearances of the play button:
65  enum class PlayAppearance {
66  Straight, Looped, CutPreview, Scrub, Seek
67  };
68 
69  //These allow buttons to be controlled externally:
70  void SetPlay(bool down, PlayAppearance appearance = PlayAppearance::Straight);
71  void SetStop(bool down);
72  void SetRecord(bool down, bool append=false);
73 
74  bool IsPauseDown() const;
75  bool IsRecordDown() const;
76 
77  // A project is only allowed to stop an audio stream that it owns.
78  bool CanStopAudioStream ();
79 
80  // Play currently selected region, or if nothing selected,
81  // play from current cursor.
82  void PlayCurrentRegion(bool looped = false, bool cutpreview = false);
83  // Play the region [t0,t1]
84  // Return the Audio IO token or -1 for failure
85  int PlayPlayRegion(const SelectedRegion &selectedRegion,
86  const AudioIOStartStreamOptions &options,
87  PlayMode playMode,
88  PlayAppearance appearance = PlayAppearance::Straight,
89  bool backwards = false,
90  // Allow t0 and t1 to be beyond end of tracks
91  bool playWhiteSpace = false);
92  void PlayDefault();
93 
94  // Stop playing
95  void StopPlaying(bool stopStream = true);
96 
97  // Pause - used by AudioIO to pause sound activate recording
98  void Pause();
99 
100  void Populate() override;
101  void Repaint(wxDC *dc) override;
102  void EnableDisableButtons() override;
103 
104  void ReCreateButtons() override;
105  void RegenerateTooltips() override;
106 
107  int WidthForStatusBar(wxStatusBar* const);
108  void UpdateStatusBar(AudacityProject *pProject);
109 
110  // Starting and stopping of scrolling display
112  void StartScrolling();
113  void StopScrolling();
114 
115  private:
116 
117  AButton *MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
118  int id,
119  bool processdownevents,
120  const wxChar *label);
121 
122  static
123  void MakeAlternateImages(AButton &button, int idx,
124  teBmps eEnabledUp,
125  teBmps eEnabledDown,
126  teBmps eDisabled);
127 
128  void ArrangeButtons();
129  void SetupCutPreviewTracks(double playStart, double cutStart,
130  double cutEnd, double playEnd);
131  void ClearCutPreviewTracks();
132  wxString StateForStatusBar();
133 
134  enum
135  {
136  ID_PLAY_BUTTON = 11000,
143  };
144 
151 
153 
154  // Maybe button state values shouldn't be duplicated in this toolbar?
155  bool mPaused; //Play or record is paused or not paused?
156 
157  // Activate ergonomic order for transport buttons
159 
160  wxString mStrLocale; // standard locale abbreviation
161 
162  wxBoxSizer *mSizer;
163 
164  std::shared_ptr<TrackList> mCutPreviewTracks;
165 
166  // strings for status bar
167  wxString mStatePlay;
168  wxString mStateStop;
169  wxString mStateRecord;
170  wxString mStatePause;
171 
172  public:
173 
174  DECLARE_CLASS(ControlToolBar)
175  DECLARE_EVENT_TABLE()
176 };
177 
178 #endif
179 
AButton * mRecord
Definition: ControlToolBar.h:147
void EnableDisableButtons() override
Definition: ControlToolBar.cpp:435
Definition: ControlToolBar.h:140
void SetPlay(bool down, PlayAppearance appearance=PlayAppearance::Straight)
Definition: ControlToolBar.cpp:476
A ToolBar that has the main Transport buttons.
Definition: ControlToolBar.h:42
A list of TrackListNode items.
Definition: Track.h:550
void OnKeyEvent(wxKeyEvent &event)
Definition: ControlToolBar.cpp:767
PlayAppearance
Definition: ControlToolBar.h:65
AButton * mPlay
Definition: ControlToolBar.h:146
void RegenerateTooltips() override
Definition: ControlToolBar.cpp:220
void Populate() override
Definition: ControlToolBar.cpp:168
wxString mStateRecord
Definition: ControlToolBar.h:169
AButton * mPause
Definition: ControlToolBar.h:148
wxString label
Definition: Tags.cpp:728
wxString StateForStatusBar()
Definition: ControlToolBar.cpp:1347
void OnPause(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:1210
PlayMode
Definition: Project.h:126
Definition: ControlToolBar.h:137
void PlayCurrentRegion(bool looped=false, bool cutpreview=false)
Definition: ControlToolBar.cpp:738
void ReCreateButtons() override
Definition: ControlToolBar.cpp:375
void StopPlaying(bool stopStream=true)
Definition: ControlToolBar.cpp:831
int teBmps
Definition: Theme.h:28
bool CanStopAudioStream()
Definition: ControlToolBar.cpp:815
virtual ~ControlToolBar()
Definition: ControlToolBar.cpp:120
Definition: ControlToolBar.h:139
void ArrangeButtons()
Definition: ControlToolBar.cpp:317
bool IsPauseDown() const
Definition: ControlToolBar.cpp:519
void Repaint(wxDC *dc) override
Definition: ControlToolBar.cpp:424
void UpdateStatusBar(AudacityProject *pProject)
Definition: ControlToolBar.cpp:1374
bool mPaused
Definition: ControlToolBar.h:155
Definition: ControlToolBar.h:142
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
void ClearCutPreviewTracks()
Definition: ControlToolBar.cpp:1314
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:29
wxString mStateStop
Definition: ControlToolBar.h:168
Defines a selected portion of a project.
Definition: SelectedRegion.h:37
void OnFF(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:1252
ControlToolBar()
Methods for ControlToolBar.
Definition: ControlToolBar.cpp:102
void SetStop(bool down)
Definition: ControlToolBar.cpp:492
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:109
void UpdatePrefs() override
Definition: ControlToolBar.cpp:280
wxString mStatePause
Definition: ControlToolBar.h:170
wxString mStrLocale
Definition: ControlToolBar.h:160
wxBoxSizer * mSizer
Definition: ControlToolBar.h:162
void SetupCutPreviewTracks(double playStart, double cutStart, double cutEnd, double playEnd)
Definition: ControlToolBar.cpp:1265
static void MakeAlternateImages(AButton &button, int idx, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled)
Definition: ControlToolBar.cpp:157
void OnStop(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:807
bool IsRecordDown() const
Definition: ControlToolBar.cpp:524
Definition: ControlToolBar.h:141
void StartScrollingIfPreferred()
Definition: ControlToolBar.cpp:1379
int WidthForStatusBar(wxStatusBar *const)
Definition: ControlToolBar.cpp:1322
AButton * mStop
Definition: ControlToolBar.h:149
static AudacityProject * mBusyProject
Definition: ControlToolBar.h:152
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
Definition: ControlToolBar.cpp:529
void SetRecord(bool down, bool append=false)
Definition: ControlToolBar.cpp:504
void StopScrolling()
Definition: ControlToolBar.cpp:1435
void Pause()
Definition: ControlToolBar.cpp:885
AButton * mRewind
Definition: ControlToolBar.h:145
AButton * MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const wxChar *label)
Definition: ControlToolBar.cpp:132
AButton * mFF
Definition: ControlToolBar.h:150
void StartScrolling()
Definition: ControlToolBar.cpp:1397
void Create(wxWindow *parent) override
Definition: ControlToolBar.cpp:125
bool mErgonomicTransportButtons
Definition: ControlToolBar.h:158
wxString mStatePlay
Definition: ControlToolBar.h:167
void OnRecord(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:895
void OnPlay(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:792
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
Definition: ControlToolBar.h:138
void OnRewind(wxCommandEvent &evt)
Definition: ControlToolBar.cpp:1240
A wxButton with mouse-over behaviour.
Definition: AButton.h:27
std::shared_ptr< TrackList > mCutPreviewTracks
Definition: ControlToolBar.h:164
void PlayDefault()
Definition: ControlToolBar.cpp:822