Audacity 3.2.0
Namespaces | Functions | Variables
ProjectManager.cpp File Reference
#include "ProjectManager.h"
#include "ActiveProject.h"
#include "AdornedRulerPanel.h"
#include "AudioIO.h"
#include "Clipboard.h"
#include "FileNames.h"
#include "MenuCreator.h"
#include "ModuleManager.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectAudioManager.h"
#include "ProjectFileIO.h"
#include "ProjectFileIOExtension.h"
#include "ProjectFileManager.h"
#include "ProjectHistory.h"
#include "ProjectRate.h"
#include "ProjectSettings.h"
#include "ProjectStatus.h"
#include "ProjectWindow.h"
#include "ProjectWindows.h"
#include "SelectUtilities.h"
#include "TrackPanel.h"
#include "TrackUtilities.h"
#include "UndoManager.h"
#include "Viewport.h"
#include "WaveTrack.h"
#include "wxFileNameWrapper.h"
#include "Import.h"
#include "QualitySettings.h"
#include "toolbars/MeterToolBar.h"
#include "toolbars/ToolManager.h"
#include "AudacityMessageBox.h"
#include "widgets/FileHistory.h"
#include "WindowAccessible.h"
#include <wx/app.h>
#include <wx/scrolbar.h>
#include <wx/sizer.h>
#include <wx/splitter.h>
#include "../images/AudacityLogoAlpha.xpm"
Include dependency graph for ProjectManager.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{ProjectManager.cpp}
 

Functions

void anonymous_namespace{ProjectManager.cpp}::SaveWindowPreferences (const wxRect &windowRect, const wxRect &normalRect, bool isMaximized, bool isIconized)
 
void InitProjectWindow (ProjectWindow &window)
 

Variables

const int AudacityProjectTimerID = 5200
 
static AudacityProject::AttachedObjects::RegisteredFactory sProjectManagerKey
 
static bool sbClosingAll = false
 

Function Documentation

◆ InitProjectWindow()

void InitProjectWindow ( ProjectWindow window)

Definition at line 162 of file ProjectManager.cpp.

