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< SampleTrack > &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< SampleTrackmTrack
 
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 288 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 306 of file RealtimeEffectPanel.cpp.

311 {
312 Create(parent, effectPicker, winid, pos, size);
313 }
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 315 of file RealtimeEffectPanel.cpp.

320 {
321 mEffectPicker = effectPicker;
322
323 //Prevents flickering and paint order issues
324 MovableControl::SetBackgroundStyle(wxBG_STYLE_PAINT);
325 MovableControl::Create(parent, winid, pos, size, wxNO_BORDER | wxWANTS_CHARS);
326
327 Bind(wxEVT_PAINT, &RealtimeEffectControl::OnPaint, this);
328 Bind(wxEVT_SET_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
329 Bind(wxEVT_KILL_FOCUS, &RealtimeEffectControl::OnFocusChange, this);
330
331 auto sizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
332
333 //On/off button
334 auto enableButton = safenew ThemedAButtonWrapper<AButton>(this);
335 enableButton->SetTranslatableLabel(XO("Power"));
336 enableButton->SetImageIndices(0, bmpEffectOff, bmpEffectOff, bmpEffectOn, bmpEffectOn, bmpEffectOff);
337 enableButton->SetButtonToggles(true);
338 enableButton->SetBackgroundColorIndex(clrEffectListItemBackground);
339 mEnableButton = enableButton;
340
341 enableButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
342
343 mEffectState->SetActive(mEnableButton->IsDown());
344 if (mProject)
345 UndoManager::Get(*mProject).MarkUnsaved();
346 });
347
348 //Central button with effect name, show settings
349 const auto optionsButton = safenew ThemedAButtonWrapper<AButton>(this, wxID_ANY);
350 optionsButton->SetImageIndices(0,
351 bmpHButtonNormal,
352 bmpHButtonHover,
353 bmpHButtonDown,
354 bmpHButtonHover,
355 bmpHButtonDisabled);
356 optionsButton->SetBackgroundColorIndex(clrEffectListItemBackground);
357 optionsButton->SetForegroundColorIndex(clrTrackPanelText);
358 optionsButton->SetButtonType(AButton::TextButton);
359 optionsButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnOptionsClicked, this);
360
361 //Remove/replace effect
362 auto changeButton = safenew ThemedAButtonWrapper<AButton>(this);
363 changeButton->SetImageIndices(0, bmpMoreNormal, bmpMoreHover, bmpMoreDown, bmpMoreHover, bmpMoreDisabled);
364 changeButton->SetBackgroundColorIndex(clrEffectListItemBackground);
365 changeButton->SetTranslatableLabel(XO("Replace effect"));
366 changeButton->Bind(wxEVT_BUTTON, &RealtimeEffectControl::OnChangeButtonClicked, this);
367
368 auto dragArea = safenew wxStaticBitmap(this, wxID_ANY, theTheme.Bitmap(bmpDragArea));
369 dragArea->Disable();
370 sizer->Add(dragArea, 0, wxLEFT | wxCENTER, 5);
371 sizer->Add(enableButton, 0, wxLEFT | wxCENTER, 5);
372 sizer->Add(optionsButton, 1, wxLEFT | wxCENTER, 5);
373 sizer->Add(changeButton, 0, wxLEFT | wxRIGHT | wxCENTER, 5);
374 mChangeButton = changeButton;
375 mOptionsButton = optionsButton;
376
377 auto vSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
378 vSizer->Add(sizer.release(), 0, wxUP | wxDOWN | wxEXPAND, 10);
379
380 SetSizer(vSizer.release());
381
382#if wxUSE_ACCESSIBILITY
383 SetAccessible(safenew RealtimeEffectControlAx(this));
384#endif
385 }
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:9
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)
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:71
void MarkUnsaved()

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

394 {
395 const auto &ID = mEffectState->GetID();
396 const auto desc = GetPlugin(ID);
397 return desc
398 ? desc->GetSymbol().Msgid()
399 : XO("%s (missing)")
400 .Format(PluginManager::GetEffectNameFromID(ID).GET());
401 }
static Identifier GetEffectNameFromID(const PluginID &ID)
static const PluginDescriptor * GetPlugin(const PluginID &ID)
const TranslatableString desc
Definition: ExportPCM.cpp:51

References anonymous_namespace{ExportPCM.cpp}::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 387 of file RealtimeEffectPanel.cpp.

387 {
388 auto desc = PluginManager::Get().GetPlugin(ID);
389 return desc;
390 }
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()

References anonymous_namespace{ExportPCM.cpp}::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 485 of file RealtimeEffectPanel.cpp.

