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;
27enum class ProjectFileIOMessage : int;
28
29class ProjectWindow;
30void InitProjectWindow( ProjectWindow &window );
31
34
37class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase
38 , public TrackPanelListener
39 , public PrefsListener
40 , public Observer::Publisher<ProjectWindowDestroyedMessage>
41{
42public:
44 static ProjectWindow &Get( AudacityProject &project );
45 static const ProjectWindow &Get( const AudacityProject &project );
46 static ProjectWindow *Find( AudacityProject *pProject );
47 static const ProjectWindow *Find( const AudacityProject *pProject );
48
49 static void OnResetWindow(const CommandContext& context);
50
51 explicit ProjectWindow(
52 wxWindow * parent, wxWindowID id,
53 const wxPoint & pos, const wxSize &size,
54 AudacityProject &project );
55 ~ProjectWindow() override;
56
57 // Next available ID for sub-windows
58 int NextWindowID();
59
60 bool IsActive() override;
61 bool IsIconized() const override;
62
63 bool IsBeingDeleted() const { return mIsDeleting; }
64 void SetIsBeingDeleted() { mIsDeleting = true; }
65
66 void Reset();
67
72 wxWindow* GetTrackListWindow() noexcept;
78 wxSplitterWindow* 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 ApplyUpdatedTheme();
136
137 // Scrollbars
138
139 wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
140 wxScrollBar &GetHorizontalScrollBar() { return *mHsbar; }
141
142 void ScrollIntoView(double pos);
143 void ScrollIntoView(int x);
144
145 void OnScrollLeft();
146 void OnScrollRight();
147
148 void Rewind(bool shift);
149 void SkipEnd(bool shift);
150
151 void OnScrollLeftButton(wxScrollEvent & event);
152 void OnScrollRightButton(wxScrollEvent & event);
153
154 void FinishAutoScroll();
155 void FixScrollbars();
156
157 bool MayScrollBeyondZero() const;
158 double ScrollingLowerBoundTime() const;
159 // How many pixels are covered by the period from lowermost scrollable time, to the given time:
160 // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
161 double PixelWidthBeforeTime(double scrollto) const;
162 void SetHorizontalThumb(double scrollto);
163
164 // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
165 // TrackPanel access
166 wxSize GetTPTracksUsableArea() /* not override */;
167 void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
168
169 void TP_RedrawScrollbars() override;
170 void TP_ScrollLeft() override;
171 void TP_ScrollRight() override;
172 void TP_ScrollWindow(double scrollto) override;
173 bool TP_ScrollUpDown(int delta) override;
174 void TP_HandleResize() override;
175
176 private:
177
178 void OnThemeChange(struct ThemeChangeMessage);
179
180 // PrefsListener implementation
181 void UpdatePrefs() override;
182
183 public:
184 // Message Handlers
185
186 void OnMenu(wxCommandEvent & event);
187 void OnUpdateUI(wxUpdateUIEvent & event);
188
189 void MacShowUndockedToolbars(bool show);
190 void OnActivate(wxActivateEvent & event);
191
192 void OnMouseEvent(wxMouseEvent & event);
193 void OnIconize(wxIconizeEvent &event);
194 void OnSize(wxSizeEvent & event);
195 void HandleResize();
196 void UpdateLayout();
197 void OnShow(wxShowEvent & event);
198 void OnMove(wxMoveEvent & event);
199 void DoScroll();
200 void OnScroll(wxScrollEvent & event);
201 void OnToolBarUpdate(wxCommandEvent & event);
202 void OnUndoPushedModified();
203 void OnUndoRedo();
204 void OnUndoReset();
205 void OnProjectTitleChange(ProjectFileIOMessage);
206
207 bool mbInitializingScrollbar{ false };
208
209private:
211
212 wxPanel *mTopPanel{};
213 wxSplitterWindow* mContainerWindow;
214 wxWindow* mTrackListWindow{};
215
216 wxScrollBar *mHsbar{};
217 wxScrollBar *mVsbar{};
218
219 int mNextWindowID{};
220
221 bool mAutoScrolling{ false };
222 bool mActive{ true };
223 bool mIconized{ false };
224 bool mShownOnce{ false };
225
226
227
228 bool mIsDeleting{ false };
229
230private:
231
235 ;
236 std::unique_ptr<PlaybackScroller> mPlaybackScroller;
237
238 DECLARE_EVENT_TABLE()
239};
240
241void GetDefaultWindowRect(wxRect *defRect);
242void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
243
244extern AUDACITY_DLL_API BoolSetting ProjectWindowMaximized;
245extern AUDACITY_DLL_API BoolSetting ProjectWindowIconized;
246extern AUDACITY_DLL_API IntSetting ProjectWindowX;
247extern AUDACITY_DLL_API IntSetting ProjectWindowY;
248extern AUDACITY_DLL_API IntSetting ProjectWindowWidth;
249extern AUDACITY_DLL_API IntSetting ProjectWindowHeight;
250extern AUDACITY_DLL_API IntSetting ProjectWindowNormalX;
251extern AUDACITY_DLL_API IntSetting ProjectWindowNormalY;
252extern AUDACITY_DLL_API IntSetting ProjectWindowNormalWidth;
253extern AUDACITY_DLL_API IntSetting ProjectWindowNormalHeight;
254
255#endif
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
Definition: ProjectFileIO.h:49
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:2546
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
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:556
A top-level window associated with a project.
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:41
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:63
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Observer::Subscription mTitleChangeSubcription
Observer::Subscription mUndoSubscription
wxRect mNormalizedWindowState
void SetIsBeingDeleted()
Definition: ProjectWindow.h:64
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:226
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
PROJECT_FILE_IO_API wxString Find(const FilePath &path)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
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:33