163{
164 auto pProject = window.FindProject();
165 if (!pProject)
166 return;
167 auto &project = *pProject;
168 auto &viewport = Viewport::Get(project);
169
170 auto statusBar = window.CreateProjectStatusBar();
171
172 auto &viewInfo = ViewInfo::Get( project );
173
174 // LLL: Read this!!!
175 //
176 // Until the time (and cpu) required to refresh the track panel is
177 // reduced, leave the following window creations in the order specified.
178 // This will place the refresh of the track panel last, allowing all
179 // the others to get done quickly.
180 //
181 // Near as I can tell, this is only a problem under Windows.
182 //
183
184 //
185 // Create the ToolDock
186 //
189
190 //
191 // Create the TrackPanel and the scrollbars
192 //
193
194 auto topPanel = window.GetTopPanel();
195
196 {
197 auto ubs = std::make_unique<wxBoxSizer>(wxVERTICAL);
198 ubs->Add( ToolManager::Get( project ).GetTopDock(), 0, wxEXPAND | wxALIGN_TOP );
199 topPanel->SetSizer(ubs.release());
200 }
201
202 wxBoxSizer *bs;
203 {
204 auto ubs = std::make_unique<wxBoxSizer>(wxVERTICAL);
205 bs = ubs.get();
206 bs->Add(topPanel, 0, wxEXPAND | wxALIGN_TOP);
207 bs->Add(window.GetContainerWindow(), 1, wxEXPAND);
208 bs->Add( ToolManager::Get( project ).GetBotDock(), 0, wxEXPAND );
209 window.SetAutoLayout(true);
210 window.SetSizer(ubs.release());
211 }
212 bs->Layout();
213
214 auto &trackPanel = TrackPanel::Get( project );
215
216 // LLL: When Audacity starts or becomes active after returning from
217 // another application, the first window that can accept focus
218 // will be given the focus even if we try to SetFocus(). By
219 // making the TrackPanel that first window, we resolve several
220 // keyboard focus problems.
221 window.GetContainerWindow()->MoveAfterInTabOrder(topPanel);
222
223 const auto trackListWindow = window.GetTrackListWindow();
224
225 //
226 // Create the horizontal ruler
227 //
229
230 bs = static_cast<wxBoxSizer*>(trackListWindow->GetSizer());
231
232 auto vsBar = &window.GetVerticalScrollBar();
233 auto hsBar = &window.GetHorizontalScrollBar();
234
235 {
236 // Top horizontal grouping
237 auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
238
239 // Track panel
240 hs->Add(&trackPanel, 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP);
241
242 {
243 // Vertical grouping
244 auto vs = std::make_unique<wxBoxSizer>(wxVERTICAL);
245
246 // Vertical scroll bar
247 vs->Add(vsBar, 1, wxEXPAND | wxALIGN_TOP);
248 hs->Add(vs.release(), 0, wxEXPAND | wxALIGN_TOP);
249 }
250
251 bs->Add(&ruler, 0, wxEXPAND | wxALIGN_TOP);
252 bs->Add(hs.release(), 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP);
253 }
254
255 {
256 // Bottom horizontal grouping
257 auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
258
259 // Bottom scrollbar
260 hs->Add(viewInfo.GetLeftOffset() - 1, 0);
261 hs->Add(hsBar, 1, wxALIGN_BOTTOM);
262 hs->Add(vsBar->GetSize().GetWidth(), 0);
263 bs->Add(hs.release(), 0, wxEXPAND | wxALIGN_LEFT);
264 }
265
266 // Lay it out
267 trackListWindow->SetAutoLayout(true);
268 trackListWindow->Layout();
269
270 wxASSERT( trackPanel.GetProject() == &project );
271
272 // MM: Give track panel the focus to ensure keyboard commands work
273 trackPanel.SetFocus();
274
275 viewport.UpdateScrollbarsForTracks();
276 ruler.SetLeftOffset(viewInfo.GetLeftOffset()); // bevel on AdornedRuler
277
278 //
279 // Set the Icon
280 //
281
282 // loads either the XPM or the windows resource, depending on the platform
283#if !defined(__WXMAC__) && !defined(__WXX11__)
284 {
285#if defined(__WXMSW__)
286 wxIcon ic{ wxICON(AudacityLogo) };
287#elif defined(__WXGTK__)
288 wxIcon ic{wxICON(AudacityLogoAlpha)};
289#else
290 wxIcon ic{};
291 ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
292#endif
293 window.SetIcon(ic);
294 }
295#endif
296
297 window.UpdateStatusWidths();
298 auto msg = XO("Welcome to Audacity version %s")
299 .Format( AUDACITY_VERSION_STRING );
301}
XO("Cut/Copy/Paste")
StatusBarField MainStatusBarField()
ID of the second field in the status bar. This field is expandable.
const auto project
THEME_API Theme theTheme
Definition: Theme.cpp:82
static AdornedRulerPanel & Get(AudacityProject &project)
static ProjectManager & Get(AudacityProject &project)
void SetStatusText(const TranslatableString &text, const StatusBarField &field)
std::shared_ptr< AudacityProject > FindProject()
wxScrollBar & GetHorizontalScrollBar()
wxScrollBar & GetVerticalScrollBar()
wxPanel * GetTopPanel() noexcept
Top panel contains project-related controls and tools.
wxWindow * GetTrackListWindow() noexcept
Track list window is the parent container for TrackPanel.
wxSplitterWindow * GetContainerWindow() noexcept
Container is a parent window for both effects panel and track list windows.
wxStatusBar * CreateProjectStatusBar()
void UpdateStatusWidths()
wxBitmap & Bitmap(int iIndex)
static ToolManager & Get(AudacityProject &project)
void CreateWindows()
void LayoutToolBars()
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33

References ThemeBase::Bitmap(), ProjectWindow::CreateProjectStatusBar(), ToolManager::CreateWindows(), ProjectWindowBase::FindProject(), ViewInfo::Get(), Viewport::Get(), AdornedRulerPanel::Get(), ProjectManager::Get(), ToolManager::Get(), TrackPanel::Get(), ProjectWindow::GetContainerWindow(), ProjectWindow::GetHorizontalScrollBar(), ProjectWindow::GetTopPanel(), ProjectWindow::GetTrackListWindow(), ProjectWindow::GetVerticalScrollBar(), ToolManager::LayoutToolBars(), MainStatusBarField(), project, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), ProjectManager::SetStatusText(), theTheme, ProjectWindow::UpdateStatusWidths(), and XO().

Referenced by ProjectManager::New().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ AudacityProjectTimerID

const int AudacityProjectTimerID = 5200

Definition at line 71 of file ProjectManager.cpp.

◆ sbClosingAll

bool sbClosingAll = false
static

◆ sProjectManagerKey

Initial value:
{
return std::make_shared< ProjectManager >( project );
}
}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

Definition at line 73 of file ProjectManager.cpp.

Referenced by ProjectManager::Get().