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 164 of file SelectUtilities.cpp.

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

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

Referenced by ControlToolBar::OnLoop(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionIn(), anonymous_namespace{TransportMenus.cpp}::OnSetPlayRegionOut(), SetPlayRegionToSelection(), 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 206 of file SelectUtilities.cpp.

207{
208 auto &viewInfo = ViewInfo::Get( project );
209 auto &playRegion = viewInfo.playRegion;
210 playRegion.Clear();
211
212 if (playRegion.Active())
214}
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
126 selectionState.HandleListSelection(
127 tracks, viewInfo, t,
128 shift, ctrl, isSyncLocked);
129
130 if (!ctrl)
131 TrackFocus::Get(project).Set(&t);
132 window.Refresh(false);
133 if (modifyState)
135}
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 ...
const auto tracks
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
bool IsSyncLocked() const
Definition: SyncLock.cpp:44
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:27
Track * Get()
Definition: TrackFocus.cpp:156
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

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(), 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 137 of file SelectUtilities.cpp.

138{
139 DoSelectTimeAndTracks( project, true, true );
140}
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 142 of file SelectUtilities.cpp.

143{
144 DoSelectTimeAndAudioTracks( project, true, true );
145}
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 152 of file SelectUtilities.cpp.

153{
154 auto &tracks = TrackList::Get( project );
155 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
156
157 bool bTime = selectedRegion.isPoint();
158 bool bTracks = tracks.Selected().empty();
159
160 if (bTime || bTracks)
161 DoSelectTimeAndTracks(project, bTime, bTracks);
162}
bool isPoint() const
Definition: ViewInfo.h:40
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216

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 182 of file SelectUtilities.cpp.

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

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 226 of file SelectUtilities.cpp.

228{
230 auto &viewInfo = ViewInfo::Get( project );
231 auto &playRegion = viewInfo.playRegion;
232 auto &selectedRegion = viewInfo.selectedRegion;
233 const auto &formats = ProjectNumericFormats::Get( project );
234 auto &window = GetProjectFrame( project );
235
236 const auto getValue = [&]() -> double {
237 if (selection) {
238 if (left)
239 return selectedRegion.t0();
240 else
241 return selectedRegion.t1();
242 }
243 else {
244 if (left)
245 return playRegion.GetStart();
246 else
247 return playRegion.GetEnd();
248 }
249 };
250
251 const auto setValue = [&](double value){
252 if (selection) {
253 if (left)
254 selectedRegion.setT0(value, false);
255 else
256 selectedRegion.setT1(value, false);
257 }
258 else {
259 if (left)
260 playRegion.SetStart(value);
261 else
262 playRegion.SetEnd(value);
263 }
264 };
265
266 bool bSelChanged = false;
267 auto gAudioIO = AudioIO::Get();
268 if ((token > 0) && gAudioIO->IsStreamActive(token))
269 {
270 double indicator = gAudioIO->GetStreamTime();
271 setValue(indicator);
272 bSelChanged = true;
273 }
274 else
275 {
276 auto fmt = formats.GetSelectionFormat();
277
278 TimeDialog dlg(&window, dialogTitle,
279 fmt, project, getValue(), XO("Position"));
280
281 if (wxID_OK == dlg.ShowModal())
282 {
283 //Get the value from the dialog
284 setValue( std::max(0.0, dlg.GetTimeValue()) );
285 bSelChanged = true;
286 }
287 }
288
289 if (bSelChanged)
291}
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:234

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 216 of file SelectUtilities.cpp.

217{
218 auto &viewInfo = ViewInfo::Get( project );
219 auto &playRegion = viewInfo.playRegion;
220 auto &selectedRegion = viewInfo.selectedRegion;
221 playRegion.SetAllTimes( selectedRegion.t0(), selectedRegion.t1() );
222 if(!playRegion.Empty())
224}
void ActivatePlayRegion(AudacityProject &project)

References ActivatePlayRegion(), 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 196 of file SelectUtilities.cpp.

197{
198 auto &viewInfo = ViewInfo::Get( project );
199 auto &playRegion = viewInfo.playRegion;
200 if (playRegion.Active())
202 else
204}

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: