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
33
36class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase
37 , public TrackPanelListener
38 , public PrefsListener
39 , public Observer::Publisher<ProjectWindowDestroyedMessage>
40{
41public:
43 static ProjectWindow &Get( AudacityProject &project );
44 static const ProjectWindow &Get( const AudacityProject &project );
45 static ProjectWindow *Find( AudacityProject *pProject );
46 static const ProjectWindow *Find( const AudacityProject *pProject );
47
48 static void OnResetWindow(const CommandContext& context);
49
50 explicit ProjectWindow(
51 wxWindow * parent, wxWindowID id,
52 const wxPoint & pos, const wxSize &size,
53 AudacityProject &project );
54 ~ProjectWindow() override;
55
56 // Next available ID for sub-windows
57 int NextWindowID();
58
59 bool IsActive() override;
60 bool IsIconized() const override;
61
62 bool IsBeingDeleted() const { return mIsDeleting; }
63 void SetIsBeingDeleted() { mIsDeleting = true; }
64
65 void Reset();
66
71 wxWindow* GetTrackListWindow() noexcept;
77 wxSplitterWindow* GetContainerWindow() noexcept;
82 wxPanel *GetTopPanel() noexcept;
83
84 void UpdateStatusWidths();
85
87
88 class PlaybackScroller final
89 : public Observer::Publisher<PlaybackScrollerMessage>
90 {
91 public:
92 explicit PlaybackScroller(AudacityProject *project);
93
94 enum class Mode {
95 Off,
96 Refresh,
97 Pinned,
98 Right,
99 };
100
101 Mode GetMode() const { return mMode; }
102 void Activate(Mode mode)
103 {
104 mMode = mode;
105 }
106
107 double GetRecentStreamTime() const { return mRecentStreamTime; }
108
109 void OnTimer();
110
111 private:
113 Mode mMode { Mode::Off };
114
115 // During timer update, grab the volatile stream time just once, so that
116 // various other drawing code can use the exact same value.
117 double mRecentStreamTime{ -1.0 };
118 };
119 PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
120
121 void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
122 wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
123
124 void RedrawProject(const bool bForceWaveTracks = false);
125
126 void Zoom(double level);
127 void ZoomInByFactor( double ZoomFactor );
128 void ZoomOutByFactor( double ZoomFactor );
129 void ZoomBy(double multiplier);
130 void ZoomAfterImport(Track *pTrack);
131 double GetZoomOfToFit() const;
132 void DoZoomFit();
133
134 void ApplyUpdatedTheme();
135
136 // Scrollbars
137
138 wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
139 wxScrollBar &GetHorizontalScrollBar() { return *mHsbar; }
140
141 void ScrollIntoView(double pos);
142 void ScrollIntoView(int x);
143
144 void OnScrollLeft();
145 void OnScrollRight();
146
147 void Rewind(bool shift);
148 void SkipEnd(bool shift);
149
150 void OnScrollLeftButton(wxScrollEvent & event);
151 void OnScrollRightButton(wxScrollEvent & event);
152
153 void FinishAutoScroll();
154 void FixScrollbars();
155
156 bool MayScrollBeyondZero() const;
157 double ScrollingLowerBoundTime() const;
158 // How many pixels are covered by the period from lowermost scrollable time, to the given time:
159 // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
160 double PixelWidthBeforeTime(double scrollto) const;
161 void SetHorizontalThumb(double scrollto);
162
163 // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
164 // TrackPanel access
165 wxSize GetTPTracksUsableArea() /* not override */;
166 void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
167
168 void TP_RedrawScrollbars() override;
169 void TP_ScrollLeft() override;
170 void TP_ScrollRight() override;
171 void TP_ScrollWindow(double scrollto) override;
172 bool TP_ScrollUpDown(int delta) override;
173 void TP_HandleResize() override;
174
175 private:
176
177 void OnThemeChange(struct ThemeChangeMessage);
178
179 // PrefsListener implementation
180 void UpdatePrefs() override;
181
182 public:
183 // Message Handlers
184
185 void OnMenu(wxCommandEvent & event);
186 void OnUpdateUI(wxUpdateUIEvent & event);
187
188 void MacShowUndockedToolbars(bool show);
189 void OnActivate(wxActivateEvent & event);
190
191 void OnMouseEvent(wxMouseEvent & event);
192 void OnIconize(wxIconizeEvent &event);
193 void OnSize(wxSizeEvent & event);
194 void HandleResize();
195 void UpdateLayout();
196 void OnShow(wxShowEvent & event);
197 void OnMove(wxMoveEvent & event);
198 void DoScroll();
199 void OnScroll(wxScrollEvent & event);
200 void OnToolBarUpdate(wxCommandEvent & event);
201 void OnUndoPushedModified();
202 void OnUndoRedo();
203 void OnUndoReset();
204
205 bool mbInitializingScrollbar{ false };
206
207private:
209
210 wxPanel *mTopPanel{};
211 wxSplitterWindow* mContainerWindow;
212 wxWindow* mTrackListWindow{};
213
214 wxScrollBar *mHsbar{};
215 wxScrollBar *mVsbar{};
216
217 int mNextWindowID{};
218
219 bool mAutoScrolling{ false };
220 bool mActive{ true };
221 bool mIconized{ false };
222 bool mShownOnce{ false };
223
224
225
226 bool mIsDeleting{ false };
227
228private:
229
232 std::unique_ptr<PlaybackScroller> mPlaybackScroller;
233
234 DECLARE_EVENT_TABLE()
235};
236
237void GetDefaultWindowRect(wxRect *defRect);
238void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
239
240extern AUDACITY_DLL_API BoolSetting ProjectWindowMaximized;
241extern AUDACITY_DLL_API BoolSetting ProjectWindowIconized;
242extern AUDACITY_DLL_API IntSetting ProjectWindowX;
243extern AUDACITY_DLL_API IntSetting ProjectWindowY;
244extern AUDACITY_DLL_API IntSetting ProjectWindowWidth;
245extern AUDACITY_DLL_API IntSetting ProjectWindowHeight;
246extern AUDACITY_DLL_API IntSetting ProjectWindowNormalX;
247extern AUDACITY_DLL_API IntSetting ProjectWindowNormalY;
248extern AUDACITY_DLL_API IntSetting ProjectWindowNormalWidth;
249extern AUDACITY_DLL_API IntSetting ProjectWindowNormalHeight;
250
251#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:2464
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:40
wxScrollBar & GetHorizontalScrollBar()
PlaybackScroller & GetPlaybackScroller()
wxSplitterWindow * mContainerWindow
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:62
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Observer::Subscription mUndoSubscription
wxRect mNormalizedWindowState
void SetIsBeingDeleted()
Definition: ProjectWindow.h:63
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:194
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
TranslatableString Message(unsigned trackCount)
Default message type for Publisher.
Definition: Observer.h:26
Message sent when the project window is closed.
Definition: ProjectWindow.h:32