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

#include <ProjectStatus.h>

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

Classes

struct  DefaultFieldsRegistrator
 
class  ProjectStatusTextField
 
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
 
TranslatableString Get (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
 
std::unordered_map< StatusBarField, TranslatableStringmCurrentStatus
 
Observer::Subscription mFieldChangedSubscription
 

Static Private Attributes

static struct ProjectStatus::DefaultFieldsRegistrator sDefaultFieldsRegistrator
 

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 106 of file ProjectStatus.h.

Member Typedef Documentation

◆ StatusWidthFunction

Definition at line 124 of file ProjectStatus.h.

◆ StatusWidthFunctions

Definition at line 127 of file ProjectStatus.h.

◆ StatusWidthResult

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

Definition at line 123 of file ProjectStatus.h.

Constructor & Destructor Documentation

◆ ProjectStatus() [1/2]

ProjectStatus::ProjectStatus ( AudacityProject project)
explicit

Definition at line 38 of file ProjectStatus.cpp.

39 : mProject { project }
41 [this](const auto& project, const auto& field)
42 {
43 if (&mProject == &project)
45 }) }
46{
47}
#define field(n, t)
Definition: ImportAUP.cpp:165
const auto project
CallbackReturn Publish(const StatusBarField &message)
Send a message to connected callbacks.
Definition: Observer.h:207
Observer::Subscription mFieldChangedSubscription
AudacityProject & mProject
static Observer::Subscription Subscribe(std::function< void(const AudacityProject &, const StatusBarField &)> handler)

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

Here is the call graph for this function:

◆ ProjectStatus() [2/2]

ProjectStatus::ProjectStatus ( const ProjectStatus )
delete

◆ ~ProjectStatus()

ProjectStatus::~ProjectStatus ( )
overridedefault

Member Function Documentation

◆ Get() [1/3]

ProjectStatus & ProjectStatus::Get ( AudacityProject project)
static

◆ Get() [2/3]

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

Definition at line 31 of file ProjectStatus.cpp.

32{
33 return Get( const_cast< AudacityProject & >( project ) );
34}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ProjectStatus & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ Get() [3/3]

TranslatableString ProjectStatus::Get ( StatusBarField  field = MainStatusBarField()) const

Definition at line 71 of file ProjectStatus.cpp.

72{
73 auto fieldObject = ProjectStatusFieldsRegistry::Get(field);
74 return fieldObject != nullptr && fieldObject->IsVisible(mProject) ?
75 fieldObject->GetText(mProject) :
77}
Holds a msgid for the translation catalog; may also bind format arguments.
static StatusBarFieldItem * Get(const StatusBarField &identifier)
Returns the field with the given identifier or nullptr if field is not present.

References field, ProjectStatusFieldsRegistry::Get(), and mProject.

Here is the call graph for this function:

◆ GetStatusWidthFunctions()

auto ProjectStatus::GetStatusWidthFunctions ( )
static

Definition at line 66 of file ProjectStatus.cpp.

67{
68 return statusWidthFunctions();
69}
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 79 of file ProjectStatus.cpp.

80{
81 auto fieldObject = ProjectStatusFieldsRegistry::Get(field);
82 if (fieldObject != nullptr)
83 fieldObject->SetText(mProject, msg);
84}

References field, ProjectStatusFieldsRegistry::Get(), and mProject.

Referenced by ProjectFileManager::DoSave(), ProjectAudioManager::OnAudioIORate(), AButton::OnMouseEvent(), LWSlider::OnMouseEvent(), anonymous_namespace{TrackMenus.cpp}::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 86 of file ProjectStatus.cpp.

87{
88 ProjectStatusFieldsRegistry::Visit([this](const StatusBarFieldItem& item, const auto&)
89 { Publish(item.name); });
90}
Abstract base class for status bar fields.
Definition: ProjectStatus.h:38
static void Visit(const StatusBarFieldRegistryVisitor &visitor)
Visits all fields in the registry in order.
const Identifier name
Definition: Registry.h:86

References Registry::detail::BaseItem::name, Observer::Publisher< StatusBarField >::Publish(), and ProjectStatusFieldsRegistry::Visit().

Here is the call graph for this function:

Member Data Documentation

◆ mCurrentStatus

std::unordered_map<StatusBarField, TranslatableString> ProjectStatus::mCurrentStatus
private

Definition at line 153 of file ProjectStatus.h.

◆ mFieldChangedSubscription

Observer::Subscription ProjectStatus::mFieldChangedSubscription
private

Definition at line 154 of file ProjectStatus.h.

◆ mProject

AudacityProject& ProjectStatus::mProject
private

Definition at line 152 of file ProjectStatus.h.

Referenced by Get(), ProjectStatus(), and Set().

◆ sDefaultFieldsRegistrator

ProjectStatus::DefaultFieldsRegistrator ProjectStatus::sDefaultFieldsRegistrator
staticprivate

Definition at line 36 of file ProjectStatus.cpp.


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