Audacity 3.2.0
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:
[legend]
Collaboration diagram for SelectTracksCommand:
[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 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 }
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 

Detailed Description

Command for changing the selection of tracks.

Definition at line 80 of file SelectCommand.h.

Member Function Documentation

◆ Apply()

bool SelectTracksCommand::Apply ( const CommandContext context)
override

Definition at line 249 of file SelectCommand.cpp.

250{
251
252 // Count selection as a do-nothing effect.
253 // Used to invalidate cached selection and tracks.
255 int index = 0;
256 auto &tracks = TrackList::Get( context.project );
257
258 // Defaults if no value...
259 if( !bHasNumTracks )
260 mNumTracks = 1.0;
261 if( !bHasFirstTrack )
262 mFirstTrack = 0.0;
263
264 // Multiple channels count as fractions of a track.
265 double last = mFirstTrack+mNumTracks;
266 double first = mFirstTrack;
267
268 for (auto t : tracks.Leaders()) {
269 auto channels = TrackList::Channels(t);
270 double term = 0.0;
271 // Add 0.01 so we are free of rounding errors in comparisons.
272 constexpr double fudge = 0.01;
273 for (auto channel : channels) {
274 double track = index + fudge + term;
275 bool sel = first <= track && track <= last;
276 if( mMode == 0 ){ // Set
277 channel->SetSelected(sel);
278 }
279 else if( mMode == 1 && sel ){ // Add
280 channel->SetSelected(sel);
281 }
282 else if( mMode == 2 && sel ){ // Remove
283 channel->SetSelected(!sel);
284 }
285 term += 1.0 / channels.size();
286 }
287 ++index;
288 }
289 return true;
290}
AudacityProject & project
static void IncEffectCounter()
Definition: Effect.h:177
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1539

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:

◆ GetDescription()

TranslatableString SelectTracksCommand::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 87 of file SelectCommand.h.

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

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SelectTracksCommand::GetSymbol ( ) const
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 86 of file SelectCommand.h.

86{return Symbol;};
static const ComponentInterfaceSymbol Symbol
Definition: SelectCommand.h:83

References Symbol.

◆ ManualPage()

ManualPageID SelectTracksCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 94 of file SelectCommand.h.

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

◆ PopulateOrExchange()

void SelectTracksCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 230 of file SelectCommand.cpp.

231{
232 S.AddSpace(0, 5);
233
234 S.StartMultiColumn(3, wxEXPAND);
235 {
236 S.SetStretchyCol( 2 );
237 S.Optional( bHasFirstTrack).TieTextBox(XXO("First Track:"),mFirstTrack);
238 S.Optional( bHasNumTracks).TieTextBox(XXO("Track Count:"),mNumTracks);
239 }
240 S.EndMultiColumn();
241 S.StartMultiColumn(2, wxALIGN_CENTER);
242 {
243 // Always used, so no check box.
244 S.TieChoice( XXO("Mode:"), mMode, Msgids( kModes, nModes ));
245 }
246 S.EndMultiColumn();
247}
#define XXO(s)
Definition: Internat.h:44
static const EnumValueSymbol kModes[nModes]
const int nModes
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64

References bHasFirstTrack, bHasNumTracks, kModes, mFirstTrack, mMode, mNumTracks, Msgids(), nModes, 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 SelectTracksCommand::VisitSettings ( ConstSettingsVisitor )
overridevirtual

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

Reimplemented from AudacityCommand.

Definition at line 227 of file SelectCommand.cpp.

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

References S.

◆ VisitSettings() [2/3]

bool SelectTracksCommand::VisitSettings ( SettingsVisitor )
overridevirtual

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

Reimplemented from AudacityCommand.

Definition at line 224 of file SelectCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 216 of file SelectCommand.cpp.

216 {
217 S.OptionalN( bHasFirstTrack).Define( mFirstTrack, wxT("Track"), 0.0, 0.0, 100.0);
218 S.OptionalN( bHasNumTracks ).Define( mNumTracks, wxT("TrackCount"), 1.0, 0.0, 100.0);
219 S.OptionalY( bHasMode ).DefineEnum( mMode, wxT("Mode"), 0, kModes, nModes );
220
221 return true;
222}

References bHasFirstTrack, bHasMode, bHasNumTracks, kModes, mFirstTrack, mMode, mNumTracks, nModes, and S.

Referenced by SelectCommand::VisitSettings().

Here is the caller graph for this function:

Member Data Documentation

◆ bHasFirstTrack

bool SelectTracksCommand::bHasFirstTrack

Definition at line 96 of file SelectCommand.h.

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

◆ bHasMode

bool SelectTracksCommand::bHasMode

Definition at line 98 of file SelectCommand.h.

Referenced by VisitSettings().

◆ bHasNumTracks

bool SelectTracksCommand::bHasNumTracks

Definition at line 97 of file SelectCommand.h.

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

◆ mFirstTrack

double SelectTracksCommand::mFirstTrack

Definition at line 100 of file SelectCommand.h.

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

◆ mMode

int SelectTracksCommand::mMode

Definition at line 102 of file SelectCommand.h.

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

◆ mNumTracks

double SelectTracksCommand::mNumTracks

Definition at line 101 of file SelectCommand.h.

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

◆ Symbol

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

Definition at line 83 of file SelectCommand.h.

Referenced by GetSymbol().


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