Audacity 3.2.0
Functions
SelectUtilities Namespace Reference

Namespace for functions for Select menu. More...

Functions

void DoSelectTimeAndTracks (AudacityProject &project, bool bAllTime, bool bAllTracks)
 
void SelectNone (AudacityProject &project)
 
void SelectAllIfNone (AudacityProject &project)
 
bool SelectAllIfNoneAndAllowed (AudacityProject &project)
 
void DoListSelection (AudacityProject &project, Track &t, bool shift, bool ctrl, bool modifyState)
 
void DoSelectAll (AudacityProject &project)
 
void DoSelectAllAudio (AudacityProject &project)
 
void DoSelectSomething (AudacityProject &project)
 
void ActivatePlayRegion (AudacityProject &project)
 
void InactivatePlayRegion (AudacityProject &project)
 
void TogglePlayRegion (AudacityProject &project)
 
void ClearPlayRegion (AudacityProject &project)
 
void SetPlayRegionToSelection (AudacityProject &project)
 
void OnSetRegion (AudacityProject &project, bool left, bool selection, const TranslatableString &dialogTitle)
 Adjust left or right of selection or play region. More...
 

Detailed Description

Namespace for functions for Select menu.

Function Documentation

◆ ActivatePlayRegion()

AUDACITY_DLL_API void SelectUtilities::ActivatePlayRegion ( AudacityProject project)

Definition at line 168 of file SelectUtilities.cpp.

169{
170 auto &tracks = TrackList::Get( project );
171
172 auto &viewInfo = ViewInfo::Get( project );
173 auto &playRegion = viewInfo.playRegion;
174 playRegion.SetActive( true );
175 if (playRegion.Empty()) {
176 auto &selectedRegion = viewInfo.selectedRegion;
177 if (!selectedRegion.isPoint())
178 playRegion.SetTimes(selectedRegion.t0(), selectedRegion.t1());
179 else
180 // Arbitrary first four seconds
181 playRegion.SetTimes(0.0, 4.0);
182 }
183
184 // Ensure the proper state of looping in the menu
186}
const auto tracks
const auto project
static CommandManager & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References CommandManager::Get(), ViewInfo::Get(), TrackList::Get(), project, tracks, and CommandManager::UpdateCheckmarks().

