MCPcopy Create free account
hub / github.com/audacity/audacity / OnSetRegion

Function OnSetRegion

src/SelectUtilities.cpp:226–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void OnSetRegion(AudacityProject &project,
227 bool left, bool selection, const TranslatableString &dialogTitle)
228{
229 auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
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

Callers 4

OnSetLeftSelectionMethod · 0.85
OnSetRightSelectionMethod · 0.85
OnSetPlayRegionInFunction · 0.85
OnSetPlayRegionOutFunction · 0.85

Calls 13

GetFunction · 0.85
maxFunction · 0.85
GetAudioIOTokenMethod · 0.80
setT0Method · 0.80
setT1Method · 0.80
SetStartMethod · 0.80
SetEndMethod · 0.80
IsStreamActiveMethod · 0.80
GetStreamTimeMethod · 0.80
GetTimeValueMethod · 0.80
GetSelectionFormatMethod · 0.45
ShowModalMethod · 0.45

Tested by

no test coverage detected