Audacity  3.0.3
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:
Collaboration diagram for SelectTimeCommand:

Public Member Functions

ComponentInterfaceSymbol GetSymbol () override
TranslatableString GetDescription () override
bool DefineParams (ShuttleParams &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 () 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

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

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)

Definition at line 92 of file SelectCommand.cpp.

92  {
93  // Many commands need focus on track panel.
94  // No harm in setting it with a scripted select.
95  TrackPanel::Get( context.project ).SetFocus();
96  if( !bHasT0 && !bHasT1 )
97  return true;
99  // Defaults if no value...
100  if( !bHasT0 )
101  mT0 = 0.0;
102  if( !bHasT1 )
103  mT1 = 0.0;
104  if( !bHasRelativeSpec )
105  mRelativeTo = 0;
107  AudacityProject * p = &context.project;
108  double end = TrackList::Get( *p ).GetEndTime();
109  double t0;
110  double t1;
112  auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
113  switch( bHasRelativeSpec ? mRelativeTo : 0 ){
114  default:
115  case 0: //project start
116  t0 = mT0;
117  t1 = mT1;
118  break;
119  case 1: //project
120  t0 = mT0;
121  t1 = end + mT1;
122  break;
123  case 2: //project end;
124  t0 = end - mT0;
125  t1 = end - mT1;
126  break;
127  case 3: //selection start
128  t0 = mT0 + selectedRegion.t0();
129  t1 = mT1 + selectedRegion.t0();
130  break;
131  case 4: //selection
132  t0 = mT0 + selectedRegion.t0();
133  t1 = mT1 + selectedRegion.t1();
134  break;
135  case 5: //selection end
136  t0 = selectedRegion.t1() - mT0;
137  t1 = selectedRegion.t1() - mT1;
138  break;
139  }
141  selectedRegion.setTimes( t0, t1 );
142  return true;
143 }

References bHasRelativeSpec, bHasT0, bHasT1, 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:

◆ DefineParams()

bool SelectTimeCommand::DefineParams ( ShuttleParams S)

Definition at line 66 of file SelectCommand.cpp.

66  {
67  // Allow selection down to -ve 100seconds.
68  // Typically used to expand/contract selections by a small amount.
69  S.OptionalY( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -100.0, (double)FLT_MAX);
70  S.OptionalY( bHasT1 ).Define( mT1, wxT("End"), 0.0, -100.0, (double)FLT_MAX);
72  return true;
73 }

References bHasRelativeSpec, bHasT0, bHasT1, ShuttleParams::Define(), ShuttleParams::DefineEnum(), kRelativeTo, mRelativeTo, mT0, mT1, nRelativeTos, ShuttleParams::OptionalN(), and ShuttleParams::OptionalY().

Referenced by SelectCommand::DefineParams().

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

◆ GetDescription()

TranslatableString SelectTimeCommand::GetDescription ( )

Reimplemented from AudacityCommand.

Definition at line 34 of file SelectCommand.h.

34 {return XO("Selects a time range.");};

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SelectTimeCommand::GetSymbol ( )

Implements AudacityCommand.

Definition at line 33 of file SelectCommand.h.

33 {return Symbol;};

References Symbol.

◆ ManualPage()

ManualPageID SelectTimeCommand::ManualPage ( )

Reimplemented from AudacityCommand.

Definition at line 40 of file SelectCommand.h.

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

◆ PopulateOrExchange()

void SelectTimeCommand::PopulateOrExchange ( ShuttleGui S)

Definition at line 75 of file SelectCommand.cpp.

76 {
77  S.AddSpace(0, 5);
79  S.StartMultiColumn(3, wxEXPAND);
80  {
81  S.SetStretchyCol( 2 );
82  S.Optional( bHasT0 ).TieTextBox(XXO("Start Time:"), mT0);
83  S.Optional( bHasT1 ).TieTextBox(XXO("End Time:"), mT1);
84  // Chooses what time is relative to.
86  XXO("Relative To:"),
88  }
89  S.EndMultiColumn();
90 }

References ShuttleGui::AddSpace(), bHasRelativeSpec, bHasT0, bHasT1, ShuttleGuiBase::EndMultiColumn(), kRelativeTo, mRelativeTo, Msgids(), mT0, mT1, nRelativeTos, ShuttleGui::Optional(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieTextBox(), and XXO.

Referenced by SelectCommand::PopulateOrExchange().

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 44 of file SelectCommand.h.

◆ bHasRelativeSpec

bool SelectTimeCommand::bHasRelativeSpec

Definition at line 45 of file SelectCommand.h.

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

◆ bHasT0

bool SelectTimeCommand::bHasT0

Definition at line 42 of file SelectCommand.h.

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

◆ bHasT1

bool SelectTimeCommand::bHasT1

Definition at line 43 of file SelectCommand.h.

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

◆ mFromEnd

bool SelectTimeCommand::mFromEnd

Definition at line 50 of file SelectCommand.h.

◆ mRelativeTo

int SelectTimeCommand::mRelativeTo

Definition at line 49 of file SelectCommand.h.

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

◆ mT0

double SelectTimeCommand::mT0

Definition at line 47 of file SelectCommand.h.

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

◆ mT1

double SelectTimeCommand::mT1

Definition at line 48 of file SelectCommand.h.

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

◆ Symbol

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

Definition at line 30 of file SelectCommand.h.

Referenced by GetSymbol().

The documentation for this class was generated from the following files:
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
double mT0
Definition: SelectCommand.h:47
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
#define XO(s)
Definition: Internat.h:31
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
double GetEndTime() const
Definition: Track.cpp:1038
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:196
#define XXO(s)
Definition: Internat.h:44
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
bool bHasT0
Definition: SelectCommand.h:42
static const ComponentInterfaceSymbol Symbol
Definition: SelectCommand.h:30
bool bHasT1
Definition: SelectCommand.h:43
virtual void DefineEnum(int &var, const wxChar *key, const int vdefault, const EnumValueSymbol strings[], size_t nStrings)
Definition: Shuttle.cpp:339
virtual ShuttleParams & OptionalY(bool &var)
Definition: Shuttle.h:71
static const EnumValueSymbol kRelativeTo[nRelativeTos]
Definition: SelectCommand.cpp:56
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
double mT1
Definition: SelectCommand.h:48
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
int mRelativeTo
Definition: SelectCommand.h:49
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
const int nRelativeTos
Definition: SelectCommand.cpp:55
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(bool &bVar)
Definition: ShuttleGui.cpp:2280
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
AudacityProject & project
Definition: CommandContext.h:64
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
bool bHasRelativeSpec
Definition: SelectCommand.h:45