Referenced by ControlToolBar::OnLoop(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionIn(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionOut(), and TogglePlayRegion().

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

◆ ClearPlayRegion()

AUDACITY_DLL_API void SelectUtilities::ClearPlayRegion ( AudacityProject project)

Definition at line 212 of file SelectUtilities.cpp.

213{
214 auto &viewInfo = ViewInfo::Get( project );
215 auto &playRegion = viewInfo.playRegion;
216 playRegion.Clear();
217
218 if (playRegion.Active())
220}
void InactivatePlayRegion(AudacityProject &project)

References ViewInfo::Get(), InactivatePlayRegion(), and project.

Referenced by anonymous_namespace{TransportMenus.cpp}::OnClearPlayRegion(), and AdornedRulerPanel::OnClearPlayRegion().

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

◆ DoListSelection()

AUDACITY_DLL_API void SelectUtilities::DoListSelection ( AudacityProject project,
Track t,
bool  shift,
bool  ctrl,
bool  modifyState 
)

Definition at line 116 of file SelectUtilities.cpp.

118{
120 auto &selectionState = SelectionState::Get(project);
121 auto &viewInfo = ViewInfo::Get(project);
122 auto &window = GetProjectFrame(project);
123
124 auto isSyncLocked = SyncLockState::Get(project).IsSyncLocked();
125 // Substitute the leader to satisfy precondition
126 auto pT = *tracks.Find(&t);
127 if (!pT)
128 return;
129
130 selectionState.HandleListSelection(
131 tracks, viewInfo, *pT,
132 shift, ctrl, isSyncLocked);
133
134 if (!ctrl)
135 TrackFocus::Get(project).Set(&t);
136 window.Refresh(false);
137 if (modifyState)
139}
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
bool IsSyncLocked() const
Definition: SyncLock.cpp:43
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:26
Track * Get()
Definition: TrackFocus.cpp:156

References TrackFocus::Get(), ProjectHistory::Get(), ViewInfo::Get(), SelectionState::Get(), SyncLockState::Get(), TrackList::Get(), GetProjectFrame(), SyncLockState::IsSyncLocked(), ProjectHistory::ModifyState(), project, and tracks.

Referenced by SelectHandle::Click(), TrackSelectHandle::Click(), SelectButtonHandle::CommitChanges(), and MixerTrackCluster::HandleSelect().

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

◆ DoSelectAll()

AUDACITY_DLL_API void SelectUtilities::DoSelectAll ( AudacityProject project)

Definition at line 141 of file SelectUtilities.cpp.

142{
143 DoSelectTimeAndTracks( project, true, true );
144}
void DoSelectTimeAndTracks(AudacityProject &project, bool bAllTime, bool bAllTracks)

References DoSelectTimeAndTracks(), and project.

Referenced by ApplyMacroDialog::OnApplyToFiles(), SelectActions::Handler::OnSelectAll(), and ProjectManager::ResetProjectToEmpty().

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

◆ DoSelectAllAudio()

AUDACITY_DLL_API void SelectUtilities::DoSelectAllAudio ( AudacityProject project)

Definition at line 146 of file SelectUtilities.cpp.

147{
148 DoSelectTimeAndAudioTracks( project, true, true );
149}
void DoSelectTimeAndAudioTracks(AudacityProject &project, bool bAllTime, bool bAllTracks)

References anonymous_namespace{SelectUtilities.cpp}::DoSelectTimeAndAudioTracks(), and project.

Referenced by SelectAllIfNone(), and SelectAllIfNoneAndAllowed().

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

◆ DoSelectSomething()

AUDACITY_DLL_API void SelectUtilities::DoSelectSomething ( AudacityProject project)

Definition at line 156 of file SelectUtilities.cpp.

157{
158 auto &tracks = TrackList::Get( project );
159 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
160
161 bool bTime = selectedRegion.isPoint();
162 bool bTracks = tracks.Selected().empty();
163
164 if (bTime || bTracks)
165 DoSelectTimeAndTracks(project, bTime, bTracks);
166}
bool isPoint() const
Definition: ViewInfo.h:40
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215

References DoSelectTimeAndTracks(), ViewInfo::Get(), TrackList::Get(), NotifyingSelectedRegion::isPoint(), project, ViewInfo::selectedRegion, and tracks.

Here is the call graph for this function:

◆ DoSelectTimeAndTracks()

AUDACITY_DLL_API void SelectUtilities::DoSelectTimeAndTracks ( AudacityProject project,
bool  bAllTime,
bool  bAllTracks 
)

Definition at line 60 of file SelectUtilities.cpp.

62{
63 auto &tracks = TrackList::Get( project );
64 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
65
66 if( bAllTime )
67 selectedRegion.setTimes(tracks.GetStartTime(), tracks.GetEndTime());
68
69 if( bAllTracks ) {
70 for (auto t : tracks)
71 t->SetSelected(true);
72
74 }
75}
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51

References ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), ProjectHistory::ModifyState(), project, ViewInfo::selectedRegion, NotifyingSelectedRegion::setTimes(), and tracks.

Referenced by DoSelectAll(), DoSelectSomething(), SelectActions::Handler::OnSelectAllTime(), and SelectActions::Handler::OnSelectAllTracks().

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

◆ InactivatePlayRegion()

AUDACITY_DLL_API void SelectUtilities::InactivatePlayRegion ( AudacityProject project)

Definition at line 188 of file SelectUtilities.cpp.

189{
190 auto &viewInfo = ViewInfo::Get( project );
191 auto &playRegion = viewInfo.playRegion;
192 auto &selectedRegion = viewInfo.selectedRegion;
193 // Set only the times that are fetched by the playback engine, but not
194 // the last-active times that are used for display.
195 playRegion.SetActive( false );
196 playRegion.SetTimes( selectedRegion.t0(), selectedRegion.t1() );
197
198 // Ensure the proper state of looping in the menu
200}

References CommandManager::Get(), ViewInfo::Get(), project, and CommandManager::UpdateCheckmarks().

Referenced by ClearPlayRegion(), ControlToolBar::OnLoop(), and TogglePlayRegion().

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

◆ OnSetRegion()

AUDACITY_DLL_API void SelectUtilities::OnSetRegion ( AudacityProject project,
bool  left,
bool  selection,
const TranslatableString dialogTitle 
)

Adjust left or right of selection or play region.

Pop up a dialog if not playing or recording, else use the current play position

Definition at line 230 of file SelectUtilities.cpp.

232{
234 auto &viewInfo = ViewInfo::Get( project );
235 auto &playRegion = viewInfo.playRegion;
236 auto &selectedRegion = viewInfo.selectedRegion;
237 const auto &formats = ProjectNumericFormats::Get( project );
238 auto &window = GetProjectFrame( project );
239
240 const auto getValue = [&]() -> double {
241 if (selection) {
242 if (left)
243 return selectedRegion.t0();
244 else
245 return selectedRegion.t1();
246 }
247 else {
248 if (left)
249 return playRegion.GetStart();
250 else
251 return playRegion.GetEnd();
252 }
253 };
254
255 const auto setValue = [&](double value){
256 if (selection) {
257 if (left)
258 selectedRegion.setT0(value, false);
259 else
260 selectedRegion.setT1(value, false);
261 }
262 else {
263 if (left)
264 playRegion.SetStart(value);
265 else
266 playRegion.SetEnd(value);
267 }
268 };
269
270 bool bSelChanged = false;
271 auto gAudioIO = AudioIO::Get();
272 if ((token > 0) && gAudioIO->IsStreamActive(token))
273 {
274 double indicator = gAudioIO->GetStreamTime();
275 setValue(indicator);
276 bSelChanged = true;
277 }
278 else
279 {
280 auto fmt = formats.GetSelectionFormat();
281
282 TimeDialog dlg(&window, dialogTitle,
283 fmt, project, getValue(), XO("Position"));
284
285 if (wxID_OK == dlg.ShowModal())
286 {
287 //Get the value from the dialog
288 setValue( std::max(0.0, dlg.GetTimeValue()) );
289 bSelChanged = true;
290 }
291 }
292
293 if (bSelChanged)
295}
XO("Cut/Copy/Paste")
static AudioIO * Get()
Definition: AudioIO.cpp:126
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectNumericFormats & Get(AudacityProject &project)
Dialog used to request a time value.
Definition: TimeDialog.h:25

References AudioIO::Get(), ProjectAudioIO::Get(), ProjectNumericFormats::Get(), ProjectHistory::Get(), ViewInfo::Get(), ProjectAudioIO::GetAudioIOToken(), GetProjectFrame(), TimeDialog::GetTimeValue(), ProjectHistory::ModifyState(), project, and XO().

Referenced by SelectActions::Handler::OnSetLeftSelection(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionIn(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionOut(), and SelectActions::Handler::OnSetRightSelection().

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

◆ SelectAllIfNone()

AUDACITY_DLL_API void SelectUtilities::SelectAllIfNone ( AudacityProject project)

Definition at line 89 of file SelectUtilities.cpp.

90{
91 auto &viewInfo = ViewInfo::Get( project );
93 if((flags & EditableTracksSelectedFlag()).none() ||
94 viewInfo.selectedRegion.isPoint())
96}
const ReservedCommandFlag & EditableTracksSelectedFlag()
@ none
Definition: Dither.h:20
CommandFlag GetUpdateFlags(bool quick=false) const
void DoSelectAllAudio(AudacityProject &project)

References DoSelectAllAudio(), EditableTracksSelectedFlag(), CommandManager::Get(), ViewInfo::Get(), CommandManager::GetUpdateFlags(), none, and project.

Referenced by ImportCommand::Apply(), and EffectUI::DoEffect().

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

◆ SelectAllIfNoneAndAllowed()

AUDACITY_DLL_API bool SelectUtilities::SelectAllIfNoneAndAllowed ( AudacityProject project)

Definition at line 100 of file SelectUtilities.cpp.

101{
102 auto allowed = gPrefs->ReadBool(wxT("/GUI/SelectAllOnNone"), false);
103 auto &viewInfo = ViewInfo::Get( project );
105
106 if((flags & EditableTracksSelectedFlag()).none() ||
107 viewInfo.selectedRegion.isPoint()) {
108 if (!allowed) {
109 return false;
110 }
112 }
113 return true;
114}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool ReadBool(const wxString &key, bool defaultValue) const

References DoSelectAllAudio(), EditableTracksSelectedFlag(), CommandManager::Get(), ViewInfo::Get(), CommandManager::GetUpdateFlags(), gPrefs, none, project, audacity::BasicSettings::ReadBool(), and wxT().

Referenced by MacroCommands::ApplyEffectCommand().

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

◆ SelectNone()

AUDACITY_DLL_API void SelectUtilities::SelectNone ( AudacityProject project)

Definition at line 77 of file SelectUtilities.cpp.

78{
79 auto &tracks = TrackList::Get( project );
80 for (auto t : tracks)
81 t->SetSelected(false);
82
83 auto &trackPanel = TrackPanel::Get( project );
84 trackPanel.Refresh(false);
85}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233

References TrackList::Get(), TrackPanel::Get(), project, and tracks.

Referenced by ProjectFileManager::AddImportedTracks(), anonymous_namespace{ImportMIDI.cpp}::DoImportMIDI(), anonymous_namespace{FileMenus.cpp}::OnImportLabels(), MixerBoardScrolledWindow::OnMouseEvent(), anonymous_namespace{LabelMenus.cpp}::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewWaveTrack(), and SelectActions::Handler::OnSelectNone().

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

◆ SetPlayRegionToSelection()

AUDACITY_DLL_API void SelectUtilities::SetPlayRegionToSelection ( AudacityProject project)

Definition at line 222 of file SelectUtilities.cpp.

223{
224 auto &viewInfo = ViewInfo::Get( project );
225 auto &playRegion = viewInfo.playRegion;
226 auto &selectedRegion = viewInfo.selectedRegion;
227 playRegion.SetAllTimes( selectedRegion.t0(), selectedRegion.t1() );
228}

References ViewInfo::Get(), and project.

Referenced by anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionToSelection(), and AdornedRulerPanel::OnSetPlayRegionToSelection().

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

◆ TogglePlayRegion()

AUDACITY_DLL_API void SelectUtilities::TogglePlayRegion ( AudacityProject project)

Definition at line 202 of file SelectUtilities.cpp.

203{
204 auto &viewInfo = ViewInfo::Get( project );
205 auto &playRegion = viewInfo.playRegion;
206 if (playRegion.Active())
208 else
210}
void ActivatePlayRegion(AudacityProject &project)

References ActivatePlayRegion(), ViewInfo::Get(), InactivatePlayRegion(), and project.

Referenced by anonymous_namespace{TransportMenus.cpp}::OnTogglePlayRegion(), and AdornedRulerPanel::OnTogglePlayRegion().

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