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

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

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

393 {
394 const auto &ID = mEffectState->GetID();
395 const auto desc = GetPlugin(ID);
396 return desc
397 ? desc->GetSymbol().Msgid()
398 : XO("%s (missing)")
399 .Format(PluginManager::GetEffectNameFromID(ID).GET());
400 }
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 386 of file RealtimeEffectPanel.cpp.

386 {
387 auto desc = PluginManager::Get().GetPlugin(ID);
388 return desc;
389 }
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 484 of file RealtimeEffectPanel.cpp.

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

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

◆ OnOptionsClicked()

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

TODO: effect is not available

Definition at line 464 of file RealtimeEffectPanel.cpp.

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

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

438 {
439 if(mProject == nullptr || mEffectState == nullptr)
440 return;
441
443 // Don't need autosave for the effect that is being removed
444 ui.Hide();
445
446 auto effectName = GetEffectName();
447 //After AudioIO::RemoveState call this will be destroyed
448 auto project = mProject.get();
449 auto trackName = mTrack->GetName();
450
457 XO("Removed %s from %s").Format(effectName, trackName),
460 XO("Remove %s").Format(effectName)
461 );
462 }
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(), 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 402 of file RealtimeEffectPanel.cpp.

405 {
406 mProject = &project;
407 mTrack = track;
408 mEffectState = pState;
409
410 mSubscription = mEffectState->Subscribe([this](RealtimeEffectStateChange state) {
413 : mEnableButton->PopUp();
414
415 if (mProject)
416 ProjectHistory::Get(*mProject).ModifyState(false);
417 });
418
420 if (pState) {
422 mSettingsAccess = pState->GetAccess();
423 }
424 else
425 mSettingsAccess.reset();
426 if (mEnableButton)
427 mSettingsAccess && mSettingsAccess->Get().extra.GetActive()
429 : mEnableButton->PopUp();
430 if (mOptionsButton)
431 {
433 mOptionsButton->SetEnabled(pState && GetPlugin(pState->GetID()));
434 }
435 }
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 296 of file RealtimeEffectPanel.cpp.

◆ mEffectPicker

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

Definition at line 294 of file RealtimeEffectPanel.cpp.

◆ mEffectState

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

Definition at line 291 of file RealtimeEffectPanel.cpp.

◆ mEnableButton

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

Definition at line 297 of file RealtimeEffectPanel.cpp.

◆ mOptionsButton

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

Definition at line 298 of file RealtimeEffectPanel.cpp.

◆ mProject

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

Definition at line 289 of file RealtimeEffectPanel.cpp.

◆ mSettingsAccess

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

Definition at line 292 of file RealtimeEffectPanel.cpp.

◆ mSubscription

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

Definition at line 300 of file RealtimeEffectPanel.cpp.

◆ mTrack

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

Definition at line 290 of file RealtimeEffectPanel.cpp.


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