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 "Prefs.h"
17#include "Viewport.h"
18
19class wxScrollBar;
20class wxPanel;
21class wxSplitterWindow;
23enum class ProjectFileIOMessage : int;
24
25class ProjectWindow;
26void InitProjectWindow( ProjectWindow &window );
27
30
33class AUDACITY_DLL_API ProjectWindow final : public ProjectWindowBase
34, public PrefsListener
35 , public Observer::Publisher<ProjectWindowDestroyedMessage>
36{
37public:
40 static const ProjectWindow &Get( const AudacityProject &project );
41 static ProjectWindow *Find( AudacityProject *pProject );
42 static const ProjectWindow *Find( const AudacityProject *pProject );
43
44 explicit ProjectWindow(
45 wxWindow * parent, wxWindowID id,
46 const wxPoint & pos, const wxSize &size,
48 ~ProjectWindow() override;
49
50 // Next available ID for sub-windows
51 int NextWindowID();
52
53 bool IsActive() override;
54 bool IsIconized() const override;
55
56 bool IsBeingDeleted() const { return mIsDeleting; }
57 void SetIsBeingDeleted() { mIsDeleting = true; }
58
63 wxWindow* GetTrackListWindow() noexcept;
69 wxSplitterWindow* GetContainerWindow() noexcept;
74 wxPanel *GetTopPanel() noexcept;
75
76 void UpdateStatusWidths();
77
79
80 class PlaybackScroller final
81 : public Observer::Publisher<PlaybackScrollerMessage>
82 {
83 public:
85
86 enum class Mode {
87 Off,
88 Refresh,
89 Pinned,
90 Right,
91 };
92
93 Mode GetMode() const { return mMode; }
94 void Activate(Mode mode)
95 {
96 mMode = mode;
97 }
98
99 double GetRecentStreamTime() const { return mRecentStreamTime; }
100
101 void OnTimer();
102
103 private:
105 Mode mMode { Mode::Off };
106
107 // During timer update, grab the volatile stream time just once, so that
108 // various other drawing code can use the exact same value.
109 double mRecentStreamTime{ -1.0 };
110 };
111 PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
112
113 void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
114 wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
115
116
117 void ApplyUpdatedTheme();
118
119 // Scrollbars
120
121 wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
122 wxScrollBar &GetHorizontalScrollBar() { return *mHsbar; }
123
124 void OnScrollLeftButton(wxScrollEvent & event);
125 void OnScrollRightButton(wxScrollEvent & event);
126
127 std::pair<int, int> ViewportSize() const;
128 unsigned MinimumTrackHeight() ;
129 bool IsTrackMinimized(const Track &track) ;
130 void SetMinimized(Track &track, bool minimized) ;
131 int GetTrackHeight(const Track &track) ;
132 void SetChannelHeights(Track &track, unsigned height) ;
133 int GetTotalHeight(const TrackList &trackList) ;
134 int GetHorizontalThumbPosition() const ;
135 int GetHorizontalThumbSize() const ;
136 int GetHorizontalRange() const ;
137 void SetHorizontalThumbPosition(int viewStart) ;
138 void SetHorizontalScrollbar(int position, int thumbSize,
139 int range, int pageSize, bool refresh) ;
140 void ShowHorizontalScrollbar(bool shown) ;
141
142 int GetVerticalThumbPosition() const ;
143 int GetVerticalThumbSize() const ;
144 int GetVerticalRange() const ;
145 void SetVerticalThumbPosition(int viewStart) ;
146 void SetVerticalScrollbar(int position, int thumbSize,
147 int range, int pageSize, bool refresh) ;
148 void ShowVerticalScrollbar(bool shown) ;
149
150 void SetToDefaultSize();
151
152 // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
153 // TrackPanel access
154 wxSize GetTPTracksUsableArea() /* not override */;
155 void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
156
157 wxStatusBar* CreateProjectStatusBar();
158 private:
159 void OnThemeChange(struct ThemeChangeMessage);
160
161 // PrefsListener implementation
162 void UpdatePrefs() override;
163
164 public:
165 // Message Handlers
166
167 void OnMenu(wxCommandEvent & event);
168 void OnUpdateUI(wxUpdateUIEvent & event);
169
170 void MacShowUndockedToolbars(bool show);
171 void OnActivate(wxActivateEvent & event);
172
173 void OnMouseEvent(wxMouseEvent & event);
174 void OnIconize(wxIconizeEvent &event);
175 void OnSize(wxSizeEvent & event);
176 void UpdateLayout();
177 void OnShow(wxShowEvent & event);
178 void OnMove(wxMoveEvent & event);
179 void OnScroll(wxScrollEvent & event);
180 void OnToolBarUpdate(wxCommandEvent & event);
181 void OnProjectTitleChange(ProjectFileIOMessage);
182
183private:
185
186 wxPanel *mTopPanel{};
187 wxSplitterWindow* mContainerWindow;
188 wxWindow* mTrackListWindow{};
189
190 wxScrollBar *mHsbar{};
191 wxScrollBar *mVsbar{};
192
193 int mNextWindowID{};
194
195 bool mActive{ true };
196 bool mIconized{ false };
197 bool mShownOnce{ false };
198
199
200
201 bool mIsDeleting{ false };
202
203private:
204 void OnViewportMessage(const ViewportMessage &message);
205
210 ;
211 std::unique_ptr<PlaybackScroller> mPlaybackScroller;
213
214 DECLARE_EVENT_TABLE()
215};
216
217void GetDefaultWindowRect(wxRect *defRect);
218void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
219
220extern AUDACITY_DLL_API BoolSetting ProjectWindowMaximized;
221extern AUDACITY_DLL_API BoolSetting ProjectWindowIconized;
222extern AUDACITY_DLL_API IntSetting ProjectWindowX;
223extern AUDACITY_DLL_API IntSetting ProjectWindowY;
224extern AUDACITY_DLL_API IntSetting ProjectWindowWidth;
225extern AUDACITY_DLL_API IntSetting ProjectWindowHeight;
226extern AUDACITY_DLL_API IntSetting ProjectWindowNormalX;
227extern AUDACITY_DLL_API IntSetting ProjectWindowNormalY;
228extern AUDACITY_DLL_API IntSetting ProjectWindowNormalWidth;
229extern AUDACITY_DLL_API IntSetting ProjectWindowNormalHeight;
230
231#endif
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
Definition: ProjectFileIO.h:50
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
const auto project
static void OnSize(wxSizeEvent &evt)
Definition: VSTEditor.cpp:224
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:346
Specialization of Setting for int.
Definition: Prefs.h:356
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:652
virtual void UpdatePrefs()=0
Definition: Prefs.cpp:154
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
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:56
Observer::Subscription mTitleChangeSubscription
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Observer::Subscription mSnappingChangedSubscription
wxRect mNormalizedWindowState
void SetIsBeingDeleted()
Definition: ProjectWindow.h:57
const Observer::Subscription mViewportSubscription
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:110
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
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:202
AUDACITY_DLL_API unsigned MinimumTrackHeight()
TranslatableString Message(unsigned trackCount)
Default message type for Publisher.
Definition: Observer.h:26
Message sent when the project window is closed.
Definition: ProjectWindow.h:29