Audacity 3.2.0
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)
 
void SetEffect (AudacityProject &project, const std::shared_ptr< EffectListUIDelegate > &delegate, 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 ListNavigationEnabled< MovableControl >
 ListNavigationEnabled ()
 
void SetInTabOrder (bool inTabOrder)
 

Private Attributes

wxWeakRef< AudacityProjectmProject
 
std::shared_ptr< EffectListUIDelegatemDelegate
 
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 443 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 460 of file RealtimeEffectPanel.cpp.

464 {
465 Create(parent, winid, pos, size);
466 }
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 468 of file RealtimeEffectPanel.cpp.

472 {
473
474 //Prevents flickering and paint order issues
475 MovableControl::SetBackgroundStyle(wxBG_STYLE_PAINT);
476 MovableControl::Create(parent, winid, pos, size, wxNO_BORDER | wxWANTS_CHARS);
477
478 Bind(wxEVT_PAINT, &RealtimeEffectControl::OnPaint, this);
479 Bind(wxEVT_SET_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
480 Bind(wxEVT_KILL_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
481
482 auto sizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
483
484 //On/off button
485 auto enableButton = safenew ThemedAButtonWrapper<AButton>(this);
486 enableButton->SetTranslatableLabel(XO("Power"));
487 enableButton->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
488 enableButton->SetButtonToggles(true);
489 enableButton->SetBackgroundColorIndex(clrEffectListItemBackground);
490 mEnableButton = enableButton;
491
492 enableButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
494 {
495 mEffectState->SetActive(mEnableButton->IsDown());
496 if (mProject)
497 {
498 ProjectHistory::Get(*mProject).ModifyState(false);
499 UndoManager::Get(*mProject).MarkUnsaved();
500 }
501 }
502 });
503
504 //Central button with effect name, show settings
505 const auto optionsButton = safenew ThemedAButtonWrapper<AButton>(this, wxID_ANY);
506 optionsButton->SetImageIndices(0,
507 bmpHButtonNormal,
508 bmpHButtonHover,
509 bmpHButtonDown,
510 bmpHButtonHover,
511 bmpHButtonDisabled);
512 optionsButton->SetBackgroundColorIndex(clrEffectListItemBackground);
513 optionsButton->SetForegroundColorIndex(clrTrackPanelText);
514 optionsButton->SetButtonType(AButton::TextButton);
515 optionsButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnOptionsClicked, this);
516
517 //Remove/replace effect
518 auto changeButton = safenew ThemedAButtonWrapper<AButton>(this);
519 changeButton->SetImageIndices(0, bmpMoreNormal, bmpMoreHover, bmpMoreDown, bmpMoreHover, bmpMoreDisabled);
520 changeButton->SetBackgroundColorIndex(clrEffectListItemBackground);
521 changeButton->SetTranslatableLabel(XO("Replace effect"));
522 changeButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnChangeButtonClicked, this);
523
524 auto dragArea = safenew wxStaticBitmap(this, wxID_ANY, theTheme.Bitmap(bmpDragArea));
525 dragArea->Disable();
526 sizer->Add(dragArea, 0, wxLEFT | wxCENTER, 5);
527 sizer->Add(enableButton, 0, wxLEFT | wxCENTER, 5);
528 sizer->Add(optionsButton, 1, wxLEFT | wxCENTER, 5);
529 sizer->Add(changeButton, 0, wxLEFT | wxRIGHT | wxCENTER, 5);
530 mChangeButton = changeButton;
531 mOptionsButton = optionsButton;
532
533 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
534 vSizer->Add(sizer.release(), 0, wxUP | wxDOWN | wxEXPAND, 10);
535
536 SetSizer(vSizer.release());
537
538 SetInTabOrder(false);
539
540#if wxUSE_ACCESSIBILITY
541 SetAccessible(safenew RealtimeEffectControlAx(this));
542#endif
543 }
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
bool IsDown()
Definition: AButton.h:227
@ TextButton
Definition: AButton.h:112
void Create(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
wxBitmap & Bitmap(int iIndex)
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
void MarkUnsaved()

References ThemeBase::Bitmap(), MovableControl::Create(), ProjectHistory::Get(), UndoManager::Get(), UndoManager::MarkUnsaved(), ProjectHistory::ModifyState(), safenew, size, AButton::TextButton, theTheme, and XO().

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 624 of file RealtimeEffectPanel.cpp.

625 {
626 if(!mDelegate || mProject == nullptr)
627 return;
628
629 if(mEffectState == nullptr)
630 return;//not initialized
631
632 const auto effectID = EffectsMenuHelper::PickEffect(
633 *mProject,
635 mEffectState->GetID()
636 );
637 if(!effectID)
638 return;//nothing
639
640 if(effectID->empty())
642 else
643 {
644 auto &project = *mProject;
646 auto oIndex = em.FindState(mDelegate->GetChannelGroup(), mEffectState);
647 if (!oIndex)
648 return;
649
650 auto oldName = GetEffectName(*mEffectState);
651
652 if (auto state = AudioIO::Get()
653 ->ReplaceState(project, mDelegate->GetChannelGroup(), *oIndex, *effectID)
654 ){
655 // Message subscription took care of updating the button text
656 // and destroyed `this`!
657 auto effect = state->GetEffect();
658 assert(effect); // postcondition of ReplaceState
660 /*i18n-hint: undo history,
661 first and second parameters - realtime effect names
662 */
663 XO("Replaced %s with %s")
664 .Format(oldName, effect->GetName()),
667 XO("Replace %s").Format(oldName));
668 }
669 }
670 }
const auto project
static AudioIO * Get()
Definition: AudioIO.cpp:126
Abstract base class used in importing a file.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static RealtimeEffectManager & Get(AudacityProject &project)
static std::optional< wxString > PickEffect(AudacityProject &project, wxWindow *parent, const wxString &selectedEffectID)
TranslatableString GetEffectName(RealtimeEffectState &state)

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

