Audacity 3.2.0
ProjectStatus.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectStatus.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT_STATUS__
12#define __AUDACITY_PROJECT_STATUS__
13#endif
14
15#include <utility>
16#include <vector>
17#include "ClientData.h" // to inherit
18#include "Prefs.h"
19#include "Observer.h"
20
21class AudacityProject;
22class wxWindow;
23
24enum StatusBarField : int {
28
30};
31
32class PROJECT_API ProjectStatus final
33 : public ClientData::Base
34 , public PrefsListener
35 , public Observer::Publisher<StatusBarField>
36{
37public:
38 static ProjectStatus &Get( AudacityProject &project );
39 static const ProjectStatus &Get( const AudacityProject &project );
40
41 explicit ProjectStatus( AudacityProject &project );
42 ProjectStatus( const ProjectStatus & ) = delete;
44 ~ProjectStatus() override;
45
46 // Type of a function to report translatable strings, and also report an extra
47 // margin, to request that the corresponding field of the status bar should
48 // be wide enough to contain any of those strings plus the margin.
49 using StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >;
50 using StatusWidthFunction = std::function<
52 >;
53 using StatusWidthFunctions = std::vector< StatusWidthFunction >;
54
55 // Typically a static instance of this struct is used.
57 {
58 explicit
60 };
61
62 static const StatusWidthFunctions &GetStatusWidthFunctions();
63
65 void Set(const TranslatableString &msg,
67
68 // PrefsListener implementation
69 void UpdatePrefs() override;
70
71private:
73 TranslatableString mLastStatusMessages[ nStatusBarFields ];
74};
Utility ClientData::Site to register hooks into a host class that attach client data.
#define field(n, t)
Definition: ImportAUP.cpp:167
StatusBarField
Definition: ProjectStatus.h:24
@ mainStatusBarField
Definition: ProjectStatus.h:26
@ nStatusBarFields
Definition: ProjectStatus.h:29
@ rateStatusBarField
Definition: ProjectStatus.h:27
@ stateStatusBarField
Definition: ProjectStatus.h:25
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
Publisher & operator=(Publisher &&)=default
A listener notified of changes in preferences.
Definition: Prefs.h:543
~ProjectStatus() override
std::pair< std::vector< TranslatableString >, unsigned > StatusWidthResult
Definition: ProjectStatus.h:49
ProjectStatus(const ProjectStatus &)=delete
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
Holds a msgid for the translation catalog; may also bind format arguments.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
A convenient default parameter for class template Site.
Definition: ClientData.h:28