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, RealtimeEffectPicker *effectPicker, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
void Create (wxWindow *parent, RealtimeEffectPicker *effectPicker, 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 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
 
RealtimeEffectPickermEffectPicker { nullptr }
 
ThemedAButtonWrapper< AButton > * mChangeButton {nullptr}
 
AButtonmEnableButton {nullptr}
 
ThemedAButtonWrapper< AButton > * mOptionsButton {}
 
Observer::Subscription mSubscription
 

Detailed Description

Definition at line 304 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,
RealtimeEffectPicker effectPicker,
wxWindowID  winid,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
inline

Definition at line 322 of file RealtimeEffectPanel.cpp.

327 {
328 Create(parent, effectPicker, winid, pos, size);
329 }
void Create(wxWindow *parent, RealtimeEffectPicker *effectPicker, 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,
RealtimeEffectPicker effectPicker,
wxWindowID  winid,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
inline

Definition at line 331 of file RealtimeEffectPanel.cpp.

336 {
337 mEffectPicker = effectPicker;
338
339 //Prevents flickering and paint order issues
340 MovableControl::SetBackgroundStyle(wxBG_STYLE_PAINT);
341 MovableControl::Create(parent, winid, pos, size, wxNO_BORDER | wxWANTS_CHARS);
342
343 Bind(wxEVT_PAINT, &RealtimeEffectControl::OnPaint, this);
344 Bind(wxEVT_SET_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
345 Bind(wxEVT_KILL_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
346
347 auto sizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
348
349 //On/off button
350 auto enableButton = safenew ThemedAButtonWrapper<AButton>(this);
351 enableButton->SetTranslatableLabel(XO("Power"));
352 enableButton->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
353 enableButton->SetButtonToggles(true);
354 enableButton->SetBackgroundColorIndex(clrEffectListItemBackground);
355 mEnableButton = enableButton;
356
357 enableButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
358
359 mEffectState->SetActive(mEnableButton->IsDown());
360 });
361
362 //Central button with effect name, show settings
363 const auto optionsButton = safenew ThemedAButtonWrapper<AButton>(this, wxID_ANY);
364 optionsButton->SetImageIndices(0,
365 bmpHButtonNormal,
366 bmpHButtonHover,
367 bmpHButtonDown,
368 bmpHButtonHover,
369 bmpHButtonDisabled);
370 optionsButton->SetBackgroundColorIndex(clrEffectListItemBackground);
371 optionsButton->SetForegroundColorIndex(clrTrackPanelText);
372 optionsButton->SetButtonType(AButton::TextButton);
373 optionsButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnOptionsClicked, this);
374
375 //Remove/replace effect
376 auto changeButton = safenew ThemedAButtonWrapper<AButton>(this);
377 changeButton->SetImageIndices(0, bmpMoreNormal, bmpMoreHover, bmpMoreDown, bmpMoreHover, bmpMoreDisabled);
378 changeButton->SetBackgroundColorIndex(clrEffectListItemBackground);
379 changeButton->SetTranslatableLabel(XO("Replace effect"));
380 changeButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnChangeButtonClicked, this);
381
382 auto dragArea = safenew wxStaticBitmap(this, wxID_ANY, theTheme.Bitmap(bmpDragArea));
383 dragArea->Disable();
384 sizer->Add(dragArea, 0, wxLEFT | wxCENTER, 5);
385 sizer->Add(enableButton, 0, wxLEFT | wxCENTER, 5);
386 sizer->Add(optionsButton, 1, wxLEFT | wxCENTER, 5);
387 sizer->Add(changeButton, 0, wxLEFT | wxRIGHT | wxCENTER, 5);
388 mChangeButton = changeButton;
389 mOptionsButton = optionsButton;
390
391 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
392 vSizer->Add(sizer.release(), 0, wxUP | wxDOWN | wxEXPAND, 10);
393
394 SetSizer(vSizer.release());
395
396#if wxUSE_ACCESSIBILITY
397 SetAccessible(safenew RealtimeEffectControlAx(this));
398#endif
399 }
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
bool IsDown()
Definition: AButton.h:208
@ 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)
wxBitmap & Bitmap(int iIndex)

References ThemeBase::Bitmap(), MovableControl::Create(), 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 407 of file RealtimeEffectPanel.cpp.

408 {
409 const auto &ID = mEffectState->GetID();
410 const auto desc = GetPlugin(ID);
411 return desc
412 ? desc->GetSymbol().Msgid()
413 : XO("%s (missing)")
414 .Format(PluginManager::GetEffectNameFromID(ID).GET());
415 }
const TranslatableString desc
Definition: ExportPCM.cpp:55
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 401 of file RealtimeEffectPanel.cpp.

401 {
402 auto desc = PluginManager::Get().GetPlugin(ID);
403 return desc;
404 }
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 499 of file RealtimeEffectPanel.cpp.

