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

Method OnChangeButtonClicked

src/RealtimeEffectPanel.cpp:650–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 12

GetFunction · 0.85
GetEffectNameFunction · 0.85
ToggleUiFunction · 0.85
GetIDMethod · 0.45
emptyMethod · 0.45
FindStateMethod · 0.45
GetChannelGroupMethod · 0.45
ReplaceStateMethod · 0.45
GetEffectMethod · 0.45
PushStateMethod · 0.45
GetNameMethod · 0.45
GetSourceNameMethod · 0.45

Tested by

no test coverage detected