| 224 | } |
| 225 | |
| 226 | void 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 |
no test coverage detected