Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
ProjectStatus::ProjectStatusTextField Class Referencefinal
Inheritance diagram for ProjectStatus::ProjectStatusTextField:
[legend]
Collaboration diagram for ProjectStatus::ProjectStatusTextField:
[legend]

Public Member Functions

 ProjectStatusTextField (StatusBarField identifier, int defaultWidth)
 
 ~ProjectStatusTextField () override=default
 
void SetText (AudacityProject &project, const TranslatableString &text) override
 Sets the current text of the field. More...
 
TranslatableString GetText (const AudacityProject &project) const
 Retrieves the current text of the field. More...
 
int GetDefaultWidth (const AudacityProject &) const override
 
bool IsVisible (const AudacityProject &) const override
 Returns true if the field is visible in the status bar of the given project. More...
 
- Public Member Functions inherited from StatusBarFieldItem
 StatusBarFieldItem (StatusBarField identifier)
 
virtual ~StatusBarFieldItem ()
 
virtual int GetDefaultWidth (const AudacityProject &project) const =0
 
virtual void OnSize (AudacityProject &project)
 
virtual void SetText (AudacityProject &project, const TranslatableString &msg)=0
 Sets the current text of the field. More...
 
virtual TranslatableString GetText (const AudacityProject &project) const =0
 Retrieves the current text of the field. More...
 
virtual bool IsVisible (const AudacityProject &project) const =0
 Returns true if the field is visible in the status bar of the given project. More...
 
- Public Member Functions inherited from Registry::SingleItem
 ~SingleItem () override=0
 
- Public Member Functions inherited from Registry::detail::BaseItem
 BaseItem (const Identifier &internalName)
 
virtual ~BaseItem ()
 

Private Attributes

const int mDefaultWidth
 

Additional Inherited Members

- Public Attributes inherited from Registry::detail::BaseItem
const Identifier name
 
OrderingHint orderingHint
 
- Protected Member Functions inherited from StatusBarFieldItem
void DispatchFieldChanged (const AudacityProject &project)
 Derived classes should call this method to notify the status bar that the field has changed. More...
 

Detailed Description

Definition at line 277 of file ProjectStatus.cpp.

Constructor & Destructor Documentation

◆ ProjectStatusTextField()

ProjectStatus::ProjectStatusTextField::ProjectStatusTextField ( StatusBarField  identifier,
int  defaultWidth 
)
inline

Definition at line 280 of file ProjectStatus.cpp.

281 : StatusBarFieldItem { identifier }
282 , mDefaultWidth { defaultWidth }
283 {
284 }
Abstract base class for status bar fields.
Definition: ProjectStatus.h:38

◆ ~ProjectStatusTextField()

ProjectStatus::ProjectStatusTextField::~ProjectStatusTextField ( )
overridedefault

Member Function Documentation

◆ GetDefaultWidth()

int ProjectStatus::ProjectStatusTextField::GetDefaultWidth ( const AudacityProject project) const
inlineoverridevirtual

Return the default width of the field in pixels. This is used to determine the initial width of the field in the status bar. The value may be overridden using StatusWidthFunctions. Returning -1 means that the field is expandable.In this case StatusWidthFunctions have no effect.

Implements StatusBarFieldItem.

Definition at line 317 of file ProjectStatus.cpp.

318 {
319 return mDefaultWidth;
320 }

References mDefaultWidth.

◆ GetText()

TranslatableString ProjectStatus::ProjectStatusTextField::GetText ( const AudacityProject project) const
inlinevirtual

Retrieves the current text of the field.

Implements StatusBarFieldItem.

Definition at line 308 of file ProjectStatus.cpp.

309 {
310 auto& projectStatus = ProjectStatus::Get(project);
311
312 auto it = projectStatus.mCurrentStatus.find(name);
313 return it != projectStatus.mCurrentStatus.end() ? it->second :
315 }
const auto project
static ProjectStatus & Get(AudacityProject &project)
Holds a msgid for the translation catalog; may also bind format arguments.
const Identifier name
Definition: Registry.h:86

References ProjectStatus::Get(), Registry::detail::BaseItem::name, and project.

Here is the call graph for this function:

◆ IsVisible()

bool ProjectStatus::ProjectStatusTextField::IsVisible ( const AudacityProject project) const
inlineoverridevirtual

Returns true if the field is visible in the status bar of the given project.

Implements StatusBarFieldItem.

Definition at line 322 of file ProjectStatus.cpp.

323 {
324 return true;
325 }

◆ SetText()

void ProjectStatus::ProjectStatusTextField::SetText ( AudacityProject project,
const TranslatableString msg 
)
inlineoverridevirtual

Sets the current text of the field.

Implements StatusBarFieldItem.

Definition at line 288 of file ProjectStatus.cpp.

289 {
290 auto& projectStatus = ProjectStatus::Get(project);
291
292 auto it = projectStatus.mCurrentStatus.find(name);
293
294 if (it == projectStatus.mCurrentStatus.end())
295 {
296 projectStatus.mCurrentStatus.emplace(name, text);
298 return;
299 }
300
301 if (it->second.Translation() != text.Translation())
302 {
303 it->second = text;
305 }
306 }
void DispatchFieldChanged(const AudacityProject &project)
Derived classes should call this method to notify the status bar that the field has changed.

References StatusBarFieldItem::DispatchFieldChanged(), ProjectStatus::Get(), Registry::detail::BaseItem::name, project, and TranslatableString::Translation().

Here is the call graph for this function:

Member Data Documentation

◆ mDefaultWidth

const int ProjectStatus::ProjectStatusTextField::mDefaultWidth
private

Definition at line 328 of file ProjectStatus.cpp.

Referenced by GetDefaultWidth().


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