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