Audacity  3.0.3
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 () override
 
TranslatableString GetDescription () override
 
bool DefineParams (ShuttleParams &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 () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
virtual void SetHostUI (EffectUIHostInterface *WXUNUSED(host))
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (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 ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

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 }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Static Public Member Functions inherited from AudacityCommand
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 

Detailed Description

Command that sets label information.

Definition at line 22 of file SetLabelCommand.h.

Constructor & Destructor Documentation

◆ SetLabelCommand()

SetLabelCommand::SetLabelCommand ( )

Definition at line 37 of file SetLabelCommand.cpp.

38 {
39 }

Member Function Documentation

◆ Apply()

bool SetLabelCommand::Apply ( const CommandContext context)
override

Definition at line 70 of file SetLabelCommand.cpp.

71 {
72  // \todo we have similar code for finding the nth Label, Clip, Track etc.
73  // this code could be put in subroutines/reduced.
74 
75  //wxString mode = GetString(wxT("Type"));
76  AudacityProject * p = &context.project;
77  auto &tracks = TrackList::Get( *p );
78  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
79  const LabelStruct * pLabel = nullptr;
80  LabelTrack *labelTrack = nullptr;
81  auto ii = mLabelIndex;
82  if ( mLabelIndex >= 0 ) {
83  for (auto lt : tracks.Any<LabelTrack>()) {
84  const auto &labels = lt->GetLabels();
85  const auto nLabels = labels.size();
86  if( ii >= (int)nLabels )
87  ii -= nLabels;
88  else {
89  labelTrack = lt;
90  pLabel = &labels[ ii ];
91  break;
92  }
93  }
94  }
95 
96  if ( !pLabel )
97  {
98  context.Error(wxT("LabelIndex was invalid."));
99  return false;
100  }
101  auto newLabel = *pLabel;
102  if( bHasText )
103  newLabel.title = mText;
104  if( bHasT0 )
105  newLabel.selectedRegion.setT0(mT0, false);
106  if( bHasT1 )
107  newLabel.selectedRegion.setT1(mT1, false);
108  if( bHasT0 || bHasT1 )
109  newLabel.selectedRegion.ensureOrdering();
110  labelTrack->SetLabel( ii, newLabel );
111 
112  // Only one label can be selected.
113  if( bHasSelected ) {
114  auto &view = LabelTrackView::Get( *labelTrack );
115  if( mbSelected )
116  {
117  view.SetNavigationIndex( ii );
118  double t0 = pLabel->selectedRegion.t0();
119  double t1 = pLabel->selectedRegion.t1();
120  selectedRegion.setTimes( t0, t1);
121  }
122  else if( view.GetNavigationIndex( context.project ) == ii )
123  view.SetNavigationIndex( -1 );
124  }
125 
126  labelTrack->SortLabels();
127 
129  XO("Edited Label"), XO("Label"));
130 
131  return true;
132 }

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

Here is the call graph for this function:

◆ DefineParams()

bool SetLabelCommand::DefineParams ( ShuttleParams S)
override

Definition at line 42 of file SetLabelCommand.cpp.

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

References bHasSelected, bHasT0, bHasT1, bHasText, ShuttleParams::Define(), mbSelected, mLabelIndex, mT0, mT1, mText, ShuttleParams::OptionalN(), and ShuttleParams::OptionalY().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString SetLabelCommand::GetDescription ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 30 of file SetLabelCommand.h.

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

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SetLabelCommand::GetSymbol ( )
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 29 of file SetLabelCommand.h.

29 {return Symbol;};

References Symbol.

◆ ManualPage()

ManualPageID SetLabelCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 35 of file SetLabelCommand.h.

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

◆ PopulateOrExchange()

void SetLabelCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 51 of file SetLabelCommand.cpp.

52 {
53  S.AddSpace(0, 5);
54 
55  S.StartMultiColumn(2, wxALIGN_CENTER);
56  {
57  S.TieNumericTextBox( XXO("Label Index"), mLabelIndex );
58  }
59  S.EndMultiColumn();
60  S.StartMultiColumn(3, wxALIGN_CENTER);
61  {
62  S.Optional( bHasText ).TieTextBox( XXO("Text:"), mText );
63  S.Optional( bHasT0 ).TieNumericTextBox( XXO("Start:"), mT0 );
64  S.Optional( bHasT1 ).TieNumericTextBox( XXO("End:"), mT1 );
65  S.Optional( bHasSelected ).TieCheckBox( XXO("Selected"), mbSelected );
66  }
67  S.EndMultiColumn();
68 }

References ShuttleGui::AddSpace(), bHasSelected, bHasT0, bHasT1, bHasText, ShuttleGuiBase::EndMultiColumn(), mbSelected, mLabelIndex, mT0, mT1, mText, ShuttleGui::Optional(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieNumericTextBox(), ShuttleGuiBase::TieTextBox(), and XXO.

Here is the call graph for this function:

Member Data Documentation

◆ bHasSelected

bool SetLabelCommand::bHasSelected

Definition at line 52 of file SetLabelCommand.h.

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

◆ bHasT0

bool SetLabelCommand::bHasT0

Definition at line 50 of file SetLabelCommand.h.

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

◆ bHasT1

bool SetLabelCommand::bHasT1

Definition at line 51 of file SetLabelCommand.h.

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

◆ bHasText

bool SetLabelCommand::bHasText

Definition at line 49 of file SetLabelCommand.h.

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

◆ mbSelected

bool SetLabelCommand::mbSelected

Definition at line 46 of file SetLabelCommand.h.

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

◆ mLabelIndex

int SetLabelCommand::mLabelIndex

Definition at line 42 of file SetLabelCommand.h.

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

◆ mT0

double SetLabelCommand::mT0

Definition at line 44 of file SetLabelCommand.h.

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

◆ mT1

double SetLabelCommand::mT1

Definition at line 45 of file SetLabelCommand.h.

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

◆ mText

wxString SetLabelCommand::mText

Definition at line 43 of file SetLabelCommand.h.

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

◆ 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:
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
SetLabelCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: SetLabelCommand.h:25
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
XO
#define XO(s)
Definition: Internat.h:31
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
LabelStruct
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:30
SetLabelCommand::bHasSelected
bool bHasSelected
Definition: SetLabelCommand.h:52
ShuttleParams::OptionalN
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:196
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
SetLabelCommand::mLabelIndex
int mLabelIndex
Definition: SetLabelCommand.h:42
SetLabelCommand::bHasText
bool bHasText
Definition: SetLabelCommand.h:49
LabelTrackView::Get
static LabelTrackView & Get(LabelTrack &)
Definition: LabelTrackView.cpp:160
ShuttleParams::OptionalY
virtual ShuttleParams & OptionalY(bool &var)
Definition: Shuttle.h:71
CommandContext::Error
virtual void Error(const wxString &message) const
Definition: CommandContext.cpp:73
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1673
SetLabelCommand::bHasT1
bool bHasT1
Definition: SetLabelCommand.h:51
SetLabelCommand::bHasT0
bool bHasT0
Definition: SetLabelCommand.h:50
SetLabelCommand::mT0
double mT0
Definition: SetLabelCommand.h:44
SetLabelCommand::mT1
double mT1
Definition: SetLabelCommand.h:45
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
SetLabelCommand::mText
wxString mText
Definition: SetLabelCommand.h:43
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
ShuttleGui::Optional
ShuttleGui & Optional(bool &bVar)
Definition: ShuttleGui.cpp:2280
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
SetLabelCommand::mbSelected
bool mbSelected
Definition: SetLabelCommand.h:46