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

Command for changing the time selection. More...

#include <SelectCommand.h>

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

Public Member Functions

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
 
bool Apply (const CommandContext &context) override
 
ManualPageID ManualPage () 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

bool bHasT0
 
bool bHasT1
 
bool bHasFromEnd
 
bool bHasRelativeSpec
 
double mT0
 
double mT1
 
int mRelativeTo
 
bool mFromEnd
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Select Time") }
 

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 for changing the time selection.

Definition at line 27 of file SelectCommand.h.

Member Function Documentation

◆ Apply()

bool SelectTimeCommand::Apply ( const CommandContext context)
override

Definition at line 100 of file SelectCommand.cpp.

100 {
101 // Many commands need focus on track panel.
102 // No harm in setting it with a scripted select.
103 TrackPanel::Get( context.project ).SetFocus();
104 if( !bHasT0 && !bHasT1 )
105 return true;
106
107 // Defaults if no value...
108 if( !bHasT0 )
109 mT0 = 0.0;
110 if( !bHasT1 )
111 mT1 = 0.0;
112 if( !bHasRelativeSpec )
113 mRelativeTo = 0;
114
115 AudacityProject * p = &context.project;
116 double end = TrackList::Get( *p ).GetEndTime();
117 double t0;
118 double t1;
119
120 auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
121 switch( bHasRelativeSpec ? mRelativeTo : 0 ){
122 default:
123 case 0: //project start
124 t0 = mT0;
125 t1 = mT1;
126 break;
127 case 1: //project
128 t0 = mT0;
129 t1 = end + mT1;
130 break;
131 case 2: //project end;
132 t0 = end - mT0;
133 t1 = end - mT1;
134 break;
135 case 3: //selection start
136 t0 = mT0 + selectedRegion.t0();
137 t1 = mT1 + selectedRegion.t0();
138 break;
139 case 4: //selection
140 t0 = mT0 + selectedRegion.t0();
141 t1 = mT1 + selectedRegion.t1();
142 break;
143 case 5: //selection end
144 t0 = selectedRegion.t1() - mT0;
145 t1 = selectedRegion.t1() - mT1;
146 break;
147 }
148
149 selectedRegion.setTimes( t0, t1 );
150 return true;
151}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
AudacityProject & project
double GetEndTime() const
Definition: Track.cpp:1048
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References bHasRelativeSpec, bHasT0, bHasT1, PackedArray::end(), ViewInfo::Get(), TrackList::Get(), TrackPanel::Get(), TrackList::GetEndTime(), mRelativeTo, mT0, mT1, CommandContext::project, and ViewInfo::selectedRegion.

Referenced by SelectCommand::Apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDescription()

TranslatableString SelectTimeCommand::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 34 of file SelectCommand.h.

34{return XO("Selects a time range.");};
#define XO(s)
Definition: Internat.h:31

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SelectTimeCommand::GetSymbol ( ) const
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 33 of file SelectCommand.h.

33{return Symbol;};
static const ComponentInterfaceSymbol Symbol
Definition: SelectCommand.h:30

References Symbol.

◆ ManualPage()

ManualPageID SelectTimeCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 42 of file SelectCommand.h.

42{return L"Extra_Menu:_Scriptables_I#select_time";}

◆ PopulateOrExchange()

void SelectTimeCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 83 of file SelectCommand.cpp.

84{
85 S.AddSpace(0, 5);
86
87 S.StartMultiColumn(3, wxEXPAND);
88 {
89 S.SetStretchyCol( 2 );
90 S.Optional( bHasT0 ).TieTextBox(XXO("Start Time:"), mT0);
91 S.Optional( bHasT1 ).TieTextBox(XXO("End Time:"), mT1);
92 // Chooses what time is relative to.
93 S.Optional( bHasRelativeSpec ).TieChoice(
94 XXO("Relative To:"),
96 }
97 S.EndMultiColumn();
98}
#define XXO(s)
Definition: Internat.h:44
static const EnumValueSymbol kRelativeTo[nRelativeTos]
const int nRelativeTos
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64

References bHasRelativeSpec, bHasT0, bHasT1, kRelativeTo, mRelativeTo, Msgids(), mT0, mT1, nRelativeTos, S, and XXO.

Referenced by SelectCommand::PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VisitSettings() [1/3]

bool SelectTimeCommand::VisitSettings ( ConstSettingsVisitor )
overridevirtual

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

Reimplemented from AudacityCommand.

Definition at line 80 of file SelectCommand.cpp.

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

References S.

◆ VisitSettings() [2/3]

bool SelectTimeCommand::VisitSettings ( SettingsVisitor )
overridevirtual

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

Reimplemented from AudacityCommand.

Definition at line 77 of file SelectCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 68 of file SelectCommand.cpp.

68 {
69 // Allow selection down to -ve 100seconds.
70 // Typically used to expand/contract selections by a small amount.
71 S.OptionalY( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -100.0, (double)FLT_MAX);
72 S.OptionalY( bHasT1 ).Define( mT1, wxT("End"), 0.0, -100.0, (double)FLT_MAX);
73 S.OptionalN( bHasRelativeSpec ).DefineEnum( mRelativeTo, wxT("RelativeTo"), 0, kRelativeTo, nRelativeTos );
74 return true;
75}

References bHasRelativeSpec, bHasT0, bHasT1, kRelativeTo, mRelativeTo, mT0, mT1, nRelativeTos, and S.

Referenced by SelectCommand::VisitSettings().

Here is the caller graph for this function:

Member Data Documentation

◆ bHasFromEnd

bool SelectTimeCommand::bHasFromEnd

Definition at line 46 of file SelectCommand.h.

◆ bHasRelativeSpec

bool SelectTimeCommand::bHasRelativeSpec

Definition at line 47 of file SelectCommand.h.

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

◆ bHasT0

bool SelectTimeCommand::bHasT0

Definition at line 44 of file SelectCommand.h.

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

◆ bHasT1

bool SelectTimeCommand::bHasT1

Definition at line 45 of file SelectCommand.h.

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

◆ mFromEnd

bool SelectTimeCommand::mFromEnd

Definition at line 52 of file SelectCommand.h.

◆ mRelativeTo

int SelectTimeCommand::mRelativeTo

Definition at line 51 of file SelectCommand.h.

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

◆ mT0

double SelectTimeCommand::mT0

Definition at line 49 of file SelectCommand.h.

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

◆ mT1

double SelectTimeCommand::mT1

Definition at line 50 of file SelectCommand.h.

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

◆ Symbol

const ComponentInterfaceSymbol SelectTimeCommand::Symbol { XO("Select Time") }
static

Definition at line 30 of file SelectCommand.h.

Referenced by GetSymbol().


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