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 "Menus.h"
#include "ModuleManager.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectAudioManager.h"
#include "ProjectFileIO.h"
#include "ProjectFileManager.h"
#include "ProjectHistory.h"
#include "ProjectSelectionManager.h"
#include "ProjectWindows.h"
#include "ProjectRate.h"
#include "ProjectSettings.h"
#include "ProjectStatus.h"
#include "ProjectWindow.h"
#include "SelectUtilities.h"
#include "TrackPanel.h"
#include "TrackUtilities.h"
#include "UndoManager.h"
#include "WaveTrack.h"
#include "wxFileNameWrapper.h"
#include "import/Import.h"
#include "import/ImportMIDI.h"
#include "QualitySettings.h"
#include "toolbars/MeterToolBar.h"
#include "toolbars/SelectionBar.h"
#include "toolbars/SpectralSelectionBar.h"
#include "toolbars/TimeToolBar.h"
#include "toolbars/ToolManager.h"
#include "widgets/AudacityMessageBox.h"
#include "widgets/FileHistory.h"
#include "widgets/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 168 of file ProjectManager.cpp.

169{
170 auto pProject = window.FindProject();
171 if (!pProject)
172 return;
173 auto &project = *pProject;
174
175#ifdef EXPERIMENTAL_DA2
176 SetBackgroundColour(theTheme.Colour( clrMedium ));
177#endif
178 // Note that the first field of the status bar is a dummy, and its width is set
179 // to zero latter in the code. This field is needed for wxWidgets 2.8.12 because
180 // if you move to the menu bar, the first field of the menu bar is cleared, which
181 // is undesirable behaviour.
182 // In addition, the help strings of menu items are by default sent to the first
183 // field. Currently there are no such help strings, but it they were introduced, then
184 // there would need to be an event handler to send them to the appropriate field.
185 auto statusBar = window.CreateStatusBar(4);
186#if wxUSE_ACCESSIBILITY
187 // so that name can be set on a standard control
188 statusBar->SetAccessible(safenew WindowAccessible(statusBar));
189#endif
190 statusBar->SetName(wxT("status_line")); // not localized
191
192 auto &viewInfo = ViewInfo::Get( project );
193
194 // LLL: Read this!!!
195 //
196 // Until the time (and cpu) required to refresh the track panel is
197 // reduced, leave the following window creations in the order specified.
198 // This will place the refresh of the track panel last, allowing all
199 // the others to get done quickly.
200 //
201 // Near as I can tell, this is only a problem under Windows.
202 //
203
204 //
205 // Create the ToolDock
206 //
207 ToolManager::Get( project ).CreateWindows();
208 ToolManager::Get( project ).LayoutToolBars();
209
210 //
211 // Create the TrackPanel and the scrollbars
212 //
213
214 auto topPanel = window.GetTopPanel();
215
216 {
217 auto ubs = std::make_unique<wxBoxSizer>(wxVERTICAL);
218 ubs->Add( ToolManager::Get( project ).GetTopDock(), 0, wxEXPAND | wxALIGN_TOP );
219 topPanel->SetSizer(ubs.release());
220 }
221
222 wxBoxSizer *bs;
223 {
224 auto ubs = std::make_unique<wxBoxSizer>(wxVERTICAL);
225 bs = ubs.get();
226 bs->Add(topPanel, 0, wxEXPAND | wxALIGN_TOP);
227 bs->Add(window.GetContainerWindow(), 1, wxEXPAND);
228 bs->Add( ToolManager::Get( project ).GetBotDock(), 0, wxEXPAND );
229 window.SetAutoLayout(true);
230 window.SetSizer(ubs.release());
231 }
232 bs->Layout();
233
234 auto &trackPanel = TrackPanel::Get( project );
235
236 // LLL: When Audacity starts or becomes active after returning from
237 // another application, the first window that can accept focus
238 // will be given the focus even if we try to SetFocus(). By
239 // making the TrackPanel that first window, we resolve several
240 // keyboard focus problems.
241 window.GetContainerWindow()->MoveAfterInTabOrder(topPanel);
242
243 const auto trackListWindow = window.GetTrackListWindow();
244
245 //
246 // Create the horizontal ruler
247 //
248 auto &ruler = AdornedRulerPanel::Get( project );
249
250 bs = static_cast<wxBoxSizer*>(trackListWindow->GetSizer());
251
252 auto vsBar = &window.GetVerticalScrollBar();
253 auto hsBar = &window.GetHorizontalScrollBar();
254
255 {
256 // Top horizontal grouping
257 auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
258
259 // Track panel
260 hs->Add(&trackPanel, 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP);
261
262 {
263 // Vertical grouping
264 auto vs = std::make_unique<wxBoxSizer>(wxVERTICAL);
265
266 // Vertical scroll bar
267 vs->Add(vsBar, 1, wxEXPAND | wxALIGN_TOP);
268 hs->Add(vs.release(), 0, wxEXPAND | wxALIGN_TOP);
269 }
270
271 bs->Add(&ruler, 0, wxEXPAND | wxALIGN_TOP);
272 bs->Add(hs.release(), 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP);
273 }
274
275 {
276 // Bottom horizontal grouping
277 auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
278
279 // Bottom scrollbar
280 hs->Add(viewInfo.GetLeftOffset() - 1, 0);
281 hs->Add(hsBar, 1, wxALIGN_BOTTOM);
282 hs->Add(vsBar->GetSize().GetWidth(), 0);
283 bs->Add(hs.release(), 0, wxEXPAND | wxALIGN_LEFT);
284 }
285
286 // Lay it out
287 trackListWindow->SetAutoLayout(true);
288 trackListWindow->Layout();
289
290 wxASSERT( trackPanel.GetProject() == &project );
291
292 // MM: Give track panel the focus to ensure keyboard commands work
293 trackPanel.SetFocus();
294
295 window.FixScrollbars();
296 ruler.SetLeftOffset(viewInfo.GetLeftOffset()); // bevel on AdornedRuler
297
298 //
299 // Set the Icon
300 //
301
302 // loads either the XPM or the windows resource, depending on the platform
303#if !defined(__WXMAC__) && !defined(__WXX11__)
304 {
305#if defined(__WXMSW__)
306 wxIcon ic{ wxICON(AudacityLogo) };
307#elif defined(__WXGTK__)
308 wxIcon ic{wxICON(AudacityLogoAlpha)};
309#else
310 wxIcon ic{};
311 ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
312#endif
313 window.SetIcon(ic);
314 }
315#endif
316
317 window.UpdateStatusWidths();
318 auto msg = XO("Welcome to Audacity version %s")
319 .Format( AUDACITY_VERSION_STRING );
321
322#ifdef EXPERIMENTAL_DA2
323 ClearBackground();// For wxGTK.
324#endif
325}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
@ mainStatusBarField
Definition: ProjectStatus.h:26
THEME_API Theme theTheme
Definition: Theme.cpp:82
static AdornedRulerPanel & Get(AudacityProject &project)
static ProjectManager & Get(AudacityProject &project)
void SetStatusText(const TranslatableString &text, int number)
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.
void UpdateStatusWidths()
wxColour & Colour(int iIndex)
wxBitmap & Bitmap(int iIndex)
static ToolManager & Get(AudacityProject &project)
void CreateWindows()
void LayoutToolBars()
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:234
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References ThemeBase::Bitmap(), ThemeBase::Colour(), ToolManager::CreateWindows(), ProjectWindowBase::FindProject(), ProjectWindow::FixScrollbars(), ViewInfo::Get(), AdornedRulerPanel::Get(), ProjectManager::Get(), ToolManager::Get(), TrackPanel::Get(), ProjectWindow::GetContainerWindow(), ProjectWindow::GetHorizontalScrollBar(), ProjectWindow::GetTopPanel(), ProjectWindow::GetTrackListWindow(), ProjectWindow::GetVerticalScrollBar(), ToolManager::LayoutToolBars(), mainStatusBarField, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), safenew, ProjectManager::SetStatusText(), theTheme, ProjectWindow::UpdateStatusWidths(), wxT(), 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 77 of file ProjectManager.cpp.

◆ sbClosingAll

bool sbClosingAll = false
static

◆ sProjectManagerKey

Initial value:
{
[]( AudacityProject &project ) {
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 79 of file ProjectManager.cpp.

Referenced by ProjectManager::Get().