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 "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 161 of file ProjectManager.cpp.

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

References ThemeBase::Bitmap(), ThemeBase::Colour(), 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(), 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 70 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 72 of file ProjectManager.cpp.

Referenced by ProjectManager::Get().