Here is the call graph for this function:

◆ OnFocusChange()

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

Definition at line 689 of file RealtimeEffectPanel.cpp.

690 {
691 Refresh(false);
692 evt.Skip();
693 }

◆ OnOptionsClicked()

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

TODO: effect is not available

Definition at line 602 of file RealtimeEffectPanel.cpp.

603 {
604 if(!mDelegate || !mEffectState)
605 return;//not initialized
606
607 const auto ID = mEffectState->GetID();
608 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
609
610 if(effectPlugin == nullptr)
611 {
613 return;
614 }
615
616 if(!mProject)
617 return;
618 auto& effectStateUI = RealtimeEffectStateUI::Get(*mEffectState);
619
620 effectStateUI.SetTargetName(mDelegate->GetSourceName());
621 effectStateUI.Toggle(*mProject);
622 }
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 672 of file RealtimeEffectPanel.cpp.

673 {
674 wxBufferedPaintDC dc(this);
675 const auto rect = wxRect(GetSize());
676
677 dc.SetPen(*wxTRANSPARENT_PEN);
678 dc.SetBrush(GetBackgroundColour());
679 dc.DrawRectangle(rect);
680
681 dc.SetPen(theTheme.Colour(clrEffectListItemBorder));
682 dc.SetBrush(theTheme.Colour(clrEffectListItemBorder));
683 dc.DrawLine(rect.GetBottomLeft(), rect.GetBottomRight());
684
685 if(HasFocus())
686 AColor::DrawFocus(dc, GetClientRect().Deflate(3, 3));
687 }
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:247
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 577 of file RealtimeEffectPanel.cpp.

578 {
579 if(!mDelegate || !mProject || mEffectState == nullptr)
580 return;
581
583 // Don't need autosave for the effect that is being removed
584 ui.Hide();
585
586 //After AudioIO::RemoveState call this will be destroyed
587 auto effectName = GetEffectName(*mEffectState);
588
589 AudioIO::Get()->RemoveState(*mProject, mDelegate->GetChannelGroup(), std::move(mEffectState));
595 XO("Removed %s from %s").Format(effectName, mDelegate->GetSourceName()),
598 XO("Remove %s").Format(effectName)
599 );
600 }
void RemoveState(AudacityProject &project, ChannelGroup *pGroup, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:369

References AudioIO::Get(), ProjectHistory::Get(), RealtimeEffectStateUI::Get(), anonymous_namespace{RealtimeEffectPanel.cpp}::GetEffectName(), ProjectHistory::PushState(), AudioIO::RemoveState(), and XO().

Here is the call graph for this function:

◆ SetEffect()

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

Definition at line 545 of file RealtimeEffectPanel.cpp.

548 {
549 mProject = &project;
550 mDelegate = delegate;
551 mEffectState = pState;
552
553 mSubscription = mEffectState->Subscribe([this](RealtimeEffectStateChange state) {
556 : mEnableButton->PopUp();
557 });
558
560 if (pState) {
562 mSettingsAccess = pState->GetAccess();
563 }
564 else
565 mSettingsAccess.reset();
566 if (mEnableButton)
567 mSettingsAccess && mSettingsAccess->Get().extra.GetActive()
569 : mEnableButton->PopUp();
570 if (mOptionsButton)
571 {
573 mOptionsButton->SetEnabled(pState && GetPlugin(pState->GetID()));
574 }
575 }
RealtimeEffectStateChange
TranslatableString label
Definition: TagsEditor.cpp:165
void PushDown()
Definition: AButton.cpp:664
void PopUp()
Definition: AButton.cpp:672
void SetEnabled(bool state)
Definition: AButton.h:201
void SetTranslatableLabel(TranslatableString label)
Holds a msgid for the translation catalog; may also bind format arguments.
const PluginDescriptor * GetPlugin(const PluginID &ID)

References EffectOn, anonymous_namespace{RealtimeEffectPanel.cpp}::GetEffectName(), anonymous_namespace{RealtimeEffectPanel.cpp}::GetPlugin(), label, and project.

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 451 of file RealtimeEffectPanel.cpp.

◆ mDelegate

std::shared_ptr<EffectListUIDelegate> anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mDelegate
private

Definition at line 446 of file RealtimeEffectPanel.cpp.

◆ mEffectState

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

Definition at line 448 of file RealtimeEffectPanel.cpp.

◆ mEnableButton

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

Definition at line 452 of file RealtimeEffectPanel.cpp.

◆ mOptionsButton

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

Definition at line 453 of file RealtimeEffectPanel.cpp.

◆ mProject

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

Definition at line 445 of file RealtimeEffectPanel.cpp.

◆ mSettingsAccess

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

Definition at line 449 of file RealtimeEffectPanel.cpp.

◆ mSubscription

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

Definition at line 455 of file RealtimeEffectPanel.cpp.


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