| 648 | } |
| 649 | |
| 650 | void OnChangeButtonClicked(wxCommandEvent& event) |
| 651 | { |
| 652 | if(!mDelegate || mProject == nullptr) |
| 653 | return; |
| 654 | |
| 655 | if(mEffectState == nullptr) |
| 656 | return;//not initialized |
| 657 | |
| 658 | const auto effectID = EffectsMenuHelper::PickEffect( |
| 659 | *mProject, |
| 660 | mChangeButton, |
| 661 | mEffectState->GetID() |
| 662 | ); |
| 663 | if(!effectID) |
| 664 | return;//nothing |
| 665 | |
| 666 | if(effectID->empty()) |
| 667 | RemoveFromList(); |
| 668 | else |
| 669 | { |
| 670 | auto &project = *mProject; |
| 671 | auto &em = RealtimeEffectManager::Get(project); |
| 672 | auto oIndex = em.FindState(mDelegate->GetChannelGroup(), mEffectState); |
| 673 | if (!oIndex) |
| 674 | return; |
| 675 | |
| 676 | auto oldName = GetEffectName(*mEffectState); |
| 677 | |
| 678 | if (auto state = AudioIO::Get() |
| 679 | ->ReplaceState(project, mDelegate->GetChannelGroup(), *oIndex, *effectID) |
| 680 | ){ |
| 681 | // Message subscription took care of updating the button text |
| 682 | // and destroyed `this`! |
| 683 | auto effect = state->GetEffect(); |
| 684 | assert(effect); // postcondition of ReplaceState |
| 685 | ProjectHistory::Get(project).PushState( |
| 686 | /*i18n-hint: undo history, |
| 687 | first and second parameters - realtime effect names |
| 688 | */ |
| 689 | XO("Replaced %s with %s") |
| 690 | .Format(oldName, effect->GetName()), |
| 691 | /*! i18n-hint: undo history record |
| 692 | first parameter - realtime effect name */ |
| 693 | XO("Replace %s").Format(oldName)); |
| 694 | |
| 695 | ToggleUi(project, *state, mDelegate->GetSourceName()); |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | void OnPaint(wxPaintEvent&) |
| 701 | { |
nothing calls this directly
no test coverage detected