forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectStatus.h
78 lines (60 loc) · 2.41 KB
/
ProjectStatus.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**********************************************************************
Sneedacity: A Digital Audio Editor
ProjectStatus.h
Paul Licameli
**********************************************************************/
#ifndef __SNEEDACITY_PROJECT_STATUS__
#define __SNEEDACITY_PROJECT_STATUS__
#endif
#include <utility>
#include <vector>
#include <wx/event.h> // to declare custom event type
#include "ClientData.h" // to inherit
#include "Prefs.h"
class SneedacityProject;
class wxWindow;
enum StatusBarField : int {
stateStatusBarField = 1,
mainStatusBarField = 2,
rateStatusBarField = 3,
nStatusBarFields = 3
};
// Type of event emitted by the project when its status message is set
// GetInt() identifies the intended field of the status bar
wxDECLARE_EXPORTED_EVENT(SNEEDACITY_DLL_API,
EVT_PROJECT_STATUS_UPDATE, wxCommandEvent);
class SNEEDACITY_DLL_API ProjectStatus final
: public ClientData::Base
, public PrefsListener
{
public:
static ProjectStatus &Get( SneedacityProject &project );
static const ProjectStatus &Get( const SneedacityProject &project );
explicit ProjectStatus( SneedacityProject &project );
ProjectStatus( const ProjectStatus & ) = delete;
ProjectStatus &operator= ( const ProjectStatus & ) = delete;
~ProjectStatus() override;
// Type of a function to report translatable strings, and also report an extra
// margin, to request that the corresponding field of the status bar should
// be wide enough to contain any of those strings plus the margin.
using StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >;
using StatusWidthFunction = std::function<
StatusWidthResult( const SneedacityProject &, StatusBarField )
>;
using StatusWidthFunctions = std::vector< StatusWidthFunction >;
// Typically a static instance of this struct is used.
struct SNEEDACITY_DLL_API RegisteredStatusWidthFunction
{
explicit
RegisteredStatusWidthFunction( const StatusWidthFunction &function );
};
static const StatusWidthFunctions &GetStatusWidthFunctions();
const TranslatableString &Get( StatusBarField field = mainStatusBarField ) const;
void Set(const TranslatableString &msg,
StatusBarField field = mainStatusBarField);
// PrefsListener implementation
void UpdatePrefs() override;
private:
SneedacityProject &mProject;
TranslatableString mLastStatusMessages[ nStatusBarFields ];
};