2019-07-02 15:38:15 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ProjectStatus.h
|
|
|
|
|
|
|
|
Paul Licameli
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_PROJECT_STATUS__
|
|
|
|
#define __AUDACITY_PROJECT_STATUS__
|
|
|
|
#endif
|
|
|
|
|
2019-07-02 22:20:14 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2019-07-02 15:38:15 +00:00
|
|
|
#include <wx/event.h> // to declare custom event type
|
|
|
|
#include "ClientData.h" // to inherit
|
2021-02-09 21:11:23 +00:00
|
|
|
#include "Prefs.h"
|
2019-07-02 15:38:15 +00:00
|
|
|
|
|
|
|
class AudacityProject;
|
|
|
|
class wxWindow;
|
|
|
|
|
|
|
|
enum StatusBarField : int {
|
|
|
|
stateStatusBarField = 1,
|
|
|
|
mainStatusBarField = 2,
|
2019-07-02 16:44:55 +00:00
|
|
|
rateStatusBarField = 3,
|
|
|
|
|
|
|
|
nStatusBarFields = 3
|
2019-07-02 15:38:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Type of event emitted by the project when its status message is set
|
2019-07-02 16:44:55 +00:00
|
|
|
// GetInt() identifies the intended field of the status bar
|
2019-07-02 15:38:15 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
|
|
|
EVT_PROJECT_STATUS_UPDATE, wxCommandEvent);
|
|
|
|
|
2020-09-28 12:50:18 +00:00
|
|
|
class AUDACITY_DLL_API ProjectStatus final
|
2019-07-02 15:38:15 +00:00
|
|
|
: public ClientData::Base
|
2021-02-09 19:47:48 +00:00
|
|
|
, public PrefsListener
|
2019-07-02 15:38:15 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ProjectStatus &Get( AudacityProject &project );
|
|
|
|
static const ProjectStatus &Get( const AudacityProject &project );
|
|
|
|
|
|
|
|
explicit ProjectStatus( AudacityProject &project );
|
|
|
|
ProjectStatus( const ProjectStatus & ) = delete;
|
|
|
|
ProjectStatus &operator= ( const ProjectStatus & ) = delete;
|
|
|
|
~ProjectStatus() override;
|
|
|
|
|
2019-12-08 21:24:20 +00:00
|
|
|
// Type of a function to report translatable strings, and also report an extra
|
2019-07-02 22:20:14 +00:00
|
|
|
// margin, to request that the corresponding field of the status bar should
|
|
|
|
// be wide enough to contain any of those strings plus the margin.
|
2019-12-08 21:24:20 +00:00
|
|
|
using StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >;
|
2019-07-02 22:20:14 +00:00
|
|
|
using StatusWidthFunction = std::function<
|
|
|
|
StatusWidthResult( const AudacityProject &, StatusBarField )
|
|
|
|
>;
|
|
|
|
using StatusWidthFunctions = std::vector< StatusWidthFunction >;
|
|
|
|
|
|
|
|
// Typically a static instance of this struct is used.
|
2020-09-28 12:50:18 +00:00
|
|
|
struct AUDACITY_DLL_API RegisteredStatusWidthFunction
|
2019-07-02 22:20:14 +00:00
|
|
|
{
|
|
|
|
explicit
|
|
|
|
RegisteredStatusWidthFunction( const StatusWidthFunction &function );
|
|
|
|
};
|
|
|
|
|
|
|
|
static const StatusWidthFunctions &GetStatusWidthFunctions();
|
|
|
|
|
2019-12-08 21:24:20 +00:00
|
|
|
const TranslatableString &Get( StatusBarField field = mainStatusBarField ) const;
|
|
|
|
void Set(const TranslatableString &msg,
|
2019-07-02 16:44:55 +00:00
|
|
|
StatusBarField field = mainStatusBarField);
|
2019-07-02 15:38:15 +00:00
|
|
|
|
2021-02-09 19:47:48 +00:00
|
|
|
// PrefsListener implementation
|
|
|
|
void UpdatePrefs() override;
|
|
|
|
|
2019-07-02 15:38:15 +00:00
|
|
|
private:
|
|
|
|
AudacityProject &mProject;
|
2019-12-08 21:24:20 +00:00
|
|
|
TranslatableString mLastStatusMessages[ nStatusBarFields ];
|
2019-07-02 15:38:15 +00:00
|
|
|
};
|