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

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

References ViewInfo::Get(), TrackList::Get(), CommandManager::Get(), 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 213 of file SelectUtilities.cpp.

214{
215 auto &viewInfo = ViewInfo::Get( project );
216 auto &playRegion = viewInfo.playRegion;
217 playRegion.Clear();
218}

References ViewInfo::Get().

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

123{
124 auto &tracks = TrackList::Get( project );
125 auto &selectionState = SelectionState::Get( project );
126 auto &viewInfo = ViewInfo::Get( project );
127 auto &window = GetProjectFrame( project );
128
129 auto isSyncLocked = SyncLockState::Get(project).IsSyncLocked();
130
131 selectionState.HandleListSelection(
132 tracks, viewInfo, *t,
133 shift, ctrl, isSyncLocked );
134
135 if (! ctrl )
136 TrackFocus::Get( project ).Set( t );
137 window.Refresh(false);
138 if (modifyState)
139 ProjectHistory::Get( project ).ModifyState(true);
140}
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()

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

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

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

References DoSelectTimeAndTracks().

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

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

References anonymous_namespace{SelectUtilities.cpp}::DoSelectTimeAndAudioTracks().

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

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

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

Here is the call graph for this function:

◆ DoSelectTimeAndTracks()

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

Definition at line 64 of file SelectUtilities.cpp.

66{
67 auto &tracks = TrackList::Get( project );
68 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
69
70 if( bAllTime )
71 selectedRegion.setTimes(
72 tracks.GetMinOffset(), tracks.GetEndTime());
73
74 if( bAllTracks ) {
75 for (auto t : tracks.Leaders())
76 t->SetSelected(true);
77
78 ProjectHistory::Get( project ).ModifyState(false);
79 }
80}
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51

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

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

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

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

Referenced by 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 228 of file SelectUtilities.cpp.

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

95{
96 auto &viewInfo = ViewInfo::Get( project );
97 auto flags = MenuManager::Get( project ).GetUpdateFlags();
98 if((flags & EditableTracksSelectedFlag()).none() ||
99 viewInfo.selectedRegion.isPoint())
100 DoSelectAllAudio( project );
101}
const ReservedCommandFlag & EditableTracksSelectedFlag()
@ none
Definition: Dither.h:20
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:539
void DoSelectAllAudio(AudacityProject &project)

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

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

106{
107 auto allowed = gPrefs->ReadBool(wxT("/GUI/SelectAllOnNone"), false);
108 auto &viewInfo = ViewInfo::Get( project );
109 auto flags = MenuManager::Get( project ).GetUpdateFlags();
110
111 if((flags & EditableTracksSelectedFlag()).none() ||
112 viewInfo.selectedRegion.isPoint()) {
113 if (!allowed) {
114 return false;
115 }
116 DoSelectAllAudio( project );
117 }
118 return true;
119}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:70

References DoSelectAllAudio(), EditableTracksSelectedFlag(), ViewInfo::Get(), MenuManager::Get(), MenuManager::GetUpdateFlags(), gPrefs, none, 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 82 of file SelectUtilities.cpp.

83{
84 auto &tracks = TrackList::Get( project );
85 for (auto t : tracks.Leaders())
86 t->SetSelected(false);
87
88 auto &trackPanel = TrackPanel::Get( project );
89 trackPanel.Refresh(false);
90}
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231

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

Referenced by ProjectFileManager::AddImportedTracks(), 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 220 of file SelectUtilities.cpp.

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

References ViewInfo::Get().

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

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

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

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: