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

Command that sets label information. More...

#include <SetLabelCommand.h>

Inheritance diagram for SetLabelCommand:
AudacityCommand ComponentInterface

Public Member Functions

 SetLabelCommand ()
 
ComponentInterfaceSymbol GetSymbol () override
 
wxString GetDescription () override
 
bool DefineParams (ShuttleParams &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
wxString ManualPage () override
 
bool Apply (const CommandContext &context) override
 
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
wxString GetPath () override
 
ComponentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
virtual bool Apply ()
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
virtual void SetHostUI (EffectUIHostInterface *WXUNUSED(host))
 
bool PopulateUI (wxWindow *parent)
 
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 wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
 
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 ()
 
const wxString & GetTranslatedName ()
 
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
 

Additional Inherited Members

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

Detailed Description

Command that sets label information.

Definition at line 24 of file SetLabelCommand.h.

Constructor & Destructor Documentation

SetLabelCommand::SetLabelCommand ( )

Definition at line 29 of file SetLabelCommand.cpp.

30 {
31 }

Member Function Documentation

bool SetLabelCommand::Apply ( const CommandContext context)
override

Definition at line 62 of file SetLabelCommand.cpp.

References TrackList::Any(), bHasSelected, bHasT0, bHasT1, bHasText, SelectedRegion::ensureOrdering(), CommandContext::Error(), CommandContext::GetProject(), AudacityProject::GetTracks(), mbSelected, mLabelIndex, mT0, mT1, mText, AudacityProject::mViewInfo, LabelStruct::selectedRegion, ViewInfo::selectedRegion, SelectedRegion::setT0(), SelectedRegion::setT1(), SelectedRegion::setTimes(), SelectedRegion::t0(), SelectedRegion::t1(), LabelStruct::title, and LabelStruct::updated.

63 {
64  // \todo we have similar code for finding the nth Label, Clip, Track etc.
65  // this code could be put in subroutines/reduced.
66 
67  //wxString mode = GetString(wxT("Type"));
68  AudacityProject * p = context.GetProject();
69  TrackList *tracks = context.GetProject()->GetTracks();
70  LabelStruct * pLabel = NULL;
71  int i=0;
72  int nn=0;
73 
74  LabelTrack *labelTrack {};
75  for (auto lt : tracks->Any<LabelTrack>()) {
76  if( i > mLabelIndex )
77  break;
78  labelTrack = lt;
79  for (nn = 0;
80  (nn< (int)labelTrack->mLabels.size()) && i<=mLabelIndex;
81  nn++) {
82  i++;
83  pLabel = &labelTrack->mLabels[nn];
84  }
85  }
86 
87  if ( (i< mLabelIndex) || (pLabel == NULL))
88  {
89  context.Error(wxT("LabelIndex was invalid."));
90  return false;
91  }
92  if( bHasText )
93  pLabel->title = mText;
94  if( bHasT0 )
95  pLabel->selectedRegion.setT0(mT0, false);
96  if( bHasT1 )
97  pLabel->selectedRegion.setT1(mT1, false);
98  if( bHasT0 || bHasT1 )
100  pLabel->updated = true;
101 
102  // Only one label can be selected.
103  if( bHasSelected ){
104  if( mbSelected )
105  {
106  labelTrack->mSelIndex = nn-1;
107  double t0 = pLabel->selectedRegion.t0();
108  double t1 = pLabel->selectedRegion.t1();
109  p->mViewInfo.selectedRegion.setTimes( t0, t1);
110  }
111  else if( labelTrack->mSelIndex == (nn-1) )
112  labelTrack->mSelIndex = -1;
113  }
114 
115  labelTrack->SortLabels();
116  return true;
117 }
AudacityProject * GetProject() const
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:162
wxString title
Definition: LabelTrack.h:92
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1246
bool updated
Pixel position of label.
Definition: LabelTrack.h:101
double t1() const
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:44
bool setT1(double t, bool maySwap=true)
ViewInfo mViewInfo
Definition: Project.h:555
bool setTimes(double t0, double t1)
SelectedRegion selectedRegion
Definition: LabelTrack.h:91
virtual void Error(const wxString &message) const
bool setT0(double t, bool maySwap=true)
TrackList * GetTracks()
Definition: Project.h:209
bool SetLabelCommand::DefineParams ( ShuttleParams S)
override

Definition at line 34 of file SetLabelCommand.cpp.

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

34  {
35  S.Define( mLabelIndex, wxT("Label"), 0, 0, 100 );
36  S.OptionalY( bHasText ).Define( mText, wxT("Text"), wxT("empty") );
37  S.OptionalY( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, 100000.0);
38  S.OptionalY( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, 100000.0);
39  S.OptionalN( bHasSelected ).Define( mbSelected, wxT("Selected"), false );
40  return true;
41 };
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
virtual ShuttleParams & OptionalY(bool &var)
Definition: Shuttle.h:71
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:338
wxString SetLabelCommand::GetDescription ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 30 of file SetLabelCommand.h.

References _().

30 {return _("Sets various values for a label.");};
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ComponentInterfaceSymbol SetLabelCommand::GetSymbol ( )
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 29 of file SetLabelCommand.h.

References SET_LABEL_PLUGIN_SYMBOL.

29 {return SET_LABEL_PLUGIN_SYMBOL;};
#define SET_LABEL_PLUGIN_SYMBOL
wxString SetLabelCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 35 of file SetLabelCommand.h.

35 {return wxT("Extra_Menu:_Scriptables_I#set_label");};
void SetLabelCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 43 of file SetLabelCommand.cpp.

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

44 {
45  S.AddSpace(0, 5);
46 
47  S.StartMultiColumn(2, wxALIGN_CENTER);
48  {
49  S.TieNumericTextBox( _("Label Index"), mLabelIndex );
50  }
51  S.EndMultiColumn();
52  S.StartMultiColumn(3, wxALIGN_CENTER);
53  {
54  S.Optional( bHasText ).TieTextBox( _("Text:"), mText );
55  S.Optional( bHasT0 ).TieNumericTextBox( _("Start:"), mT0 );
56  S.Optional( bHasT1 ).TieNumericTextBox( _("End:"), mT1 );
57  S.Optional( bHasSelected ).TieCheckBox( _("Selected:"), mbSelected );
58  }
59  S.EndMultiColumn();
60 }
ShuttleGui & Optional(bool &bVar)
void EndMultiColumn()
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
wxTextCtrl * TieNumericTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
wxSizerItem * AddSpace(int width, int height)
wxTextCtrl * TieTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)

Member Data Documentation

bool SetLabelCommand::bHasSelected

Definition at line 50 of file SetLabelCommand.h.

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

bool SetLabelCommand::bHasT0

Definition at line 48 of file SetLabelCommand.h.

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

bool SetLabelCommand::bHasT1

Definition at line 49 of file SetLabelCommand.h.

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

bool SetLabelCommand::bHasText

Definition at line 47 of file SetLabelCommand.h.

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

bool SetLabelCommand::mbSelected

Definition at line 44 of file SetLabelCommand.h.

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

int SetLabelCommand::mLabelIndex

Definition at line 40 of file SetLabelCommand.h.

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

double SetLabelCommand::mT0

Definition at line 42 of file SetLabelCommand.h.

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

double SetLabelCommand::mT1

Definition at line 43 of file SetLabelCommand.h.

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

wxString SetLabelCommand::mText

Definition at line 41 of file SetLabelCommand.h.

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


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