Audacity 3.2.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SetLabelCommand Class Reference

Command that sets label information. More...

#include <SetLabelCommand.h>

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

Public Member Functions

 SetLabelCommand ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
template<bool Const>
bool VisitSettings (SettingsVisitorBase< Const > &S)
 
bool VisitSettings (SettingsVisitor &S) override
 
bool VisitSettings (ConstSettingsVisitor &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
ManualPageID ManualPage () override
 
bool Apply (const CommandContext &context) override
 
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
PluginPath GetPath () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
ComponentInterfaceSymbol GetSymbol () const override=0
 
virtual TranslatableString GetDescription () const override
 
virtual ManualPageID ManualPage ()
 
virtual bool IsBatchProcessing () const
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
bool SaveSettingsAsString (wxString &parms)
 
bool LoadSettingsFromString (const wxString &parms)
 
bool DoAudacityCommand (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
virtual bool CheckWhetherSkipAudacityCommand ()
 
virtual void End ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool VisitSettings (SettingsVisitor &)
 
virtual bool VisitSettings (ConstSettingsVisitor &)
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Public Attributes

int mLabelIndex
 
wxString mText
 
double mT0
 
double mT1
 
bool mbSelected
 
bool bHasText
 
bool bHasT0
 
bool bHasT1
 
bool bHasSelected
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Set Label") }
 

Additional Inherited Members

- Public Types inherited from AudacityCommand
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 

Detailed Description

Command that sets label information.

Definition at line 22 of file SetLabelCommand.h.

Constructor & Destructor Documentation

◆ SetLabelCommand()

SetLabelCommand::SetLabelCommand ( )

Definition at line 40 of file SetLabelCommand.cpp.

41{
42}

Member Function Documentation

◆ Apply()

bool SetLabelCommand::Apply ( const CommandContext context)
override

Definition at line 79 of file SetLabelCommand.cpp.

80{
81 // \todo we have similar code for finding the nth Label, Clip, Track etc.
82 // this code could be put in subroutines/reduced.
83
84 //wxString mode = GetString(wxT("Type"));
85 AudacityProject * p = &context.project;
86 auto &tracks = TrackList::Get( *p );
87 auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
88 const LabelStruct * pLabel = nullptr;
89 LabelTrack *labelTrack = nullptr;
90 auto ii = mLabelIndex;
91 if ( mLabelIndex >= 0 ) {
92 for (auto lt : tracks.Any<LabelTrack>()) {
93 const auto &labels = lt->GetLabels();
94 const auto nLabels = labels.size();
95 if( ii >= (int)nLabels )
96 ii -= nLabels;
97 else {
98 labelTrack = lt;
99 pLabel = &labels[ ii ];
100 break;
101 }
102 }
103 }
104
105 if ( !pLabel )
106 {
107 context.Error(wxT("LabelIndex was invalid."));
108 return false;
109 }
110 auto newLabel = *pLabel;
111 if( bHasText )
112 newLabel.title = mText;
113 if( bHasT0 )
114 newLabel.selectedRegion.setT0(mT0, false);
115 if( bHasT1 )
116 newLabel.selectedRegion.setT1(mT1, false);
117 if( bHasT0 || bHasT1 )
118 newLabel.selectedRegion.ensureOrdering();
119 labelTrack->SetLabel( ii, newLabel );
120
121 // Only one label can be selected.
122 if( bHasSelected ) {
123 auto &view = LabelTrackView::Get( *labelTrack );
124 if( mbSelected )
125 {
126 view.SetNavigationIndex( ii );
127 double t0 = pLabel->selectedRegion.t0();
128 double t1 = pLabel->selectedRegion.t1();
129 selectedRegion.setTimes( t0, t1);
130 }
131 else if( view.GetNavigationIndex( context.project ) == ii )
132 view.SetNavigationIndex( -1 );
133 }
134
135 labelTrack->SortLabels();
136
138 XO("Edited Label"), XO("Label"));
139
140 return true;
141}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
const auto tracks
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual void Error(const wxString &message) const
AudacityProject & project
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:37
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:95
static LabelTrackView & Get(LabelTrack &)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References bHasSelected, bHasT0, bHasT1, bHasText, CommandContext::Error(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), LabelTrackView::Get(), mbSelected, mLabelIndex, mT0, mT1, mText, CommandContext::project, ProjectHistory::PushState(), ViewInfo::selectedRegion, tracks, wxT(), and XO().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString SetLabelCommand::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 30 of file SetLabelCommand.h.

30{return XO("Sets various values for a label.");};

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol SetLabelCommand::GetSymbol ( ) const
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 29 of file SetLabelCommand.h.

29{return Symbol;};
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ ManualPage()

ManualPageID SetLabelCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 37 of file SetLabelCommand.h.

37{return L"Extra_Menu:_Scriptables_I#set_label";}

◆ PopulateOrExchange()

void SetLabelCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 60 of file SetLabelCommand.cpp.

61{
62 S.AddSpace(0, 5);
63
64 S.StartMultiColumn(2, wxALIGN_CENTER);
65 {
66 S.TieNumericTextBox( XXO("Label Index"), mLabelIndex );
67 }
68 S.EndMultiColumn();
69 S.StartMultiColumn(3, wxALIGN_CENTER);
70 {
71 S.Optional( bHasText ).TieTextBox( XXO("Text:"), mText );
72 S.Optional( bHasT0 ).TieNumericTextBox( XXO("Start:"), mT0 );
73 S.Optional( bHasT1 ).TieNumericTextBox( XXO("End:"), mT1 );
74 S.Optional( bHasSelected ).TieCheckBox( XXO("Selected"), mbSelected );
75 }
76 S.EndMultiColumn();
77}
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64

References bHasSelected, bHasT0, bHasT1, bHasText, mbSelected, mLabelIndex, mT0, mT1, mText, S, and XXO().

Here is the call graph for this function:

◆ VisitSettings() [1/3]

bool SetLabelCommand::VisitSettings ( ConstSettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 57 of file SetLabelCommand.cpp.

58 { return VisitSettings<true>(S); }

References S.

◆ VisitSettings() [2/3]

bool SetLabelCommand::VisitSettings ( SettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 54 of file SetLabelCommand.cpp.

55 { return VisitSettings<false>(S); }

References S.

◆ VisitSettings() [3/3]

template<bool Const>
bool SetLabelCommand::VisitSettings ( SettingsVisitorBase< Const > &  S)

Definition at line 45 of file SetLabelCommand.cpp.

45 {
46 S.Define( mLabelIndex, wxT("Label"), 0, 0, 10000 );
47 S.OptionalY( bHasText ).Define( mText, wxT("Text"), wxString{"empty"} );
48 S.OptionalY( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, 100000.0);
49 S.OptionalY( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, 100000.0);
50 S.OptionalN( bHasSelected ).Define( mbSelected, wxT("Selected"), false );
51 return true;
52};

References bHasSelected, bHasT0, bHasT1, bHasText, mbSelected, mLabelIndex, mT0, mT1, mText, S, and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ bHasSelected

bool SetLabelCommand::bHasSelected

Definition at line 54 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ bHasT0

bool SetLabelCommand::bHasT0

Definition at line 52 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ bHasT1

bool SetLabelCommand::bHasT1

Definition at line 53 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ bHasText

bool SetLabelCommand::bHasText

Definition at line 51 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mbSelected

bool SetLabelCommand::mbSelected

Definition at line 48 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mLabelIndex

int SetLabelCommand::mLabelIndex

Definition at line 44 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mT0

double SetLabelCommand::mT0

Definition at line 46 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mT1

double SetLabelCommand::mT1

Definition at line 47 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mText

wxString SetLabelCommand::mText

Definition at line 45 of file SetLabelCommand.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ Symbol

const ComponentInterfaceSymbol SetLabelCommand::Symbol { XO("Set Label") }
static

Definition at line 25 of file SetLabelCommand.h.

Referenced by GetSymbol().


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