Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl Class Reference
Inheritance diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl:
[legend]
Collaboration diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl:
[legend]

Public Member Functions

 RealtimeEffectControl ()=default
 
 RealtimeEffectControl (wxWindow *parent, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
void Create (wxWindow *parent, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
TranslatableString GetEffectName () const
 
void SetEffect (AudacityProject &project, const std::shared_ptr< Track > &track, const std::shared_ptr< RealtimeEffectState > &pState)
 
void RemoveFromList ()
 
void OnOptionsClicked (wxCommandEvent &event)
 
void OnChangeButtonClicked (wxCommandEvent &event)
 
void OnPaint (wxPaintEvent &)
 
void OnFocusChange (wxFocusEvent &evt)
 
- Public Member Functions inherited from anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< MovableControl >
 ListNavigationEnabled ()
 

Static Public Member Functions

static const PluginDescriptorGetPlugin (const PluginID &ID)
 

Private Attributes

wxWeakRef< AudacityProjectmProject
 
std::shared_ptr< TrackmTrack
 
std::shared_ptr< RealtimeEffectStatemEffectState
 
std::shared_ptr< EffectSettingsAccessmSettingsAccess
 
ThemedAButtonWrapper< AButton > * mChangeButton {nullptr}
 
AButtonmEnableButton {nullptr}
 
ThemedAButtonWrapper< AButton > * mOptionsButton {}
 
Observer::Subscription mSubscription
 

Detailed Description

Definition at line 607 of file RealtimeEffectPanel.cpp.

Constructor & Destructor Documentation

◆ RealtimeEffectControl() [1/2]

anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::RealtimeEffectControl ( )
default

◆ RealtimeEffectControl() [2/2]

anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::RealtimeEffectControl ( wxWindow *  parent,
wxWindowID  winid,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
inline

Definition at line 623 of file RealtimeEffectPanel.cpp.

627 {
628 Create(parent, winid, pos, size);
629 }
void Create(wxWindow *parent, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)

References size.

Member Function Documentation

◆ Create()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::Create ( wxWindow *  parent,
wxWindowID  winid,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
inline

Definition at line 631 of file RealtimeEffectPanel.cpp.

635 {
636 //Prevents flickering and paint order issues
637 MovableControl::SetBackgroundStyle(wxBG_STYLE_PAINT);
638 MovableControl::Create(parent, winid, pos, size, wxNO_BORDER | wxWANTS_CHARS);
639
640 Bind(wxEVT_PAINT, &RealtimeEffectControl::OnPaint, this);
641 Bind(wxEVT_SET_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
642 Bind(wxEVT_KILL_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
643
644 auto sizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
645
646 //On/off button
647 auto enableButton = safenew ThemedAButtonWrapper<AButton>(this);
648 enableButton->SetTranslatableLabel(XO("Power"));
649 enableButton->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
650 enableButton->SetButtonToggles(true);
651 enableButton->SetBackgroundColorIndex(clrEffectListItemBackground);
652 mEnableButton = enableButton;
653
654 enableButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
655
656 mEffectState->SetActive(mEnableButton->IsDown());
657 });
658
659 //Central button with effect name, show settings
660 const auto optionsButton = safenew ThemedAButtonWrapper<AButton>(this, wxID_ANY);
661 optionsButton->SetImageIndices(0,
662 bmpHButtonNormal,
663 bmpHButtonHover,
664 bmpHButtonDown,
665 bmpHButtonHover,
666 bmpHButtonDisabled);
667 optionsButton->SetBackgroundColorIndex(clrEffectListItemBackground);
668 optionsButton->SetForegroundColorIndex(clrTrackPanelText);
669 optionsButton->SetButtonType(AButton::TextButton);
670 optionsButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnOptionsClicked, this);
671
672 //Remove/replace effect
673 auto changeButton = safenew ThemedAButtonWrapper<AButton>(this);
674 changeButton->SetImageIndices(0, bmpMoreNormal, bmpMoreHover, bmpMoreDown, bmpMoreHover, bmpMoreDisabled);
675 changeButton->SetBackgroundColorIndex(clrEffectListItemBackground);
676 changeButton->SetTranslatableLabel(XO("Replace effect"));
677 changeButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnChangeButtonClicked, this);
678
679 auto dragArea = safenew wxStaticBitmap(this, wxID_ANY, theTheme.Bitmap(bmpDragArea));
680 dragArea->Disable();
681 sizer->Add(dragArea, 0, wxLEFT | wxCENTER, 5);
682 sizer->Add(enableButton, 0, wxLEFT | wxCENTER, 5);
683 sizer->Add(optionsButton, 1, wxLEFT | wxCENTER, 5);
684 sizer->Add(changeButton, 0, wxLEFT | wxRIGHT | wxCENTER, 5);
685 mChangeButton = changeButton;
686 mOptionsButton = optionsButton;
687
688 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
689 vSizer->Add(sizer.release(), 0, wxUP | wxDOWN | wxEXPAND, 10);
690
691 SetSizer(vSizer.release());
692
693#if wxUSE_ACCESSIBILITY
694 SetAccessible(safenew RealtimeEffectControlAx(this));
695#endif
696 }
#define XO(s)
Definition: Internat.h:31
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
bool IsDown()
Definition: AButton.h:129
@ TextButton
Definition: AButton.h:34
wxBitmap & Bitmap(int iIndex)
void Create(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)

References ThemeBase::Bitmap(), safenew, size, AButton::TextButton, theTheme, and XO.

Here is the call graph for this function:

◆ GetEffectName()

TranslatableString anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::GetEffectName ( ) const
inline
Precondition
mEffectState != nullptr

Definition at line 704 of file RealtimeEffectPanel.cpp.

705 {
706 const auto &ID = mEffectState->GetID();
707 const auto desc = GetPlugin(ID);
708 return desc
709 ? desc->GetSymbol().Msgid()
710 : XO("%s (missing)")
711 .Format(PluginManager::GetEffectNameFromID(ID).GET());
712 }
const TranslatableString desc
Definition: ExportPCM.cpp:58
static Identifier GetEffectNameFromID(const PluginID &ID)
static const PluginDescriptor * GetPlugin(const PluginID &ID)

References desc, PluginManager::GetEffectNameFromID(), and XO.

Here is the call graph for this function:

◆ GetPlugin()

static const PluginDescriptor * anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::GetPlugin ( const PluginID ID)
inlinestatic

Definition at line 698 of file RealtimeEffectPanel.cpp.

698 {
699 auto desc = PluginManager::Get().GetPlugin(ID);
700 return desc;
701 }
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()

References desc, PluginManager::Get(), and PluginManager::GetPlugin().

Here is the call graph for this function:

◆ OnChangeButtonClicked()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnChangeButtonClicked ( wxCommandEvent &  event)
inline

i18n-hint: undo history record first parameter - realtime effect name

Definition at line 796 of file RealtimeEffectPanel.cpp.

797 {
798 if(!mTrack || mProject == nullptr)
799 return;
800 if(mEffectState == nullptr)
801 return;//not initialized
802
803 const auto effectID = ShowSelectEffectMenu(mChangeButton, this);
804 if(effectID.empty())
805 return;
806
808 auto oIndex = em.FindState(&*mTrack, mEffectState);
809 if (!oIndex)
810 return;
811
812 auto oldName = GetEffectName();
813 auto &project = *mProject;
814 auto trackName = mTrack->GetName();
815 if (auto state = AudioIO::Get()
816 ->ReplaceState(project, &*mTrack, *oIndex, effectID)
817 ){
818 // Message subscription took care of updating the button text
819 // and destroyed `this`!
820 auto effect = state->GetEffect();
821 assert(effect); // postcondition of ReplaceState
823 /*i18n-hint: undo history,
824 first and second parameters - realtime effect names
825 */
826 XO("Replaced %s with %s")
827 .Format(oldName, effect->GetName()),
830 XO("Replace %s").Format(oldName));
831 }
832 }
static AudioIO * Get()
Definition: AudioIO.cpp:133
Abstract base class used in importing a file.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static RealtimeEffectManager & Get(AudacityProject &project)
PluginID ShowSelectEffectMenu(wxWindow *parent, RealtimeEffectControl *currentEffectControl=nullptr)

References AudioIO::Get(), ProjectHistory::Get(), RealtimeEffectManager::Get(), ProjectHistory::PushState(), anonymous_namespace{RealtimeEffectPanel.cpp}::ShowSelectEffectMenu(), and XO.

Here is the call graph for this function:

◆ OnFocusChange()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnFocusChange ( wxFocusEvent &  evt)
inline

Definition at line 851 of file RealtimeEffectPanel.cpp.

852 {
853 Refresh(false);
854 evt.Skip();
855 }

◆ OnOptionsClicked()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked ( wxCommandEvent &  event)
inline

TODO: effect is not available

Definition at line 776 of file RealtimeEffectPanel.cpp.

777 {
778 if(mProject == nullptr || mEffectState == nullptr)
779 return;//not initialized
780
781 const auto ID = mEffectState->GetID();
782 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
783
784 if(effectPlugin == nullptr)
785 {
787 return;
788 }
789
790 auto& effectStateUI = RealtimeEffectStateUI::Get(*mEffectState);
791
792 effectStateUI.UpdateTrackData(*mTrack);
793 effectStateUI.Toggle( *mProject );
794 }
EffectPlugin * GetEffect(const PluginID &ID)
static EffectManager & Get()
static RealtimeEffectStateUI & Get(RealtimeEffectState &state)

References EffectManager::Get(), RealtimeEffectStateUI::Get(), and EffectManager::GetEffect().

Here is the call graph for this function:

◆ OnPaint()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnPaint ( wxPaintEvent &  )
inline

Definition at line 834 of file RealtimeEffectPanel.cpp.

835 {
836 wxBufferedPaintDC dc(this);
837 const auto rect = wxRect(GetSize());
838
839 dc.SetPen(*wxTRANSPARENT_PEN);
840 dc.SetBrush(GetBackgroundColour());
841 dc.DrawRectangle(rect);
842
843 dc.SetPen(theTheme.Colour(clrEffectListItemBorder));
844 dc.SetBrush(theTheme.Colour(clrEffectListItemBorder));
845 dc.DrawLine(rect.GetBottomLeft(), rect.GetBottomRight());
846
847 if(HasFocus())
848 AColor::DrawFocus(dc, GetClientRect().Deflate(3, 3));
849 }
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:235
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), AColor::DrawFocus(), and theTheme.

