Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
AudioUnitEffectImportDialog Class Referencefinal
Inheritance diagram for AudioUnitEffectImportDialog:
[legend]
Collaboration diagram for AudioUnitEffectImportDialog:
[legend]

Public Member Functions

 AudioUnitEffectImportDialog (wxWindow *parent, AudioUnitEffect *effect)
 
virtual ~AudioUnitEffectImportDialog ()
 
void PopulateOrExchange (ShuttleGui &S)
 
bool HasPresets ()
 
TranslatableString Import (const wxString &path, const wxString &name)
 
void OnOk (wxCommandEvent &evt)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Attributes

wxWindow * mParent
 
AudioUnitEffectmEffect
 
wxListCtrl * mList
 

Detailed Description

Definition at line 578 of file AudioUnitEffect.cpp.

Constructor & Destructor Documentation

◆ AudioUnitEffectImportDialog()

AudioUnitEffectImportDialog::AudioUnitEffectImportDialog ( wxWindow *  parent,
AudioUnitEffect effect 
)

Definition at line 603 of file AudioUnitEffect.cpp.

604: wxDialogWrapper(parent, wxID_ANY, XO("Import Audio Unit Presets"))
605{
606 mEffect = effect;
607
608 ShuttleGui S(this, eIsCreating);
610}
#define XO(s)
Definition: Internat.h:31
@ eIsCreating
Definition: ShuttleGui.h:39
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631

References eIsCreating, and S.

◆ ~AudioUnitEffectImportDialog()

AudioUnitEffectImportDialog::~AudioUnitEffectImportDialog ( )
virtual

Definition at line 612 of file AudioUnitEffect.cpp.

613{
614}

Member Function Documentation

◆ HasPresets()

bool AudioUnitEffectImportDialog::HasPresets ( )

Definition at line 686 of file AudioUnitEffect.cpp.

687{
688 return mList->GetItemCount() > 0;
689}

References mList.

◆ Import()

TranslatableString AudioUnitEffectImportDialog::Import ( const wxString &  path,
const wxString &  name 
)

Definition at line 691 of file AudioUnitEffect.cpp.

693{
694 // Generate the path
695 wxString fullPath;
696 fullPath.Printf(wxT("%s/%s.aupreset"),
697 path,
698 name);
699
700 // Open the preset
701 wxFFile f(fullPath, wxT("r"));
702 if (!f.IsOpened())
703 {
704 return XO("Couldn't open \"%s\"").Format(fullPath);
705 }
706
707 // Load it into the buffer
708 size_t len = f.Length();
709 wxMemoryBuffer buf(len);
710 if (f.Read(buf.GetData(), len) != len || f.Error())
711 {
712 return XO("Unable to read the preset from \"%s\"").Format(fullPath);
713 }
714
716 fullPath, buf.GetData(), len, false);
717}
const TranslatableString name
Definition: Distortion.cpp:82
RegistryPath UserPresetsGroup(const RegistryPath &name)
Compute part of a registry path, given a name which may be empty.
TranslatableString SaveBlobToConfig(const RegistryPath &group, const wxString &path, const void *blob, size_t len, bool allowEmpty=true) const

References mEffect, name, AudioUnitEffect::SaveBlobToConfig(), UserPresetsGroup(), and XO.

Referenced by OnOk().

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

◆ OnOk()

void AudioUnitEffectImportDialog::OnOk ( wxCommandEvent &  evt)

Definition at line 734 of file AudioUnitEffect.cpp.

735{
736 evt.Skip();
737
738 // Import all selected presets
739 long sel = -1;
740 while ((sel = mList->GetNextItem(sel, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) >= 0)
741 {
742 wxListItem item;
743 item.SetId(sel);
744 item.SetColumn(1);
745 item.SetMask(wxLIST_MASK_TEXT);
746 mList->GetItem(item);
747
748 wxString path = item.GetText();
749 wxString name = mList->GetItemText(sel);
750 auto msg = Import(path, name);
751
752 if (!msg.empty())
753 {
755 XO("Could not import \"%s\" preset\n\n%s").Format(name, msg),
756 XO("Import Audio Unit Presets"),
757 wxOK | wxCENTRE,
758 this);
759 return;
760 }
761 }
762
763 EndModal(wxID_OK);
764}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
TranslatableString Import(const wxString &path, const wxString &name)
Abstract base class used in importing a file.

References AudacityMessageBox(), Import(), mList, name, and XO.

Here is the call graph for this function:

◆ PopulateOrExchange()

void AudioUnitEffectImportDialog::PopulateOrExchange ( ShuttleGui S)

Definition at line 616 of file AudioUnitEffect.cpp.

617{
618 S.SetBorder(5);
619 S.StartHorizontalLay(wxEXPAND, 1);
620 {
621 S.StartVerticalLay(true);
622 {
623 S.StartStatic(XO("Presets (may select multiple)"));
624 {
625 mList = S.Style(wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
626 wxLC_NO_SORT_HEADER)
627 .AddListControlReportMode({ XO("Preset"), XO("Location") });
628 }
629 S.EndStatic();
630 }
631 S.EndVerticalLay();
632 }
633 S.EndHorizontalLay();
634
635 S.AddStandardButtons();
636
637 FilePaths presets;
638 wxFileName fn;
639
640 // Generate the local domain path
641 wxString path;
642 path.Printf(wxT("%s/%s/%s"),
645 mEffect->mName);
646 fn = path;
647 fn.Normalize();
648
649 // Get all presets in the local domain for this effect
650 wxDir::GetAllFiles(fn.GetFullPath(), &presets, wxT("*.aupreset"));
651
652 // Generate the user domain path
653 path.Printf(wxT("%s/%s/%s"),
656 mEffect->mName);
657 fn = path;
658 fn.Normalize();
659
660 // Get all presets in the user domain for this effect
661 wxDir::GetAllFiles(fn.GetFullPath(), &presets, wxT("*.aupreset"));
662
663 presets.Sort();
664
665 for (size_t i = 0, cnt = presets.size(); i < cnt; i++)
666 {
667 fn = presets[i];
668 mList->InsertItem(i, fn.GetName());
669 mList->SetItem(i, 1, fn.GetPath());
670 }
671
672 mList->SetColumnWidth(0, wxLIST_AUTOSIZE);
673 mList->SetColumnWidth(1, wxLIST_AUTOSIZE);
674
675 // Set the list size...with a little extra for good measure
676 wxSize sz = mList->GetBestSize();
677 sz.x += 5;
678 sz.y += 5;
679 mList->SetMinSize(sz);
680
681 Layout();
682 Fit();
683 Center();
684}
#define PRESET_LOCAL_PATH
#define PRESET_USER_PATH
static const auto fn
const wxString mName
const wxString mVendor
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References fn, mEffect, mList, AudioUnitEffect::mName, AudioUnitEffect::mVendor, PRESET_LOCAL_PATH, PRESET_USER_PATH, S, and XO.

Member Data Documentation

◆ mEffect

AudioUnitEffect* AudioUnitEffectImportDialog::mEffect
private

Definition at line 592 of file AudioUnitEffect.cpp.

Referenced by Import(), and PopulateOrExchange().

◆ mList

wxListCtrl* AudioUnitEffectImportDialog::mList
private

Definition at line 594 of file AudioUnitEffect.cpp.

Referenced by HasPresets(), OnOk(), and PopulateOrExchange().

◆ mParent

wxWindow* AudioUnitEffectImportDialog::mParent
private

Definition at line 591 of file AudioUnitEffect.cpp.


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