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 104 of file SelectCommand.cpp.

104 {
105 // Many commands need focus on track panel.
106 // No harm in setting it with a scripted select.
107 TrackPanel::Get( context.project ).SetFocus();
108 if( !bHasT0 && !bHasT1 )
109 return true;
110
111 // Defaults if no value...
112 if( !bHasT0 )
113 mT0 = 0.0;
114 if( !bHasT1 )
115 mT1 = 0.0;
116 if( !bHasRelativeSpec )
117 mRelativeTo = 0;
118
119 AudacityProject * p = &context.project;
120 double end = TrackList::Get(*p).GetEndTime();
121 double t0;
122 double t1;
123
124 auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
125 switch( bHasRelativeSpec ? mRelativeTo : 0 ){
126 default:
127 case 0: //project start
128 t0 = mT0;
129 t1 = mT1;
130 break;
131 case 1: //project
132 t0 = mT0;
133 t1 = end + mT1;
134 break;
135 case 2: //project end;
136 t0 = end - mT0;
137 t1 = end - mT1;
138 break;
139 case 3: //selection start
140 t0 = mT0 + selectedRegion.t0();
141 t1 = mT1 + selectedRegion.t0();
142 break;
143 case 4: //selection
144 t0 = mT0 + selectedRegion.t0();
145 t1 = mT1 + selectedRegion.t1();
146 break;
147 case 5: //selection end
148 t0 = selectedRegion.t1() - mT0;
149 t1 = selectedRegion.t1() - mT1;
150 break;
151 }
152
153 selectedRegion.setTimes( t0, t1 );
154 return true;
155}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
AudacityProject & project
double GetEndTime() const
Return the greatest end time of the tracks, or 0 when no tracks.
Definition: Track.cpp:991
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
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.");};
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ 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 87 of file SelectCommand.cpp.

88{
89 S.AddSpace(0, 5);
90
91 S.StartMultiColumn(3, wxEXPAND);
92 {
93 S.SetStretchyCol( 2 );
94 S.Optional( bHasT0 ).TieTextBox(XXO("Start Time:"), mT0);
95 S.Optional( bHasT1 ).TieTextBox(XXO("End Time:"), mT1);
96 // Chooses what time is relative to.
97 S.Optional( bHasRelativeSpec ).TieChoice(
98 XXO("Relative To:"),
100 }
101 S.EndMultiColumn();
102}
XXO("&Cut/Copy/Paste Toolbar")
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 84 of file SelectCommand.cpp.

85 { 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 81 of file SelectCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 72 of file SelectCommand.cpp.

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

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

Referenced by SelectCommand::VisitSettings().

Here is the call graph for this function:
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: