Audacity 3.2.0
ProjectWindow.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectWindow.h
6
7Paul 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#include "Observer.h"
19
20class CommandContext;
21class Track;
22
23class wxScrollBar;
24class wxPanel;
25class wxSplitterWindow;
27
28class ProjectWindow;
29void InitProjectWindow( ProjectWindow &window );
30
33class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase
34 , public TrackPanelListener
35 , public PrefsListener
36{
37public:
38 static ProjectWindow &Get( AudacityProject &project );
39 static const ProjectWindow &Get( const AudacityProject &project );
40 static ProjectWindow *Find( AudacityProject *pProject );
41 static const ProjectWindow *Find( const AudacityProject *pProject );
42
43 static void OnResetWindow(const CommandContext& context);
44
45 explicit ProjectWindow(
46 wxWindow * parent, wxWindowID id,
47 const wxPoint & pos, const wxSize &size,
48 AudacityProject &project );
49 ~ProjectWindow() override;
50
51 // Next available ID for sub-windows
52 int NextWindowID();
53
54 bool IsActive() override;
55 bool IsIconized() const override;
56
57 bool IsBeingDeleted() const { return mIsDeleting; }
58 void SetIsBeingDeleted() { mIsDeleting = true; }
59
60 void Reset();
61
67 wxWindow* GetEffectsWindow() noexcept;
72 wxWindow* GetTrackListWindow() noexcept;
78 wxWindow* GetContainerWindow() noexcept;
83 wxPanel *GetTopPanel() noexcept;
84
85 void UpdateStatusWidths();
86
88
89 class PlaybackScroller final
90 : public Observer::Publisher<PlaybackScrollerMessage>
91 {
92 public:
93 explicit PlaybackScroller(AudacityProject *project);
94
95 enum class Mode {
96 Off,
97 Refresh,
98 Pinned,
99 Right,
100 };
101
102 Mode GetMode() const { return mMode; }
103 void Activate(Mode mode)
104 {
105 mMode = mode;
106 }
107
108 double GetRecentStreamTime() const { return mRecentStreamTime; }
109
110 void OnTimer();
111
112 private:
114 Mode mMode { Mode::Off };
115
116 // During timer update, grab the volatile stream time just once, so that
117 // various other drawing code can use the exact same value.
118 double mRecentStreamTime{ -1.0 };
119 };
120 PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
121
122 void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
123 wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
124
125 void RedrawProject(const bool bForceWaveTracks = false);
126
127 void Zoom(double level);
128 void ZoomInByFactor( double ZoomFactor );
129 void ZoomOutByFactor( double ZoomFactor );
130 void ZoomBy(double multiplier);
131 void ZoomAfterImport(Track *pTrack);
132 double GetZoomOfToFit() const;
133 void DoZoomFit();
134
135 void ShowEffectsPanel(AudacityProject& project, Track* track = nullptr);
136 void HideEffectsPanel();
137
138 void ApplyUpdatedTheme();
139
140 // Scrollbars
141
142 wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
143 wxScrollBar &GetHorizontalScrollBar() { return *mHsbar; }
144
145 void ScrollIntoView(double pos);
146 void ScrollIntoView(int x);
147
148 void OnScrollLeft();
149 void OnScrollRight();
150
151 void Rewind(bool shift);
152 void SkipEnd(bool shift);
153
154 void OnScrollLeftButton(wxScrollEvent & event);
155 void OnScrollRightButton(wxScrollEvent & event);
156
157 void FinishAutoScroll();
158 void FixScrollbars();
159
160 bool MayScrollBeyondZero() const;
161 double ScrollingLowerBoundTime() const;
162 // How many pixels are covered by the period from lowermost scrollable time, to the given time:
163 // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
164 double PixelWidthBeforeTime(double scrollto) const;
165 void SetHorizontalThumb(double scrollto);
166
167 // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
168 // TrackPanel access
169 wxSize GetTPTracksUsableArea() /* not override */;
170 void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
171
172 void TP_RedrawScrollbars() override;
173 void TP_ScrollLeft() override;
174 void TP_ScrollRight() override;
175 void TP_ScrollWindow(double scrollto) override;
176 bool TP_ScrollUpDown(int delta) override;
177 void TP_HandleResize() override;
178
179 private:
180
181 void OnThemeChange(struct ThemeChangeMessage);
182
183 // PrefsListener implementation
184 void UpdatePrefs() override;
185
186 public:
187 // Message Handlers
188
189 void OnMenu(wxCommandEvent & event);
190 void OnUpdateUI(wxUpdateUIEvent & event);
191
192 void MacShowUndockedToolbars(bool show);
193 void OnActivate(wxActivateEvent & event);
194
195 void OnMouseEvent(wxMouseEvent & event);
196 void OnIconize(wxIconizeEvent &event);
197 void OnSize(wxSizeEvent & event);
198 void HandleResize();
199 void UpdateLayout();
200 void OnShow(wxShowEvent & event);
201 void OnMove(wxMoveEvent & event);
202 void DoScroll();
203 void OnScroll(wxScrollEvent & event);
204 void OnToolBarUpdate(wxCommandEvent & event);
205 void OnUndoPushedModified();
206 void OnUndoRedo();
207 void OnUndoReset();
208
209 bool mbInitializingScrollbar{ false };
210
211private:
213
214 wxPanel *mTopPanel{};
215 wxSplitterWindow* mContainerWindow;
216 RealtimeEffectPanel* mEffectsWindow{};
217 wxWindow* mTrackListWindow{};
218
219 wxScrollBar *mHsbar{};
220 wxScrollBar *mVsbar{};
221
222 int mNextWindowID{};
223
224 bool mAutoScrolling{ false };
225 bool mActive{ true };
226 bool mIconized{ false };
227 bool mShownOnce{ false };
228
229
230
231 bool mIsDeleting{ false };
232
233private:
234
237 std::unique_ptr<PlaybackScroller> mPlaybackScroller;
238
240
241 DECLARE_EVENT_TABLE()
242};
243
244void GetDefaultWindowRect(wxRect *defRect);
245void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
246
247extern AUDACITY_DLL_API BoolSetting ProjectWindowMaximized;
248extern AUDACITY_DLL_API BoolSetting ProjectWindowIconized;
249extern AUDACITY_DLL_API IntSetting ProjectWindowX;
250extern AUDACITY_DLL_API IntSetting ProjectWindowY;
251extern AUDACITY_DLL_API IntSetting ProjectWindowWidth;
252extern AUDACITY_DLL_API IntSetting ProjectWindowHeight;
253extern AUDACITY_DLL_API IntSetting ProjectWindowNormalX;
254extern AUDACITY_DLL_API IntSetting ProjectWindowNormalY;
255extern AUDACITY_DLL_API IntSetting ProjectWindowNormalWidth;
256extern AUDACITY_DLL_API IntSetting ProjectWindowNormalHeight;
257
258#endif
AUDACITY_DLL_API IntSetting ProjectWindowNormalWidth
void InitProjectWindow(ProjectWindow &window)
AUDACITY_DLL_API IntSetting ProjectWindowNormalHeight
AUDACITY_DLL_API IntSetting ProjectWindowHeight
void GetDefaultWindowRect(wxRect *defRect)
AUDACITY_DLL_API IntSetting ProjectWindowX
AUDACITY_DLL_API IntSetting ProjectWindowNormalX
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
AUDACITY_DLL_API IntSetting ProjectWindowWidth
AUDACITY_DLL_API IntSetting ProjectWindowY
AUDACITY_DLL_API BoolSetting ProjectWindowMaximized
AUDACITY_DLL_API BoolSetting ProjectWindowIconized
AUDACITY_DLL_API IntSetting ProjectWindowNormalY
static void OnSize(wxSizeEvent &evt)
Definition: VSTEffect.cpp:2243
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
This specialization of Setting for bool adds a Toggle method to negate the saved value.
Definition: Prefs.h:339
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Specialization of Setting for int.
Definition: Prefs.h:349
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
A listener notified of changes in preferences.
Definition: Prefs.h:543
A top-level window associated with a project.
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:36
wxScrollBar & GetHorizontalScrollBar()
PlaybackScroller & GetPlaybackScroller()
wxSplitterWindow * mContainerWindow
Observer::Subscription mFocusChangeSubscription
void RefreshTPTrack(Track *pTrk, bool refreshbacking=true)
wxScrollBar & GetVerticalScrollBar()
Observer::Subscription mThemeChangeSubscription
wxRect GetNormalizedWindowState() const
void SetNormalizedWindowState(wxRect pSizeAndLocation)
wxSize GetTPTracksUsableArea()
bool IsBeingDeleted() const
Definition: ProjectWindow.h:57
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Observer::Subscription mUndoSubscription
wxRect mNormalizedWindowState
void SetIsBeingDeleted()
Definition: ProjectWindow.h:58
UI Panel that displays realtime effects from the effect stack of an individual track,...
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
virtual void TP_HandleResize()=0
virtual void TP_ScrollLeft()=0
virtual void TP_ScrollWindow(double scrollto)=0
virtual bool TP_ScrollUpDown(int delta)=0
virtual void TP_RedrawScrollbars()=0
virtual void TP_ScrollRight()=0
wxString Find(const FilePath &path)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
TranslatableString Message(unsigned trackCount)