| 371 | |
| 372 | |
| 373 | void OnCopy(const CommandContext &context) |
| 374 | { |
| 375 | ClearClipboard(); |
| 376 | |
| 377 | auto &project = context.project; |
| 378 | auto &tracks = TrackList::Get( project ); |
| 379 | auto &trackPanel = TrackPanel::Get( project ); |
| 380 | auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; |
| 381 | |
| 382 | for (auto lt : tracks.Selected<LabelTrack>()) { |
| 383 | auto &view = LabelTrackView::Get( *lt ); |
| 384 | if (view.CopySelectedText( context.project )) { |
| 385 | //trackPanel.Refresh(false); |
| 386 | return; |
| 387 | } |
| 388 | } |
| 389 | //Presumably, there might be not more than one track |
| 390 | //that expects text input |
| 391 | for (auto wt : tracks.Any<WaveTrack>()) { |
| 392 | auto& view = WaveChannelView::GetFirst(*wt); |
| 393 | if (view.CopySelectedText(context.project)) { |
| 394 | return; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | auto &clipboard = Clipboard::Get(); |
| 399 | clipboard.Clear(); |
| 400 | |
| 401 | auto pNewClipboard = TrackList::Create( nullptr ); |
| 402 | auto &newClipboard = *pNewClipboard; |
| 403 | |
| 404 | for (auto n : tracks.Selected()) { |
| 405 | if (n->SupportsBasicEditing()) { |
| 406 | auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1()); |
| 407 | newClipboard.Add(dest); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | // Survived possibility of exceptions. Commit changes to the clipboard now. |
| 412 | clipboard.Assign( std::move( newClipboard ), |
| 413 | selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() ); |
| 414 | |
| 415 | //Make sure the menus/toolbar states get updated |
| 416 | trackPanel.Refresh(false); |
| 417 | } |
| 418 | |
| 419 | std::pair<double, double> FindSelection(const CommandContext &context) |
| 420 | { |
nothing calls this directly
no test coverage detected