Audacity 3.2.0
ActiveProject.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file ActiveProject.cpp
6
7 Paul Licameli split from Project.cpp
8
9 **********************************************************************/
10
11#include "ActiveProject.h"
12#include "KeyboardCapture.h"
13#include "Project.h"
14#include "ProjectWindows.h"
15
16#include <wx/app.h>
17#include <wx/frame.h>
18
19//This is a pointer to the currently-active project.
20static std::weak_ptr<AudacityProject> gActiveProject;
21
22AUDACITY_DLL_API std::weak_ptr<AudacityProject> GetActiveProject()
23{
24 return gActiveProject;
25}
26
28{
29 auto pProject = project ? project->shared_from_this() : nullptr;
30 if ( gActiveProject.lock() != pProject ) {
31 gActiveProject = pProject;
32 KeyboardCapture::Capture( nullptr );
33 }
34 wxTheApp->SetTopWindow( FindProjectFrame( project ) );
35}
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
void SetActiveProject(AudacityProject *project)
static std::weak_ptr< AudacityProject > gActiveProject
Handle changing of active project and keep global project pointer.
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
accessors for certain important windows associated with each project
const auto 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
void Capture(wxWindow *handler)