22 return std::make_shared< ProjectStatus >( parent );
74 return fieldObject !=
nullptr && fieldObject->IsVisible(
mProject) ?
82 if (fieldObject !=
nullptr)
131 {
handler(message.project, message.identifier); });
143 mCallEnqueued =
true;
144 mNewFields.push_back(identifier);
156 for (
const auto&
field : mNewFields)
161 mCallEnqueued =
false;
169 bool mCallEnqueued{
false };
175 : SingleItem { identifier }
207 { { L
"", L
"state,main,rate" } },
221 std::size_t count = 0;
239 if (item.
name == identifier)
250 int currentIndex = 1;
257 if (item.
name == identifier)
258 result = currentIndex;
292 auto it = projectStatus.mCurrentStatus.find(
name);
294 if (it == projectStatus.mCurrentStatus.end())
296 projectStatus.mCurrentStatus.emplace(
name, text);
301 if (it->second.Translation() != text.
Translation())
312 auto it = projectStatus.mCurrentStatus.find(
name);
313 return it != projectStatus.mCurrentStatus.end() ? it->second :
Toolkit-neutral facade for basic user interface services.
StatusBarField MainStatusBarField()
ID of the second field in the status bar. This field is expandable.
StatusBarField StateStatusBarField()
ID of the first field in the status bar. This filed is used to display playback state.
static const AudacityProject::AttachedObjects::RegisteredFactory key
StatusBarField RateStatusBarField()
ID of the third field in the status bar. This field is used to display the current rate.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
An explicitly nonlocalized string, not meant for the user to see.
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
An object that sends messages to an open-ended list of subscribed callbacks.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
CallbackReturn Publish(const StatusBarField &message)
Send a message to connected callbacks.
A move-only handle representing a connection to a Publisher.
int GetDefaultWidth(const AudacityProject &) const override
~ProjectStatusTextField() override=default
void SetText(AudacityProject &project, const TranslatableString &text) override
Sets the current text of the field.
ProjectStatusTextField(StatusBarField identifier, int defaultWidth)
bool IsVisible(const AudacityProject &) const override
Returns true if the field is visible in the status bar of the given project.
TranslatableString GetText(const AudacityProject &project) const
Retrieves the current text of the field.
~ProjectStatus() override
ProjectStatus(AudacityProject &project)
static const StatusWidthFunctions & GetStatusWidthFunctions()
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=MainStatusBarField())
std::function< StatusWidthResult(const AudacityProject &, StatusBarField) > StatusWidthFunction
std::vector< StatusWidthFunction > StatusWidthFunctions
static struct ProjectStatus::DefaultFieldsRegistrator sDefaultFieldsRegistrator
AudacityProject & mProject
void UpdatePrefs() override
Generates classes whose instances register items at construction.
Abstract base class for status bar fields.
void DispatchFieldChanged(const AudacityProject &project)
Derived classes should call this method to notify the status bar that the field has changed.
virtual void OnSize(AudacityProject &project)
virtual ~StatusBarFieldItem()
StatusBarFieldItem(StatusBarField identifier)
virtual bool IsVisible(const AudacityProject &project) const =0
Returns true if the field is visible in the status bar of the given project.
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
void OnAppInitialized(std::function< void()> callback)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
void VisitWithFunctions(const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
auto Dispatch(Head_t< Types > &object, const TupleLike &functions, Args &&... args) -> std::enable_if_t< TypeListCheck_v< Types >, R >
ProjectStatus::StatusWidthFunctions & statusWidthFunctions()
AuthorizationHandler handler
StatusBarFieldItemRegistrator rateStatusBarField
DefaultFieldsRegistrator()
RegisteredStatusWidthFunction(const StatusWidthFunction &function)
Registry of status bar fields.
static StatusBarFieldItem * Get(const StatusBarField &identifier)
Returns the field with the given identifier or nullptr if field is not present.
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.
static Registry::GroupItem< StatusBarFieldRegistryTraits > & Registry()
Returns the registry.
static void Visit(const StatusBarFieldRegistryVisitor &visitor)
Visits all fields in the registry in order.
static Observer::Subscription Subscribe(std::function< void(const AudacityProject &, const StatusBarField &)> handler)
static int GetFieldIndex(const AudacityProject &project, const StatusBarField &identifier)
Returns the zero based index of the field or -1 if field is not present.
static void OnSize(AudacityProject &project)
Handle OnSize event for all fields in the registry.
Has variadic and range constructors that check types.
void NewFieldRegistered(const StatusBarField &identifier)
Observer::Subscription Subscribe(std::function< void(const AudacityProject &, const StatusBarField &)> handler)
void Dispatch(const AudacityProject &project, const StatusBarField &identifier)
std::vector< StatusBarField > mNewFields
static Dispatcher & Get()
const AudacityProject & project
const StatusBarField & identifier