Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ProjectStatus Class Referencefinal

#include <ProjectStatus.h>

Inheritance diagram for ProjectStatus:
[legend]
Collaboration diagram for ProjectStatus:
[legend]

Classes

struct  RegisteredStatusWidthFunction
 

Public Types

using StatusWidthResult = std::pair< std::vector< TranslatableString >, unsigned >
 
using StatusWidthFunction = std::function< StatusWidthResult(const AudacityProject &, StatusBarField) >
 
using StatusWidthFunctions = std::vector< StatusWidthFunction >
 
- Public Types inherited from Observer::Publisher< StatusBarField >
using message_type = StatusBarField
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const StatusBarField &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 ProjectStatus (AudacityProject &project)
 
 ProjectStatus (const ProjectStatus &)=delete
 
ProjectStatusoperator= (const ProjectStatus &)=delete
 
 ~ProjectStatus () override
 
const TranslatableStringGet (StatusBarField field=mainStatusBarField) const
 
void Set (const TranslatableString &msg, StatusBarField field=mainStatusBarField)
 
void UpdatePrefs () override
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Public Member Functions inherited from Observer::Publisher< StatusBarField >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static ProjectStatusGet (AudacityProject &project)
 
static const ProjectStatusGet (const AudacityProject &project)
 
static const StatusWidthFunctionsGetStatusWidthFunctions ()
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Private Attributes

AudacityProjectmProject
 
TranslatableString mLastStatusMessages [nStatusBarFields]
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< StatusBarField >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
- Protected Member Functions inherited from Observer::Publisher< StatusBarField >
CallbackReturn Publish (const StatusBarField &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Definition at line 32 of file ProjectStatus.h.

Member Typedef Documentation

◆ StatusWidthFunction

Definition at line 50 of file ProjectStatus.h.

◆ StatusWidthFunctions

Definition at line 53 of file ProjectStatus.h.

◆ StatusWidthResult

using ProjectStatus::StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >

Definition at line 49 of file ProjectStatus.h.

Constructor & Destructor Documentation

◆ ProjectStatus() [1/2]

ProjectStatus::ProjectStatus ( AudacityProject project)
explicit

Definition at line 31 of file ProjectStatus.cpp.

32 : mProject{ project }
33{
34}
AudacityProject & mProject
Definition: ProjectStatus.h:72

◆ ProjectStatus() [2/2]

ProjectStatus::ProjectStatus ( const ProjectStatus )
delete

◆ ~ProjectStatus()

ProjectStatus::~ProjectStatus ( )
overridedefault

Member Function Documentation

◆ Get() [1/3]

ProjectStatus & ProjectStatus::Get ( AudacityProject project)
static

Definition at line 21 of file ProjectStatus.cpp.

22{
23 return project.AttachedObjects::Get< ProjectStatus >( key );
24}
static const AudacityProject::AttachedObjects::RegisteredFactory key

References key.

Referenced by ProjectFileManager::DoSave(), Get(), ProjectAudioManager::OnAudioIORate(), AButton::OnMouseEvent(), LWSlider::OnMouseEvent(), ProjectManager::OnStatusChange(), TrackActions::Handler::OnTrackClose(), ProjectManager::ProjectManager(), LWSlider::SendUpdate(), AButton::UpdateStatus(), ControlToolBar::UpdateStatusBar(), AdornedRulerPanel::UpdateStatusMessage(), TrackPanel::UpdateStatusMessage(), and TrackPanel::UpdateViewIfNoTracks().

Here is the caller graph for this function:

◆ Get() [2/3]

const ProjectStatus & ProjectStatus::Get ( const AudacityProject project)
static

Definition at line 26 of file ProjectStatus.cpp.

27{
28 return Get( const_cast< AudacityProject & >( project ) );
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
static ProjectStatus & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ Get() [3/3]

const TranslatableString & ProjectStatus::Get ( StatusBarField  field = mainStatusBarField) const

Definition at line 58 of file ProjectStatus.cpp.

59{
60 return mLastStatusMessages[ field - 1 ];
61}
#define field(n, t)
Definition: ImportAUP.cpp:167
TranslatableString mLastStatusMessages[nStatusBarFields]
Definition: ProjectStatus.h:73

References field, and mLastStatusMessages.

◆ GetStatusWidthFunctions()

auto ProjectStatus::GetStatusWidthFunctions ( )
static

Definition at line 53 of file ProjectStatus.cpp.

54{
55 return statusWidthFunctions();
56}
ProjectStatus::StatusWidthFunctions & statusWidthFunctions()

References anonymous_namespace{ProjectStatus.cpp}::statusWidthFunctions().

Referenced by ProjectWindow::UpdateStatusWidths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

ProjectStatus & ProjectStatus::operator= ( const ProjectStatus )
delete

◆ Set()

void ProjectStatus::Set ( const TranslatableString msg,
StatusBarField  field = mainStatusBarField 
)

Definition at line 63 of file ProjectStatus.cpp.

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}
CallbackReturn Publish(const StatusBarField &message)
Send a message to connected callbacks.
Definition: Observer.h:207
wxString Translation() const

References field, mLastStatusMessages, mProject, Observer::Publisher< StatusBarField >::Publish(), and TranslatableString::Translation().

Referenced by ProjectFileManager::DoSave(), ProjectAudioManager::OnAudioIORate(), AButton::OnMouseEvent(), LWSlider::OnMouseEvent(), TrackActions::Handler::OnTrackClose(), LWSlider::SendUpdate(), AButton::UpdateStatus(), ControlToolBar::UpdateStatusBar(), AdornedRulerPanel::UpdateStatusMessage(), TrackPanel::UpdateStatusMessage(), and TrackPanel::UpdateViewIfNoTracks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void ProjectStatus::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 74 of file ProjectStatus.cpp.

75{
76 auto &project = mProject;
77 for (auto field = 1; field <= nStatusBarFields; ++field)
78 Publish(static_cast<StatusBarField>(field));
79}
StatusBarField
Definition: ProjectStatus.h:24
@ nStatusBarFields
Definition: ProjectStatus.h:29

References field, mProject, nStatusBarFields, and Observer::Publisher< StatusBarField >::Publish().

Here is the call graph for this function:

Member Data Documentation

◆ mLastStatusMessages

TranslatableString ProjectStatus::mLastStatusMessages[nStatusBarFields]
private

Definition at line 73 of file ProjectStatus.h.

Referenced by Get(), and Set().

◆ mProject

AudacityProject& ProjectStatus::mProject
private

Definition at line 72 of file ProjectStatus.h.

Referenced by Set(), and UpdatePrefs().


The documentation for this class was generated from the following files: