Audacity  3.0.3
ProjectWindow.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ProjectWindow.h
6 
7 Paul Licameli split from AudacityProject.h
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_PROJECT_WINDOW__
12 #define __AUDACITY_PROJECT_WINDOW__
13 
14 #include <memory>
15 #include "ProjectWindowBase.h" // to inherit
16 #include "TrackPanelListener.h" // to inherit
17 #include "Prefs.h"
18 
19 class Track;
20 
21 class wxScrollBar;
22 class wxPanel;
23 
24 class ProjectWindow;
25 void InitProjectWindow( ProjectWindow &window );
26 
29 class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase
30  , public TrackPanelListener
31  , public PrefsListener
32 {
33 public:
34  static ProjectWindow &Get( AudacityProject &project );
35  static const ProjectWindow &Get( const AudacityProject &project );
36  static ProjectWindow *Find( AudacityProject *pProject );
37  static const ProjectWindow *Find( const AudacityProject *pProject );
38 
39  explicit ProjectWindow(
40  wxWindow * parent, wxWindowID id,
41  const wxPoint & pos, const wxSize &size,
42  AudacityProject &project );
43  ~ProjectWindow() override;
44 
45  // Next available ID for sub-windows
46  int NextWindowID();
47 
48  bool IsActive() override;
49  bool IsIconized() const override;
50 
51  bool IsBeingDeleted() const { return mIsDeleting; }
52  void SetIsBeingDeleted() { mIsDeleting = true; }
53 
54  wxWindow *GetMainPage() { return mMainPage; }
55  wxPanel *GetMainPanel() { return mMainPanel; }
56  wxPanel *GetTopPanel() { return mTopPanel; }
57 
58  void UpdateStatusWidths();
59 
60  class PlaybackScroller final : public wxEvtHandler
61  {
62  public:
63  explicit PlaybackScroller(AudacityProject *project);
64 
65  enum class Mode {
66  Off,
67  Refresh,
68  Pinned,
69  Right,
70  };
71 
72  Mode GetMode() const { return mMode; }
73  void Activate(Mode mode)
74  {
75  mMode = mode;
76  }
77 
78  double GetRecentStreamTime() const { return mRecentStreamTime; }
79 
80  private:
81  void OnTimer(wxCommandEvent &event);
82 
84  Mode mMode { Mode::Off };
85 
86  // During timer update, grab the volatile stream time just once, so that
87  // various other drawing code can use the exact same value.
88  double mRecentStreamTime{ -1.0 };
89  };
90  PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
91 
92  void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
93  wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
94 
95  void RedrawProject(const bool bForceWaveTracks = false);
96 
97  void Zoom(double level);
98  void ZoomInByFactor( double ZoomFactor );
99  void ZoomOutByFactor( double ZoomFactor );
100  void ZoomBy(double multiplier);
101  void ZoomAfterImport(Track *pTrack);
102  double GetZoomOfToFit() const;
103  void DoZoomFit();
104 
105  void ApplyUpdatedTheme();
106 
107  // Scrollbars
108 
109  wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
110  wxScrollBar &GetHorizontalScrollBar() { return *mHsbar; }
111 
112  void ScrollIntoView(double pos);
113  void ScrollIntoView(int x);
114 
115  void OnScrollLeft();
116  void OnScrollRight();
117 
118  void Rewind(bool shift);
119  void SkipEnd(bool shift);
120 
121  void OnScrollLeftButton(wxScrollEvent & event);
122  void OnScrollRightButton(wxScrollEvent & event);
123 
124  void FinishAutoScroll();
125  void FixScrollbars();
126 
127  bool MayScrollBeyondZero() const;
128  double ScrollingLowerBoundTime() const;
129  // How many pixels are covered by the period from lowermost scrollable time, to the given time:
130  // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
131  double PixelWidthBeforeTime(double scrollto) const;
132  void SetHorizontalThumb(double scrollto);
133 
134  // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
135  // TrackPanel access
136  wxSize GetTPTracksUsableArea() /* not override */;
137  void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
138 
139  void TP_RedrawScrollbars() override;
140  void TP_ScrollLeft() override;
141  void TP_ScrollRight() override;
142  void TP_ScrollWindow(double scrollto) override;
143  bool TP_ScrollUpDown(int delta) override;
144  void TP_HandleResize() override;
145 
146  private:
147 
148  void OnThemeChange(wxCommandEvent & evt);
149 
150  // PrefsListener implementation
151  void UpdatePrefs() override;
152 
153  public:
154  // Message Handlers
155 
156  void OnMenu(wxCommandEvent & event);
157  void OnUpdateUI(wxUpdateUIEvent & event);
158 
159  void MacShowUndockedToolbars(bool show);
160  void OnActivate(wxActivateEvent & event);
161 
162  void OnMouseEvent(wxMouseEvent & event);
163  void OnIconize(wxIconizeEvent &event);
164  void OnSize(wxSizeEvent & event);
165  void HandleResize();
166  void UpdateLayout();
167  void OnShow(wxShowEvent & event);
168  void OnMove(wxMoveEvent & event);
169  void DoScroll();
170  void OnScroll(wxScrollEvent & event);
171  void OnToolBarUpdate(wxCommandEvent & event);
172  void OnUndoPushedModified( wxCommandEvent & );
173  void OnUndoRedo( wxCommandEvent & );
174  void OnUndoReset( wxCommandEvent & );
175 
176  bool mbInitializingScrollbar{ false };
177 
178 private:
180 
181  wxPanel *mTopPanel{};
182  wxWindow * mMainPage{};
183  wxPanel * mMainPanel{};
184  wxScrollBar *mHsbar{};
185  wxScrollBar *mVsbar{};
186 
187  int mNextWindowID{};
188 
189  bool mAutoScrolling{ false };
190  bool mActive{ true };
191  bool mIconized{ false };
192  bool mShownOnce{ false };
193 
194 
195 
196  bool mIsDeleting{ false };
197 
198 private:
199 
200  std::unique_ptr<PlaybackScroller> mPlaybackScroller;
201 
202  DECLARE_EVENT_TABLE()
203 };
204 
205 void GetDefaultWindowRect(wxRect *defRect);
206 void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
207 
208 #endif
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
RefreshCode::FixScrollbars
@ FixScrollbars
Definition: RefreshCode.h:27
TrackPanelListener::TP_RedrawScrollbars
virtual void TP_RedrawScrollbars()=0
ProjectWindow::IsBeingDeleted
bool IsBeingDeleted() const
Definition: ProjectWindow.h:51
ProjectWindowBase.h
ProjectWindow::PlaybackScroller::mProject
AudacityProject * mProject
Definition: ProjectWindow.h:83
ProjectWindow::GetTopPanel
wxPanel * GetTopPanel()
Definition: ProjectWindow.h:56
TrackPanelListener::TP_ScrollWindow
virtual void TP_ScrollWindow(double scrollto)=0
ProjectWindow::PlaybackScroller::Activate
void Activate(Mode mode)
Definition: ProjectWindow.h:73
ProjectWindow::GetMainPanel
wxPanel * GetMainPanel()
Definition: ProjectWindow.h:55
ProjectWindow::PlaybackScroller::GetRecentStreamTime
double GetRecentStreamTime() const
Definition: ProjectWindow.h:78
ProjectWindow::GetPlaybackScroller
PlaybackScroller & GetPlaybackScroller()
Definition: ProjectWindow.h:90
ProjectWindow::RefreshTPTrack
void RefreshTPTrack(Track *pTrk, bool refreshbacking=true)
OnSize
static void OnSize(wxSizeEvent &evt)
Definition: VSTEffect.cpp:2784
TrackPanelListener::TP_ScrollUpDown
virtual bool TP_ScrollUpDown(int delta)=0
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:392
GetDefaultWindowRect
void GetDefaultWindowRect(wxRect *defRect)
Definition: ProjectWindow.cpp:92
InitProjectWindow
void InitProjectWindow(ProjectWindow &window)
Definition: ProjectManager.cpp:360
TrackPanelListener::TP_ScrollRight
virtual void TP_ScrollRight()=0
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
TrackPanelListener::TP_HandleResize
virtual void TP_HandleResize()=0
ProjectWindow
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:32
ProjectWindow::PlaybackScroller::Mode
Mode
Definition: ProjectWindow.h:65
ProjectWindowBase
A top-level window associated with a project.
Definition: ProjectWindowBase.h:20
ProjectWindow::GetMainPage
wxWindow * GetMainPage()
Definition: ProjectWindow.h:54
TrackPanelListener.h
ActiveProjects::Find
wxString Find(const FilePath &path)
TrackPanelListener
Definition: TrackPanelListener.h:23
ProjectWindow::SetNormalizedWindowState
void SetNormalizedWindowState(wxRect pSizeAndLocation)
Definition: ProjectWindow.h:92
ProjectWindow::PlaybackScroller
Definition: ProjectWindow.h:61
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
ProjectWindow::GetNormalizedWindowState
wxRect GetNormalizedWindowState() const
Definition: ProjectWindow.h:93
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ProjectWindow::PlaybackScroller::GetMode
Mode GetMode() const
Definition: ProjectWindow.h:72
ProjectWindow::mNormalizedWindowState
wxRect mNormalizedWindowState
Definition: ProjectWindow.h:179
TrackPanelListener::TP_ScrollLeft
virtual void TP_ScrollLeft()=0
PrefsListener::UpdatePrefs
virtual void UpdatePrefs()=0
ProjectWindow::GetTPTracksUsableArea
wxSize GetTPTracksUsableArea()
Prefs.h
GetNextWindowPlacement
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
Definition: ProjectWindow.cpp:139
ProjectWindow::SetIsBeingDeleted
void SetIsBeingDeleted()
Definition: ProjectWindow.h:52
ProjectWindow::GetVerticalScrollBar
wxScrollBar & GetVerticalScrollBar()
Definition: ProjectWindow.h:109
ProjectWindow::GetHorizontalScrollBar
wxScrollBar & GetHorizontalScrollBar()
Definition: ProjectWindow.h:110
ProjectWindow::mPlaybackScroller
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Definition: ProjectWindow.h:200