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
19wxDEFINE_EVENT(EVT_PROJECT_ACTIVATION, wxCommandEvent);
20
21//This is a pointer to the currently-active project.
22static std::weak_ptr<AudacityProject> gActiveProject;
23
24AUDACITY_DLL_API std::weak_ptr<AudacityProject> GetActiveProject()
25{
26 return gActiveProject;
27}
28
30{
31 auto pProject = project ? project->shared_from_this() : nullptr;
32 if ( gActiveProject.lock() != pProject ) {
33 gActiveProject = pProject;
34 KeyboardCapture::Capture( nullptr );
35 wxTheApp->QueueEvent( safenew wxCommandEvent{ EVT_PROJECT_ACTIVATION } );
36 }
37 wxTheApp->SetTopWindow( FindProjectFrame( project ) );
38}
wxDEFINE_EVENT(EVT_PROJECT_ACTIVATION, wxCommandEvent)
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.
#define safenew
Definition: MemoryX.h:10
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
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
void Capture(wxWindow *handler)