Here is the call graph for this function:

◆ RemoveFromList()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::RemoveFromList ( )
inline

i18n-hint: undo history record first parameter - realtime effect name second parameter - track name

i18n-hint: undo history record first parameter - realtime effect name

Definition at line 749 of file RealtimeEffectPanel.cpp.

750 {
751 if(mProject == nullptr || mEffectState == nullptr)
752 return;
753
755 // Don't need autosave for the effect that is being removed
756 ui.Hide();
757
758 auto effectName = GetEffectName();
759 //After AudioIO::RemoveState call this will be destroyed
760 auto project = mProject.get();
761 auto trackName = mTrack->GetName();
762
769 XO("Removed %s from %s").Format(effectName, trackName),
772 XO("Remove %s").Format(effectName)
773 );
774 }
void RemoveState(AudacityProject &project, Track *pTrack, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:373

References AudioIO::Get(), ProjectHistory::Get(), RealtimeEffectStateUI::Get(), ProjectHistory::PushState(), AudioIO::RemoveState(), and XO.

Referenced by anonymous_namespace{RealtimeEffectPanel.cpp}::ShowSelectEffectMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEffect()

void anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::SetEffect ( AudacityProject project,
const std::shared_ptr< Track > &  track,
const std::shared_ptr< RealtimeEffectState > &  pState 
)
inline

Definition at line 714 of file RealtimeEffectPanel.cpp.

717 {
718 mProject = &project;
719 mTrack = track;
720 mEffectState = pState;
721
722 mSubscription = mEffectState->Subscribe([this](RealtimeEffectStateChange state) {
725 : mEnableButton->PopUp();
726
727 if (mProject)
728 ProjectHistory::Get(*mProject).ModifyState(false);
729 });
730
732 if (pState) {
734 mSettingsAccess = pState->GetAccess();
735 }
736 else
737 mSettingsAccess.reset();
738 if (mEnableButton)
739 mSettingsAccess && mSettingsAccess->Get().extra.GetActive()
741 : mEnableButton->PopUp();
742 if (mOptionsButton)
743 {
745 mOptionsButton->SetEnabled(pState && GetPlugin(pState->GetID()));
746 }
747 }
RealtimeEffectStateChange
TranslatableString label
Definition: TagsEditor.cpp:163
void PushDown()
Definition: AButton.cpp:642
void PopUp()
Definition: AButton.cpp:650
void SetEnabled(bool state)
Definition: AButton.h:104
void ModifyState(bool bWantsAutoSave)
void SetTranslatableLabel(TranslatableString label)
Holds a msgid for the translation catalog; may also bind format arguments.

References EffectOn, ProjectHistory::Get(), label, and ProjectHistory::ModifyState().

Here is the call graph for this function:

Member Data Documentation

◆ mChangeButton

ThemedAButtonWrapper<AButton>* anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mChangeButton {nullptr}
private

Definition at line 614 of file RealtimeEffectPanel.cpp.

◆ mEffectState

std::shared_ptr<RealtimeEffectState> anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mEffectState
private

Definition at line 611 of file RealtimeEffectPanel.cpp.

◆ mEnableButton

AButton* anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mEnableButton {nullptr}
private

Definition at line 615 of file RealtimeEffectPanel.cpp.

◆ mOptionsButton

ThemedAButtonWrapper<AButton>* anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mOptionsButton {}
private

Definition at line 616 of file RealtimeEffectPanel.cpp.

◆ mProject

wxWeakRef<AudacityProject> anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mProject
private

Definition at line 609 of file RealtimeEffectPanel.cpp.

◆ mSettingsAccess

std::shared_ptr<EffectSettingsAccess> anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mSettingsAccess
private

Definition at line 612 of file RealtimeEffectPanel.cpp.

◆ mSubscription

Observer::Subscription anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mSubscription
private

Definition at line 618 of file RealtimeEffectPanel.cpp.

◆ mTrack

std::shared_ptr<Track> anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mTrack
private

Definition at line 610 of file RealtimeEffectPanel.cpp.


The documentation for this class was generated from the following file: