Audacity  3.0.3
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SelectTracksCommand Class Reference

Command for changing the selection of tracks. More...

#include <SelectCommand.h>

Inheritance diagram for SelectTracksCommand:
Collaboration diagram for SelectTracksCommand:

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 bHasFirstTrack
bool bHasNumTracks
bool bHasMode
double mFirstTrack
double mNumTracks
int mMode

Static Public Attributes

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

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 selection of tracks.

Definition at line 76 of file SelectCommand.h.

Member Function Documentation

◆ Apply()

bool SelectTracksCommand::Apply ( const CommandContext context)

Definition at line 227 of file SelectCommand.cpp.

228 {
230  // Count selection as a do-nothing effect.
231  // Used to invalidate cached selection and tracks.
233  int index = 0;
234  auto &tracks = TrackList::Get( context.project );
236  // Defaults if no value...
237  if( !bHasNumTracks )
238  mNumTracks = 1.0;
239  if( !bHasFirstTrack )
240  mFirstTrack = 0.0;
242  // Multiple channels count as fractions of a track.
243  double last = mFirstTrack+mNumTracks;
244  double first = mFirstTrack;
246  for (auto t : tracks.Leaders()) {
247  auto channels = TrackList::Channels(t);
248  double term = 0.0;
249  // Add 0.01 so we are free of rounding errors in comparisons.
250  constexpr double fudge = 0.01;
251  for (auto channel : channels) {
252  double track = index + fudge + term;
253  bool sel = first <= track && track <= last;
254  if( mMode == 0 ){ // Set
255  channel->SetSelected(sel);
256  }
257  else if( mMode == 1 && sel ){ // Add
258  channel->SetSelected(sel);
259  }
260  else if( mMode == 2 && sel ){ // Remove
261  channel->SetSelected(!sel);
262  }
263  term += 1.0 / channels.size();
264  }
265  ++index;
266  }
267  return true;
268 }

References bHasFirstTrack, bHasNumTracks, TrackList::Channels(), TrackList::Get(), Effect::IncEffectCounter(), mFirstTrack, mMode, mNumTracks, and CommandContext::project.

Referenced by SelectCommand::Apply().

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

◆ DefineParams()

bool SelectTracksCommand::DefineParams ( ShuttleParams S)

Definition at line 200 of file SelectCommand.cpp.

200  {
201  S.OptionalN( bHasFirstTrack).Define( mFirstTrack, wxT("Track"), 0.0, 0.0, 100.0);
202  S.OptionalN( bHasNumTracks ).Define( mNumTracks, wxT("TrackCount"), 1.0, 0.0, 100.0);
203  S.OptionalY( bHasMode ).DefineEnum( mMode, wxT("Mode"), 0, kModes, nModes );
205  return true;
206 }

References bHasFirstTrack, bHasMode, bHasNumTracks, ShuttleParams::Define(), ShuttleParams::DefineEnum(), kModes, mFirstTrack, mMode, mNumTracks, nModes, 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 SelectTracksCommand::GetDescription ( )

Reimplemented from AudacityCommand.

Definition at line 83 of file SelectCommand.h.

83 {return XO("Selects a range of tracks.");};

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SelectTracksCommand::GetSymbol ( )

Implements AudacityCommand.

Definition at line 82 of file SelectCommand.h.

82 {return Symbol;};

References Symbol.

◆ ManualPage()

ManualPageID SelectTracksCommand::ManualPage ( )

Reimplemented from AudacityCommand.

Definition at line 88 of file SelectCommand.h.

88 {return L"Extra_Menu:_Scriptables_I#select_tracks";}

◆ PopulateOrExchange()

void SelectTracksCommand::PopulateOrExchange ( ShuttleGui S)

Definition at line 208 of file SelectCommand.cpp.

209 {
210  S.AddSpace(0, 5);
212  S.StartMultiColumn(3, wxEXPAND);
213  {
214  S.SetStretchyCol( 2 );
215  S.Optional( bHasFirstTrack).TieTextBox(XXO("First Track:"),mFirstTrack);
216  S.Optional( bHasNumTracks).TieTextBox(XXO("Track Count:"),mNumTracks);
217  }
218  S.EndMultiColumn();
219  S.StartMultiColumn(2, wxALIGN_CENTER);
220  {
221  // Always used, so no check box.
222  S.TieChoice( XXO("Mode:"), mMode, Msgids( kModes, nModes ));
223  }
224  S.EndMultiColumn();
225 }

References ShuttleGui::AddSpace(), bHasFirstTrack, bHasNumTracks, ShuttleGuiBase::EndMultiColumn(), kModes, mFirstTrack, mMode, mNumTracks, Msgids(), nModes, 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

◆ bHasFirstTrack

bool SelectTracksCommand::bHasFirstTrack

Definition at line 90 of file SelectCommand.h.

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

◆ bHasMode

bool SelectTracksCommand::bHasMode

Definition at line 92 of file SelectCommand.h.

Referenced by DefineParams().

◆ bHasNumTracks

bool SelectTracksCommand::bHasNumTracks

Definition at line 91 of file SelectCommand.h.

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

◆ mFirstTrack

double SelectTracksCommand::mFirstTrack

Definition at line 94 of file SelectCommand.h.

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

◆ mMode

int SelectTracksCommand::mMode

Definition at line 96 of file SelectCommand.h.

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

◆ mNumTracks

double SelectTracksCommand::mNumTracks

Definition at line 95 of file SelectCommand.h.

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

◆ Symbol

const ComponentInterfaceSymbol SelectTracksCommand::Symbol { XO("Select Tracks") }

Definition at line 79 of file SelectCommand.h.

Referenced by GetSymbol().

The documentation for this class was generated from the following files:
double mNumTracks
Definition: SelectCommand.h:95
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
#define XO(s)
Definition: Internat.h:31
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
double mFirstTrack
Definition: SelectCommand.h:94
static void IncEffectCounter()
Definition: Effect.h:279
virtual ShuttleParams & OptionalN(bool &var)
Definition: Shuttle.h:72
const int nModes
Definition: SelectCommand.cpp:189
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
int mMode
Definition: SelectCommand.h:96
#define XXO(s)
Definition: Internat.h:44
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
virtual void DefineEnum(int &var, const wxChar *key, const int vdefault, const EnumValueSymbol strings[], size_t nStrings)
Definition: Shuttle.cpp:339
bool bHasMode
Definition: SelectCommand.h:92
virtual ShuttleParams & OptionalY(bool &var)
Definition: Shuttle.h:71
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
static const EnumValueSymbol kModes[nModes]
Definition: SelectCommand.cpp:190
bool bHasFirstTrack
Definition: SelectCommand.h:90
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
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
static const ComponentInterfaceSymbol Symbol
Definition: SelectCommand.h:79
bool bHasNumTracks
Definition: SelectCommand.h:91