Audacity 3.2.0
Static Public Member Functions | List of all members
ProjectStatusFieldsRegistry Struct Referencefinal

Registry of status bar fields. More...

#include <ProjectStatus.h>

Static Public Member Functions

static Registry::GroupItem< StatusBarFieldRegistryTraits > & Registry ()
 Returns the registry. More...
 
static void Visit (const StatusBarFieldRegistryVisitor &visitor)
 Visits all fields in the registry in order. More...
 
static std::size_t Count (const AudacityProject *project)
 Returns the number of fields in the registry. If project is no null, only visible fields are counted. More...
 
static StatusBarFieldItemGet (const StatusBarField &identifier)
 Returns the field with the given identifier or nullptr if field is not present. More...
 
static int GetFieldIndex (const AudacityProject &project, const StatusBarField &identifier)
 Returns the zero based index of the field or -1 if field is not present. More...
 
static void OnSize (AudacityProject &project)
 Handle OnSize event for all fields in the registry. More...
 
static Observer::Subscription Subscribe (std::function< void(const AudacityProject &, const StatusBarField &)> handler)
 

Detailed Description

Registry of status bar fields.

Definition at line 82 of file ProjectStatus.h.

Member Function Documentation

◆ Count()

std::size_t ProjectStatusFieldsRegistry::Count ( const AudacityProject project)
static

Returns the number of fields in the registry. If project is no null, only visible fields are counted.

Definition at line 214 of file ProjectStatus.cpp.

215{
216 if (project == nullptr)
217 return Registry().size();
218
219 auto& group = Registry();
220
221 std::size_t count = 0;
222 Visit(
223 [&](const StatusBarFieldItem& item, const auto&)
224 {
225 if (item.IsVisible(*project))
226 ++count;
227 });
228
229 return count;
230}
const auto project
Abstract base class for status bar fields.
Definition: ProjectStatus.h:38
virtual bool IsVisible(const AudacityProject &project) const =0
Returns true if the field is visible in the status bar of the given project.
static Registry::GroupItem< StatusBarFieldRegistryTraits > & Registry()
Returns the registry.
static void Visit(const StatusBarFieldRegistryVisitor &visitor)
Visits all fields in the registry in order.

References StatusBarFieldItem::IsVisible(), project, Registry(), and Visit().

Referenced by ProjectWindow::CreateProjectStatusBar(), and ProjectWindow::UpdateStatusWidths().

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

◆ Get()

StatusBarFieldItem * ProjectStatusFieldsRegistry::Get ( const StatusBarField identifier)
static

Returns the field with the given identifier or nullptr if field is not present.

Definition at line 232 of file ProjectStatus.cpp.

233{
234 StatusBarFieldItem* result = nullptr;
235
236 Visit(
237 [&](const StatusBarFieldItem& item, const auto&)
238 {
239 if (item.name == identifier)
240 result = const_cast<StatusBarFieldItem*>(&item);
241 });
242
243 return result;
244}
const Identifier name
Definition: Registry.h:86

References Registry::detail::BaseItem::name, and Visit().

Referenced by ProjectStatus::Get(), audacity::cloud::audiocom::sync::CloudSyncStatusField::MarkDirty(), and ProjectStatus::Set().

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

◆ GetFieldIndex()

int ProjectStatusFieldsRegistry::GetFieldIndex ( const AudacityProject project,
const StatusBarField identifier 
)
static

Returns the zero based index of the field or -1 if field is not present.

Definition at line 246 of file ProjectStatus.cpp.

248{
249 int result = -1;
250 int currentIndex = 1;
251 Visit(
252 [&](const StatusBarFieldItem& item, const auto&)
253 {
254 if (!item.IsVisible(project))
255 return;
256
257 if (item.name == identifier)
258 result = currentIndex;
259 ++currentIndex;
260 });
261
262 return result;
263}

References StatusBarFieldItem::IsVisible(), Registry::detail::BaseItem::name, project, and Visit().

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncStatusField.cpp}::CloudSyncStatusBarFieldItem::OnSize(), and ProjectManager::SetStatusText().

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

◆ OnSize()

void ProjectStatusFieldsRegistry::OnSize ( AudacityProject project)
static

Handle OnSize event for all fields in the registry.

Definition at line 265 of file ProjectStatus.cpp.

266{
267 Visit([&](const StatusBarFieldItem& item, const auto&)
268 { const_cast<StatusBarFieldItem&>(item).OnSize(project); });
269}
static void OnSize(AudacityProject &project)
Handle OnSize event for all fields in the registry.

References OnSize(), project, and Visit().

Referenced by ProjectWindow::CreateProjectStatusBar(), OnSize(), and ProjectWindow::UpdateStatusWidths().

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

◆ Registry()

Registry::GroupItem< StatusBarFieldRegistryTraits > & ProjectStatusFieldsRegistry::Registry ( )
static

Returns the registry.

Definition at line 194 of file ProjectStatus.cpp.

195{
198 };
199 return registry;
200}
Has variadic and range constructors that check types.
Definition: Registry.h:292

References anonymous_namespace{ProjectStatus.cpp}::PathStart.

Referenced by Count(), and Visit().

Here is the caller graph for this function:

◆ Subscribe()

Observer::Subscription ProjectStatusFieldsRegistry::Subscribe ( std::function< void(const AudacityProject &, const StatusBarField &)>  handler)
static

Definition at line 271 of file ProjectStatus.cpp.

273{
274 return Dispatcher::Get().Subscribe(std::move(handler));
275}
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202

References BasicUI::Get(), and audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler.

Here is the call graph for this function:

◆ Visit()

void ProjectStatusFieldsRegistry::Visit ( const StatusBarFieldRegistryVisitor visitor)
static

Visits all fields in the registry in order.

Definition at line 202 of file ProjectStatus.cpp.

204{
206 PathStart,
207 { { L"", L"state,main,rate" } },
208 };
209
211 Registry::VisitWithFunctions(visitor, &top, &Registry());
212}
void VisitWithFunctions(const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:623

References anonymous_namespace{ProjectStatus.cpp}::PathStart, Registry(), and Registry::VisitWithFunctions().

Referenced by Count(), ProjectWindow::CreateProjectStatusBar(), Get(), GetFieldIndex(), OnSize(), ProjectStatus::UpdatePrefs(), and ProjectWindow::UpdateStatusWidths().

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

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