500 {
501 if(!mTrack || mProject == nullptr)
502 return;
503 if(mEffectState == nullptr)
504 return;//not initialized
505
506 const auto effectID = mEffectPicker->PickEffect(mChangeButton, mEffectState->GetID());
507 if(!effectID)
508 return;//nothing
509
510 if(effectID->empty())
511 {
513 return;
514 }
515
517 auto oIndex = em.FindState(&*mTrack, mEffectState);
518 if (!oIndex)
519 return;
520
521 auto oldName = GetEffectName();
522 auto &project = *mProject;
523 auto trackName = mTrack->GetName();
524 if (auto state = AudioIO::Get()
525 ->ReplaceState(project, &*mTrack, *oIndex, *effectID)
526 ){
527 // Message subscription took care of updating the button text
528 // and destroyed `this`!
529 auto effect = state->GetEffect();
530 assert(effect); // postcondition of ReplaceState
532 /*i18n-hint: undo history,
533 first and second parameters - realtime effect names
534 */
535 XO("Replaced %s with %s")
536 .Format(oldName, effect->GetName()),
539 XO("Replace %s").Format(oldName));
540 }
541 }
static AudioIO * Get()
Definition: AudioIO.cpp:147
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)
virtual std::optional< wxString > PickEffect(wxWindow *parent, const wxString &selectedEffectID)=0

References AudioIO::Get(), ProjectHistory::Get(), RealtimeEffectManager::Get(), 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 560 of file RealtimeEffectPanel.cpp.

561 {
562 Refresh(false);
563 evt.Skip();
564 }

◆ OnOptionsClicked()

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

TODO: effect is not available

Definition at line 479 of file RealtimeEffectPanel.cpp.

480 {
481 if(mProject == nullptr || mEffectState == nullptr)
482 return;//not initialized
483
484 const auto ID = mEffectState->GetID();
485 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
486
487 if(effectPlugin == nullptr)
488 {
490 return;
491 }
492
493 auto& effectStateUI = RealtimeEffectStateUI::Get(*mEffectState);
494
495 effectStateUI.UpdateTrackData(*mTrack);
496 effectStateUI.Toggle( *mProject );
497 }
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 543 of file RealtimeEffectPanel.cpp.

544 {
545 wxBufferedPaintDC dc(this);
546 const auto rect = wxRect(GetSize());
547
548 dc.SetPen(*wxTRANSPARENT_PEN);
549 dc.SetBrush(GetBackgroundColour());
550 dc.DrawRectangle(rect);
551
552 dc.SetPen(theTheme.Colour(clrEffectListItemBorder));
553 dc.SetBrush(theTheme.Colour(clrEffectListItemBorder));
554 dc.DrawLine(rect.GetBottomLeft(), rect.GetBottomRight());
555
556 if(HasFocus())
557 AColor::DrawFocus(dc, GetClientRect().Deflate(3, 3));
558 }
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 452 of file RealtimeEffectPanel.cpp.

453 {
454 if(mProject == nullptr || mEffectState == nullptr)
455 return;
456
458 // Don't need autosave for the effect that is being removed
459 ui.Hide();
460
461 auto effectName = GetEffectName();
462 //After AudioIO::RemoveState call this will be destroyed
463 auto project = mProject.get();
464 auto trackName = mTrack->GetName();
465
472 XO("Removed %s from %s").Format(effectName, trackName),
475 XO("Remove %s").Format(effectName)
476 );
477 }
void RemoveState(AudacityProject &project, Track *pTrack, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:390

References AudioIO::Get(), ProjectHistory::Get(), RealtimeEffectStateUI::Get(), 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< Track > &  track,
const std::shared_ptr< RealtimeEffectState > &  pState 
)
inline

Definition at line 417 of file RealtimeEffectPanel.cpp.

420 {
421 mProject = &project;
422 mTrack = track;
423 mEffectState = pState;
424
425 mSubscription = mEffectState->Subscribe([this](RealtimeEffectStateChange state) {
428 : mEnableButton->PopUp();
429
430 if (mProject)
431 ProjectHistory::Get(*mProject).ModifyState(false);
432 });
433
435 if (pState) {
437 mSettingsAccess = pState->GetAccess();
438 }
439 else
440 mSettingsAccess.reset();
441 if (mEnableButton)
442 mSettingsAccess && mSettingsAccess->Get().extra.GetActive()
444 : mEnableButton->PopUp();
445 if (mOptionsButton)
446 {
448 mOptionsButton->SetEnabled(pState && GetPlugin(pState->GetID()));
449 }
450 }
RealtimeEffectStateChange
TranslatableString label
Definition: TagsEditor.cpp:164
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585
void SetEnabled(bool state)
Definition: AButton.h:182
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 313 of file RealtimeEffectPanel.cpp.

◆ mEffectPicker

RealtimeEffectPicker* anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::mEffectPicker { nullptr }
private

Definition at line 311 of file RealtimeEffectPanel.cpp.

◆ mEffectState

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

Definition at line 308 of file RealtimeEffectPanel.cpp.

◆ mEnableButton

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

Definition at line 314 of file RealtimeEffectPanel.cpp.

◆ mOptionsButton

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

Definition at line 315 of file RealtimeEffectPanel.cpp.

◆ mProject

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

Definition at line 306 of file RealtimeEffectPanel.cpp.

◆ mSettingsAccess

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

Definition at line 309 of file RealtimeEffectPanel.cpp.

◆ mSubscription

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

Definition at line 317 of file RealtimeEffectPanel.cpp.

◆ mTrack

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

Definition at line 307 of file RealtimeEffectPanel.cpp.


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