486 {
487 if(!mTrack || mProject == nullptr)
488 return;
489 if(mEffectState == nullptr)
490 return;//not initialized
491
492 const auto effectID = mEffectPicker->PickEffect(mChangeButton, mEffectState->GetID());
493 if(!effectID)
494 return;//nothing
495
496 if(effectID->empty())
497 {
499 return;
500 }
501
503 auto oIndex = em.FindState(&*mTrack, mEffectState);
504 if (!oIndex)
505 return;
506
507 auto oldName = GetEffectName();
508 auto &project = *mProject;
509 auto trackName = mTrack->GetName();
510 if (auto state = AudioIO::Get()
511 ->ReplaceState(project, &*mTrack, *oIndex, *effectID)
512 ){
513 // Message subscription took care of updating the button text
514 // and destroyed `this`!
515 auto effect = state->GetEffect();
516 assert(effect); // postcondition of ReplaceState
518 /*i18n-hint: undo history,
519 first and second parameters - realtime effect names
520 */
521 XO("Replaced %s with %s")
522 .Format(oldName, effect->GetName()),
525 XO("Replace %s").Format(oldName));
526 }
527 }
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 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(), 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 546 of file RealtimeEffectPanel.cpp.

547 {
548 Refresh(false);
549 evt.Skip();
550 }

◆ OnOptionsClicked()

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

TODO: effect is not available

Definition at line 465 of file RealtimeEffectPanel.cpp.

466 {
467 if(mProject == nullptr || mEffectState == nullptr)
468 return;//not initialized
469
470 const auto ID = mEffectState->GetID();
471 const auto effectPlugin = EffectManager::Get().GetEffect(ID);
472
473 if(effectPlugin == nullptr)
474 {
476 return;
477 }
478
479 auto& effectStateUI = RealtimeEffectStateUI::Get(*mEffectState);
480
481 effectStateUI.UpdateTrackData(*mTrack);
482 effectStateUI.Toggle( *mProject );
483 }
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 529 of file RealtimeEffectPanel.cpp.

530 {
531 wxBufferedPaintDC dc(this);
532 const auto rect = wxRect(GetSize());
533
534 dc.SetPen(*wxTRANSPARENT_PEN);
535 dc.SetBrush(GetBackgroundColour());
536 dc.DrawRectangle(rect);
537
538 dc.SetPen(theTheme.Colour(clrEffectListItemBorder));
539 dc.SetBrush(theTheme.Colour(clrEffectListItemBorder));
540 dc.DrawLine(rect.GetBottomLeft(), rect.GetBottomRight());
541
542 if(HasFocus())
543 AColor::DrawFocus(dc, GetClientRect().Deflate(3, 3));
544 }
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 438 of file RealtimeEffectPanel.cpp.

439 {
440 if(mProject == nullptr || mEffectState == nullptr)
441 return;
442
444 // Don't need autosave for the effect that is being removed
445 ui.Hide();
446
447 auto effectName = GetEffectName();
448 //After AudioIO::RemoveState call this will be destroyed
449 auto project = mProject.get();
450 auto trackName = mTrack->GetName();
451
458 XO("Removed %s from %s").Format(effectName, trackName),
461 XO("Remove %s").Format(effectName)
462 );
463 }
void RemoveState(AudacityProject &project, ChannelGroup *pGroup, std::shared_ptr< RealtimeEffectState > pState)
Forwards to RealtimeEffectManager::RemoveState with proper init scope.
Definition: AudioIO.cpp:371

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

Definition at line 403 of file RealtimeEffectPanel.cpp.

406 {
407 mProject = &project;
408 mTrack = track;
409 mEffectState = pState;
410
411 mSubscription = mEffectState->Subscribe([this](RealtimeEffectStateChange state) {
414 : mEnableButton->PopUp();
415
416 if (mProject)
417 ProjectHistory::Get(*mProject).ModifyState(false);
418 });
419
421 if (pState) {
423 mSettingsAccess = pState->GetAccess();
424 }
425 else
426 mSettingsAccess.reset();
427 if (mEnableButton)
428 mSettingsAccess && mSettingsAccess->Get().extra.GetActive()
430 : mEnableButton->PopUp();
431 if (mOptionsButton)
432 {
434 mOptionsButton->SetEnabled(pState && GetPlugin(pState->GetID()));
435 }
436 }
RealtimeEffectStateChange
TranslatableString label
Definition: TagsEditor.cpp:165
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, ProjectHistory::ModifyState(), 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 297 of file RealtimeEffectPanel.cpp.

◆ mEffectPicker

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

Definition at line 295 of file RealtimeEffectPanel.cpp.

◆ mEffectState

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

Definition at line 292 of file RealtimeEffectPanel.cpp.

◆ mEnableButton

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

Definition at line 298 of file RealtimeEffectPanel.cpp.

◆ mOptionsButton

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

Definition at line 299 of file RealtimeEffectPanel.cpp.

◆ mProject

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

Definition at line 290 of file RealtimeEffectPanel.cpp.

◆ mSettingsAccess

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

Definition at line 293 of file RealtimeEffectPanel.cpp.

◆ mSubscription

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

Definition at line 301 of file RealtimeEffectPanel.cpp.

◆ mTrack

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

Definition at line 291 of file RealtimeEffectPanel.cpp.


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