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
185 CommandManager::Get( project ).UpdateCheckmarks( project );
186}
void UpdateCheckmarks(AudacityProject &project)
static CommandManager & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:468
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

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

Referenced by ControlToolBar::OnLoop(), TransportActions::Handler::OnSetPlayRegionIn(), TransportActions::Handler::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}

References ViewInfo::Get().

Referenced by TransportActions::Handler::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 119 of file SelectUtilities.cpp.

121{
122 auto &tracks = TrackList::Get( project );
123 auto &selectionState = SelectionState::Get( project );
124 const auto &settings = ProjectSettings::Get( project );
125 auto &viewInfo = ViewInfo::Get( project );
126 auto &window = GetProjectFrame( project );
127
128 auto isSyncLocked = settings.IsSyncLocked();
129
130 selectionState.HandleListSelection(
131 tracks, viewInfo, *t,
132 shift, ctrl, isSyncLocked );
133
134 if (! ctrl )
135 TrackFocus::Get( project ).Set( t );
136 window.Refresh(false);
137 if (modifyState)
138 ProjectHistory::Get( project ).ModifyState(true);
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 ...
static Settings & settings()
Definition: TrackInfo.cpp:87
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
Track * Get()

References TrackFocus::Get(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), ProjectSettings::Get(), SelectionState::Get(), GetProjectFrame(), ProjectHistory::ModifyState(), and settings().

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().

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().

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:39
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216

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

64{
65 auto &tracks = TrackList::Get( project );
66 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
67
68 if( bAllTime )
69 selectedRegion.setTimes(
70 tracks.GetMinOffset(), tracks.GetEndTime());
71
72 if( bAllTracks ) {
73 for (auto t : tracks.Any())
74 t->SetSelected(true);
75
76 ProjectHistory::Get( project ).ModifyState(false);
77 }
78}
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 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
199 CommandManager::Get( project ).UpdateCheckmarks( project );
200}

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

229{
230 auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
231 auto &viewInfo = ViewInfo::Get( project );
232 auto &playRegion = viewInfo.playRegion;
233 auto &selectedRegion = viewInfo.selectedRegion;
234 const auto &settings = ProjectSettings::Get( project );
235 auto &window = GetProjectFrame( project );
236
237 const auto getValue = [&]() -> double {
238 if (selection) {
239 if (left)
240 return selectedRegion.t0();
241 else
242 return selectedRegion.t1();
243 }
244 else {
245 if (left)
246 return playRegion.GetStart();
247 else
248 return playRegion.GetEnd();
249 }
250 };
251
252 const auto setValue = [&](double value){
253 if (selection) {
254 if (left)
255 selectedRegion.setT0(value, false);
256 else
257 selectedRegion.setT1(value, false);
258 }
259 else {
260 if (left)
261 playRegion.SetStart(value);
262 else
263 playRegion.SetEnd(value);
264 }
265 };
266
267 bool bSelChanged = false;
268 auto gAudioIO = AudioIO::Get();
269 if ((token > 0) && gAudioIO->IsStreamActive(token))
270 {
271 double indicator = gAudioIO->GetStreamTime();
272 setValue(indicator);
273 bSelChanged = true;
274 }
275 else
276 {
277 auto fmt = settings.GetSelectionFormat();
278 auto rate = ProjectRate::Get(project).GetRate();
279
280 TimeDialog dlg(&window, dialogTitle,
281 fmt, rate, 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}
#define XO(s)
Definition: Internat.h:31
static AudioIO * Get()
Definition: AudioIO.cpp:133
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
Dialog used to request a time value.
Definition: TimeDialog.h:24

References AudioIO::Get(), ProjectHistory::Get(), ProjectRate::Get(), ViewInfo::Get(), ProjectAudioIO::Get(), ProjectSettings::Get(), ProjectAudioIO::GetAudioIOToken(), GetProjectFrame(), ProjectRate::GetRate(), TimeDialog::GetTimeValue(), ProjectHistory::ModifyState(), settings(), and XO.

Referenced by SelectActions::Handler::OnSetLeftSelection(), TransportActions::Handler::OnSetPlayRegionIn(), TransportActions::Handler::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 92 of file SelectUtilities.cpp.

93{
94 auto &viewInfo = ViewInfo::Get( project );
95 auto flags = MenuManager::Get( project ).GetUpdateFlags();
96 if((flags & EditableTracksSelectedFlag()).none() ||
97 viewInfo.selectedRegion.isPoint())
98 DoSelectAllAudio( project );
99}
const ReservedCommandFlag & EditableTracksSelectedFlag()
@ none
Definition: Dither.h:20
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:553
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 103 of file SelectUtilities.cpp.

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

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

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

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

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

Referenced by ProjectFileManager::AddImportedTracks(), DoImportMIDI(), FileActions::Handler::OnImportLabels(), MixerBoardScrolledWindow::OnMouseEvent(), LabelEditActions::Handler::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::Handler::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::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 219 of file SelectUtilities.cpp.

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

References ViewInfo::Get().

Referenced by TransportActions::Handler::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())
207 InactivatePlayRegion(project);
208 else
209 ActivatePlayRegion(project);
210}
void ActivatePlayRegion(AudacityProject &project)
void InactivatePlayRegion(AudacityProject &project)

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

Referenced by TransportActions::Handler::OnTogglePlayRegion(), and AdornedRulerPanel::OnTogglePlayRegion().

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