Audacity 3.2.0
ProjectStatus.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectStatus.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#include "ProjectStatus.h"
12
13#include "Project.h"
14
16 []( AudacityProject &parent ){
17 return std::make_shared< ProjectStatus >( parent );
18 }
19};
20
22{
23 return project.AttachedObjects::Get< ProjectStatus >( key );
24}
25
27{
28 return Get( const_cast< AudacityProject & >( project ) );
29}
30
32 : mProject{ project }
33{
34}
35
37
38namespace
39{
41 {
42 static ProjectStatus::StatusWidthFunctions theFunctions;
43 return theFunctions;
44 }
45}
46
48 const StatusWidthFunction &function )
49{
50 statusWidthFunctions().emplace_back( function );
51}
52
54{
55 return statusWidthFunctions();
56}
57
59{
60 return mLastStatusMessages[ field - 1 ];
61}
62
64{
65 auto &project = mProject;
66 auto &lastMessage = mLastStatusMessages[ field - 1 ];
67 // compare full translations not msgids!
68 if ( msg.Translation() != lastMessage.Translation() ) {
69 lastMessage = msg;
71 }
72}
73
75{
76 auto &project = mProject;
77 for (auto field = 1; field <= nStatusBarFields; ++field)
78 Publish(static_cast<StatusBarField>(field));
79}
#define field(n, t)
Definition: ImportAUP.cpp:167
static const AudacityProject::AttachedObjects::RegisteredFactory key
StatusBarField
Definition: ProjectStatus.h:24
@ nStatusBarFields
Definition: ProjectStatus.h:29
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
CallbackReturn Publish(const StatusBarField &message)
Send a message to connected callbacks.
Definition: Observer.h:207
~ProjectStatus() override
ProjectStatus(AudacityProject &project)
static const StatusWidthFunctions & GetStatusWidthFunctions()
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)
TranslatableString mLastStatusMessages[nStatusBarFields]
Definition: ProjectStatus.h:73
std::function< StatusWidthResult(const AudacityProject &, StatusBarField) > StatusWidthFunction
Definition: ProjectStatus.h:52
std::vector< StatusWidthFunction > StatusWidthFunctions
Definition: ProjectStatus.h:53
AudacityProject & mProject
Definition: ProjectStatus.h:72
void UpdatePrefs() override
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
ProjectStatus::StatusWidthFunctions & statusWidthFunctions()
RegisteredStatusWidthFunction(const StatusWidthFunction &function)