Audacity  3.0.3
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PluginRegistrationDialog Class Referencefinal

#include <PluginRegistrationDialog.h>

Inheritance diagram for PluginRegistrationDialog:
[legend]
Collaboration diagram for PluginRegistrationDialog:
[legend]

Classes

struct  ItemData
 

Public Member Functions

 PluginRegistrationDialog (wxWindow *parent, EffectType type)
 
- 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 Types

using ItemDataMap = std::unordered_map< PluginPath, ItemData >
 

Private Member Functions

void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 Defines the dialog and does data exchange with it. More...
 
void RegenerateEffectsList (int iShowWhat)
 
void SetState (int i, bool toggle, bool state=true)
 
int SortCompare (ItemData *item1, ItemData *item2)
 
void OnChangedVisibility (wxCommandEvent &evt)
 
void OnSort (wxListEvent &evt)
 
void DoSort (int col)
 
void OnListChar (wxKeyEvent &evt)
 
void OnOK (wxCommandEvent &evt)
 
void OnCancel (wxCommandEvent &evt)
 
void OnSelectAll (wxCommandEvent &evt)
 
void OnClearAll (wxCommandEvent &evt)
 
void OnEnable (wxCommandEvent &evt)
 
void OnDisable (wxCommandEvent &evt)
 

Static Private Member Functions

static int wxCALLBACK SortCompare (wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
 

Private Attributes

EffectType mType
 
int mFilter
 
wxArrayString mStates
 
ItemDataMap mItems
 
int mSortColumn
 
int mSortDirection
 
PluginPath mLongestPath
 
wxListCtrl * mEffects
 

Detailed Description

Definition at line 24 of file PluginRegistrationDialog.h.

Member Typedef Documentation

◆ ItemDataMap

using PluginRegistrationDialog::ItemDataMap = std::unordered_map<PluginPath, ItemData>
private

Definition at line 43 of file PluginRegistrationDialog.h.

Constructor & Destructor Documentation

◆ PluginRegistrationDialog()

PluginRegistrationDialog::PluginRegistrationDialog ( wxWindow *  parent,
EffectType  type 
)

Definition at line 383 of file PluginRegistrationDialog.cpp.

384 : wxDialogWrapper(parent,
385  wxID_ANY,
386  XO("Manage Plug-ins"),
387  wxDefaultPosition, wxDefaultSize,
388  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
389 {
390  mType = type;
391  mEffects = NULL;
392  SetName();
393 
394  mStates.resize(STATE_COUNT);
395  mStates[STATE_Enabled] = _("Enabled");
396  mStates[STATE_Disabled] = _("Disabled");
397  mStates[STATE_New] = _("New");
398 
400  mSortDirection = 1;
401 
402  Populate();
403 
404  DoSort( mSortColumn );
405 }

References _, COL_Name, STATE_COUNT, STATE_Disabled, STATE_Enabled, and STATE_New.

Member Function Documentation

◆ DoSort()

void PluginRegistrationDialog::DoSort ( int  col)
private

Definition at line 774 of file PluginRegistrationDialog.cpp.

775 {
776  if (col != mSortColumn)
777  {
778  mSortDirection = 1;
779  }
780  else
781  {
782  mSortDirection *= -1;
783  }
784 
785  mSortColumn = col;
786  mEffects->SortItems(SortCompare, (wxUIntPtr) this);
787 
788  // Without a refresh, wxMac doesn't redisplay the list properly after a sort
789  mEffects->Refresh();
790 }

References mEffects, mSortColumn, mSortDirection, and SortCompare().

Referenced by OnSort().

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

◆ OnCancel()

void PluginRegistrationDialog::OnCancel ( wxCommandEvent &  evt)
private

Definition at line 967 of file PluginRegistrationDialog.cpp.

968 {
969  EndModal(wxID_CANCEL);
970 }

◆ OnChangedVisibility()

void PluginRegistrationDialog::OnChangedVisibility ( wxCommandEvent &  evt)
private

Definition at line 762 of file PluginRegistrationDialog.cpp.

763 {
764  // Go and show the relevant items.
765  RegenerateEffectsList(evt.GetId());
766 }

References RegenerateEffectsList().

Here is the call graph for this function:

◆ OnClearAll()

void PluginRegistrationDialog::OnClearAll ( wxCommandEvent &  evt)
private

Definition at line 826 of file PluginRegistrationDialog.cpp.

827 {
828  for (int i = 0, cnt = mEffects->GetItemCount(); i < cnt; i++)
829  {
830  mEffects->SetItemState(i, 0, wxLIST_STATE_SELECTED);
831  }
832 }

References mEffects.

◆ OnDisable()

void PluginRegistrationDialog::OnDisable ( wxCommandEvent &  evt)
private

Definition at line 853 of file PluginRegistrationDialog.cpp.

854 {
855  std::vector<long> items;
856 
857  {
858  long i = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
859  while (i != wxNOT_FOUND)
860  {
861  items.insert(items.begin(), i);
862  i = mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
863  }
864  }
865 
866  for (size_t i = 0, cnt = items.size(); i < cnt; i++)
867  {
868  SetState(items[i], false, STATE_Disabled);
869  }
870 }

References mEffects, SetState(), and STATE_Disabled.

Here is the call graph for this function:

◆ OnEnable()

void PluginRegistrationDialog::OnEnable ( wxCommandEvent &  evt)
private

Definition at line 834 of file PluginRegistrationDialog.cpp.

835 {
836  std::vector<long> items;
837 
838  {
839  long i = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
840  while (i != wxNOT_FOUND)
841  {
842  items.insert(items.begin(), i);
843  i = mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
844  }
845  }
846 
847  for (size_t i = 0, cnt = items.size(); i < cnt; i++)
848  {
849  SetState(items[i], false, STATE_Enabled);
850  }
851 }

References mEffects, SetState(), and STATE_Enabled.

Here is the call graph for this function:

◆ OnListChar()

void PluginRegistrationDialog::OnListChar ( wxKeyEvent &  evt)
private

Definition at line 792 of file PluginRegistrationDialog.cpp.

793 {
794  switch (evt.GetKeyCode())
795  {
796  case WXK_SPACE:
797  {
798  int item = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
799  if (item != wxNOT_FOUND)
800  {
801  SetState(item, true);
802  }
803  }
804  break;
805 
806  case WXK_RETURN:
807  // Don't know why wxListCtrls prevent default dialog action,
808  // but they do, so handle it.
809  EmulateButtonClickIfPresent(GetAffirmativeId());
810  break;
811 
812  default:
813  evt.Skip();
814  break;
815  }
816 }

References mEffects, and SetState().

Referenced by PopulateOrExchange().

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

◆ OnOK()

void PluginRegistrationDialog::OnOK ( wxCommandEvent &  evt)
private

Definition at line 872 of file PluginRegistrationDialog.cpp.

873 {
876 
877  int enableCount = 0;
878  for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
879  {
880  ItemData & item = iter->second;
881  wxString path = item.path;
882 
883  if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
884  {
885  enableCount++;
886  }
887  }
888 
889  wxString last3 = mLongestPath + wxT("\n") +
890  mLongestPath + wxT("\n") +
891  mLongestPath + wxT("\n");
892 
893  auto msg = XO("Enabling effects or commands:\n\n%s").Format( last3 );
894 
895  // Make sure the progress dialog is deleted before we call EndModal() or
896  // we will leave the project window in an unusable state on OSX.
897  // See bug #1192.
898  {
899  ProgressDialog progress{
900  Verbatim( GetTitle() ), msg, pdlgHideStopButton };
901  progress.CenterOnParent();
902 
903  int i = 0;
904  for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
905  {
906  ItemData & item = iter->second;
907  wxString path = item.path;
908 
909  if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
910  {
911  last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
912  auto status = progress.Update(++i, enableCount,
913  XO("Enabling effect or command:\n\n%s").Format( last3 ));
914  if (status == ProgressResult::Cancelled)
915  {
916  break;
917  }
918 
919  TranslatableString errMsgs;
920 
921  // Try to register the plugin via each provider until one succeeds
922  for (size_t j = 0, cntj = item.plugs.size(); j < cntj; j++)
923  {
924  TranslatableString errMsg;
925  if (mm.RegisterEffectPlugin(item.plugs[j]->GetProviderID(), path,
926  errMsg))
927  {
928  for (auto plug : item.plugs)
929  pm.UnregisterPlugin(
930  plug->GetProviderID() + wxT("_") + path);
931  // Bug 1893. We've found a provider that works.
932  // Error messages from any that failed are no longer useful.
933  errMsgs = {};
934  break;
935  }
936  else
937  {
938  if (!errMsgs.empty())
939  errMsgs.Join( errMsg, '\n' );
940  else
941  errMsgs = errMsg;
942  }
943  }
944  if (!errMsgs.empty())
946  XO("Effect or Command at %s failed to register:\n%s")
947  .Format( path, errMsgs ) );
948  }
949  else if (item.state == STATE_New) {
950  for (auto plug : item.plugs)
951  plug->SetValid(false);
952  }
953  else if (item.state != STATE_New) {
954  for (auto plug : item.plugs) {
955  plug->SetEnabled(item.state == STATE_Enabled);
956  plug->SetValid(item.valid);
957  }
958  }
959  }
960 
961  pm.Save();
962  }
963 
964  EndModal(wxID_OK);
965 }

References AudacityMessageBox(), RefreshCode::Cancelled, TranslatableString::empty(), ModuleManager::Get(), PluginManager::Get(), TranslatableString::Join(), mItems, mLongestPath, PluginRegistrationDialog::ItemData::path, pdlgHideStopButton, PluginTypeStub, PluginRegistrationDialog::ItemData::plugs, ModuleManager::RegisterEffectPlugin(), PluginManager::Save(), PluginRegistrationDialog::ItemData::state, STATE_Enabled, STATE_New, PluginManager::UnregisterPlugin(), PluginRegistrationDialog::ItemData::valid, Verbatim(), and XO.

Here is the call graph for this function:

◆ OnSelectAll()

void PluginRegistrationDialog::OnSelectAll ( wxCommandEvent &  evt)
private

Definition at line 818 of file PluginRegistrationDialog.cpp.

819 {
820  for (int i = 0, cnt = mEffects->GetItemCount(); i < cnt; i++)
821  {
822  mEffects->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
823  }
824 }

References mEffects.

◆ OnSort()

void PluginRegistrationDialog::OnSort ( wxListEvent &  evt)
private

Definition at line 768 of file PluginRegistrationDialog.cpp.

769 {
770  int col = evt.GetColumn();
771  DoSort( col );
772 }

References DoSort().

Here is the call graph for this function:

◆ Populate()

void PluginRegistrationDialog::Populate ( )
private

Definition at line 407 of file PluginRegistrationDialog.cpp.

408 {
409  //------------------------- Main section --------------------
410  ShuttleGui S(this, eIsCreating);
412  // ----------------------- End of main section --------------
413 }

References eIsCreating, and PopulateOrExchange().

Here is the call graph for this function:

◆ PopulateOrExchange()

void PluginRegistrationDialog::PopulateOrExchange ( ShuttleGui S)
private

Defines the dialog and does data exchange with it.

Definition at line 416 of file PluginRegistrationDialog.cpp.

417 {
418  S.StartVerticalLay(true);
419  {
420  /*i18n-hint: The dialog shows a list of plugins with check-boxes
421  beside each one.*/
422 // S.StartStatic(XO("Effects"), true);
423  S.StartVerticalLay();
424  {
425  S.StartHorizontalLay(wxEXPAND, 0);
426  {
427  S.StartHorizontalLay(wxALIGN_LEFT, 0);
428  {
429  S.AddPrompt(XXO("Select effects, click the Enable or Disable button, then click OK."));
430  }
431  S.EndHorizontalLay();
432 
433  S.StartHorizontalLay(wxCENTER, 1);
434  {
435  S.AddSpace(1);
436  }
437  S.EndHorizontalLay();
438 
439  S.StartHorizontalLay(wxALIGN_NOT | wxALIGN_LEFT, 0);
440  {
441  wxRadioButton *rb;
442 
443  /* i18n-hint: This is before radio buttons selecting which effects to show */
444  S.AddPrompt(XXO("Show:"));
445  rb = S.Id(ID_ShowAll)
446  /* i18n-hint: Radio button to show all effects */
447  .Name(XO("Show all"))
448  /* i18n-hint: Radio button to show all effects */
449  .AddRadioButton(XXO("&All"));
450 #if wxUSE_ACCESSIBILITY
451  // so that name can be set on a standard control
452  rb->SetAccessible(safenew WindowAccessible(rb));
453 #endif
454 
455  rb = S.Id(ID_ShowDisabled)
456  /* i18n-hint: Radio button to show just the currently disabled effects */
457  .Name(XO("Show disabled"))
458  /* i18n-hint: Radio button to show just the currently disabled effects */
459  .AddRadioButtonToGroup(XXO("D&isabled"));
460 #if wxUSE_ACCESSIBILITY
461  // so that name can be set on a standard control
462  rb->SetAccessible(safenew WindowAccessible(rb));
463 #endif
464 
465  rb = S.Id(ID_ShowEnabled)
466  /* i18n-hint: Radio button to show just the currently enabled effects */
467  .Name(XO("Show enabled"))
468  /* i18n-hint: Radio button to show just the currently enabled effects */
469  .AddRadioButtonToGroup(XXO("E&nabled"));
470 #if wxUSE_ACCESSIBILITY
471  // so that name can be set on a standard control
472  rb->SetAccessible(safenew WindowAccessible(rb));
473 #endif
474 
475  rb = S.Id(ID_ShowNew)
476  /* i18n-hint: Radio button to show just the newly discovered effects */
477  .Name(XO("Show new"))
478  /* i18n-hint: Radio button to show just the newly discovered effects */
479  .AddRadioButtonToGroup(XXO("Ne&w"));
480 #if wxUSE_ACCESSIBILITY
481  // so that name can be set on a standard control
482  rb->SetAccessible(safenew WindowAccessible(rb));
483 #endif
484  }
485  S.EndHorizontalLay();
486  }
487  S.EndHorizontalLay();
488 
489  mEffects = S.Id(ID_List)
490  .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES )
491  .ConnectRoot(wxEVT_KEY_DOWN,
493  .AddListControlReportMode({ XO("Name"), XO("State"), XO("Path") });
494 #if wxUSE_ACCESSIBILITY
495  mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects));
496 #endif
497 
498  S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, 0);
499  {
500  S.Id(ID_SelectAll).AddButton(XXO("&Select All"));
501  S.Id(ID_ClearAll).AddButton(XXO("C&lear All"));
502 
503  S.StartHorizontalLay(wxALIGN_CENTER);
504  {
505  S.AddSpace(1);
506  }
507  S.EndHorizontalLay();
508 
509  S.Id(ID_Enable).AddButton(XXO("&Enable"));
510  S.Id(ID_Disable).AddButton(XXO("&Disable"));
511  }
512  S.EndHorizontalLay();
513  }
514 // S.EndStatic();
515  S.EndVerticalLay();
516 
518  }
519  S.EndVerticalLay();
520 
521  std::vector<int> colWidths;
522  for (int i = 0, cnt = mEffects->GetColumnCount(); i < cnt; i++)
523  {
524  colWidths.push_back(0);
525  }
526 
527  for (int i = 0, cnt = mStates.size(); i < cnt; i++)
528  {
529  int x;
530  mEffects->GetTextExtent(mStates[i], &x, NULL);
531  colWidths[COL_State] = wxMax(colWidths[COL_State], x + 4); // 2 pixel margin on each side
532  }
533 
535  for (auto &plug : pm.AllPlugins()) {
536  PluginType plugType = plug.GetPluginType();
537  if (plugType != PluginTypeEffect && plugType != PluginTypeStub)
538  continue;
539 
540  const auto &path = plug.GetPath();
541  ItemData & item = mItems[path]; // will create NEW entry
542  item.plugs.push_back(&plug);
543  item.path = path;
544  item.state = plug.IsEnabled() ? STATE_Enabled : STATE_Disabled;
545  item.valid = plug.IsValid();
546 
547  if (plugType == PluginTypeEffect)
548  {
549  item.name = plug.GetSymbol().Translation();
550  }
551  // This is not right and will not work when other plugin types are added.
552  // But it's presumed that the plugin manager dialog will be fully developed
553  // by then.
554  else if (plugType == PluginTypeStub)
555  {
556  wxFileName fname { path };
557  item.name = fname.GetName().Trim(false).Trim(true);
558  if (!item.valid)
559  {
560  item.state = STATE_New;
561  }
562  }
563 
564  int x;
565  mEffects->GetTextExtent(item.name, &x, NULL);
566  colWidths[COL_Name] = wxMax(colWidths[COL_Name], x);
567 
568  mEffects->GetTextExtent(item.path, &x, NULL);
569  if (x > colWidths[COL_Path])
570  {
571  mLongestPath = item.path;
572  }
573  colWidths[COL_Path] = wxMax(colWidths[COL_Path], x);
574  }
575 
576  wxRect r = wxGetClientDisplayRect();
577 
578  int maxW = 0;
579  for (int i = 0, cnt = mEffects->GetColumnCount(); i < cnt; i++)
580  {
581  int w = colWidths[i] + /* fudge */ 10;
582  mEffects->SetColumnWidth(i, w);
583  maxW += w;
584  }
585 
586  // Keep dialog from getting too wide
587  int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth());
588  mEffects->SetMinSize({ std::min(maxW, w), 200 });
589  mEffects->SetMaxSize({ w, -1 });
590 
592 
593  Layout();
594  Fit();
595 
596  wxSize sz = GetSize();
597  sz.SetWidth(wxMin(sz.GetWidth(), r.GetWidth()));
598  sz.SetHeight(wxMin(sz.GetHeight(), r.GetHeight()));
599  SetMinSize(sz);
600 
601  // Parent window is usually not there yet, so centre on screen rather than on parent.
602  CenterOnScreen();
603 
604  if (mEffects->GetItemCount() > 0)
605  {
606  // Make sure first item is selected/focused.
607  mEffects->SetFocus();
608  mEffects->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
609 #if wxUSE_ACCESSIBILITY
610  mAx->SetSelected(0);
611 #endif
612  }
613 
614 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddRadioButton(), ShuttleGuiBase::AddRadioButtonToGroup(), ShuttleGui::AddSpace(), ShuttleGui::AddStandardButtons(), PluginManager::AllPlugins(), COL_Name, COL_Path, COL_State, ShuttleGui::ConnectRoot(), eCancelButton, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndVerticalLay(), eOkButton, PluginManager::Get(), ShuttleGui::Id(), ID_ClearAll, ID_Disable, ID_Enable, ID_List, ID_SelectAll, ID_ShowAll, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, min(), mItems, mLongestPath, mStates, PluginRegistrationDialog::ItemData::name, ShuttleGui::Name(), OnListChar(), PluginRegistrationDialog::ItemData::path, PluginTypeEffect, PluginTypeStub, PluginRegistrationDialog::ItemData::plugs, RegenerateEffectsList(), safenew, ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartVerticalLay(), PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, STATE_New, ShuttleGui::Style(), PluginRegistrationDialog::ItemData::valid, XO, and XXO.

Referenced by Populate().

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

◆ RegenerateEffectsList()

void PluginRegistrationDialog::RegenerateEffectsList ( int  iShowWhat)
private

Definition at line 616 of file PluginRegistrationDialog.cpp.

617 {
618  mFilter = filter;
619 
620  mEffects->DeleteAllItems();
621 
622  int i = 0;
623  for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
624  {
625  ItemData & item = iter->second;
626  bool add = false;
627 
628  switch (mFilter)
629  {
630  case ID_ShowAll:
631  add = true;
632  break;
633  case ID_ShowNew:
634  if (item.state == STATE_New)
635  {
636  add = true;
637  }
638  break;
639  case ID_ShowEnabled:
640  if (item.state == STATE_Enabled)
641  {
642  add = true;
643  }
644  break;
645  case ID_ShowDisabled:
646  if (item.state == STATE_Disabled)
647  {
648  add = true;
649  }
650  break;
651  }
652 
653  if (add)
654  {
655  mEffects->InsertItem(i, item.name);
656  mEffects->SetItem(i, COL_State, mStates[item.state]);
657  mEffects->SetItem(i, COL_Path, item.path);
658  mEffects->SetItemPtrData(i, (wxUIntPtr) &item);
659 
660  ++i;
661  }
662  }
663 
664  mEffects->SortItems(SortCompare, (wxUIntPtr) this);
665 
666  if (mEffects->GetItemCount() > 0)
667  {
668  // Make sure first item is selected/focused.
669 // mEffects->SetFocus();
670  mEffects->SetItemState(0, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);
671 #if wxUSE_ACCESSIBILITY
672  mAx->SetSelected(0, false);
673 #endif
674  }
675 }

References COL_Path, COL_State, ID_ShowAll, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, mFilter, mItems, mStates, PluginRegistrationDialog::ItemData::name, PluginRegistrationDialog::ItemData::path, SortCompare(), PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, and STATE_New.

Referenced by OnChangedVisibility(), and PopulateOrExchange().

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

◆ SetState()

void PluginRegistrationDialog::SetState ( int  i,
bool  toggle,
bool  state = true 
)
private

Definition at line 677 of file PluginRegistrationDialog.cpp.

678 {
679  wxListItem li;
680 
681  li.m_mask = wxLIST_MASK_DATA;
682  li.m_itemId = i;
683 
684  mEffects->GetItem(li);
685 
686  ItemData *item = (ItemData *) li.m_data;
687 
688  // If changing the state of a "New" (stub) entry, then we mark it as valid
689  // since it will either be registered if "Enabled" or ignored if "Disabled".
690  if (item->state == STATE_New)
691  {
692  item->valid = true;
693  }
694 
695  if (toggle)
696  {
697  item->state = item->state == STATE_Enabled ? STATE_Disabled : STATE_Enabled;
698  }
699  else
700  {
701  item->state = state;
702  }
703 
704  if (mFilter == ID_ShowNew && item->state != STATE_New)
705  {
706  mEffects->DeleteItem(i);
707  }
708  else if (mFilter == ID_ShowDisabled && item->state != STATE_Disabled)
709  {
710  mEffects->DeleteItem(i);
711  }
712  else if (mFilter == ID_ShowEnabled && item->state != STATE_Enabled)
713  {
714  mEffects->DeleteItem(i);
715  }
716  else
717  {
718  mEffects->SetItem(i, COL_State, mStates[item->state]);
719 #if wxUSE_ACCESSIBILITY
720  mAx->SetSelected(i);
721 #endif
722  }
723 }

References COL_State, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, mFilter, mStates, PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, STATE_New, and PluginRegistrationDialog::ItemData::valid.

Referenced by OnDisable(), OnEnable(), and OnListChar().

Here is the caller graph for this function:

◆ SortCompare() [1/2]

int PluginRegistrationDialog::SortCompare ( ItemData item1,
ItemData item2 
)
private

Definition at line 734 of file PluginRegistrationDialog.cpp.

735 {
736  // This function is a three-valued comparator
737 
738  wxString *str1;
739  wxString *str2;
740 
741  switch (mSortColumn)
742  {
743  case COL_Name:
744  str1 = &item1->name;
745  str2 = &item2->name;
746  break;
747  case COL_State:
748  str1 = &mStates[item1->state];
749  str2 = &mStates[item2->state];
750  break;
751  case COL_Path:
752  str1 = &item1->path;
753  str2 = &item2->path;
754  break;
755  default:
756  return 0;
757  }
758 
759  return str2->CmpNoCase(*str1) * mSortDirection;
760 }

References COL_Name, COL_Path, COL_State, mSortColumn, mSortDirection, mStates, PluginRegistrationDialog::ItemData::name, PluginRegistrationDialog::ItemData::path, and PluginRegistrationDialog::ItemData::state.

◆ SortCompare() [2/2]

int wxCALLBACK PluginRegistrationDialog::SortCompare ( wxIntPtr  item1,
wxIntPtr  item2,
wxIntPtr  sortData 
)
staticprivate

Definition at line 725 of file PluginRegistrationDialog.cpp.

726 {
728  ItemData *i1 = (ItemData *) item1;
729  ItemData *i2 = (ItemData *) item2;
730 
731  return dlg->SortCompare(i1, i2);
732 }

References SortCompare().

Referenced by DoSort(), RegenerateEffectsList(), and SortCompare().

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

Member Data Documentation

◆ mEffects

wxListCtrl* PluginRegistrationDialog::mEffects
private

◆ mFilter

int PluginRegistrationDialog::mFilter
private

Definition at line 66 of file PluginRegistrationDialog.h.

Referenced by RegenerateEffectsList(), and SetState().

◆ mItems

ItemDataMap PluginRegistrationDialog::mItems
private

Definition at line 69 of file PluginRegistrationDialog.h.

Referenced by OnOK(), PopulateOrExchange(), and RegenerateEffectsList().

◆ mLongestPath

PluginPath PluginRegistrationDialog::mLongestPath
private

Definition at line 74 of file PluginRegistrationDialog.h.

Referenced by OnOK(), and PopulateOrExchange().

◆ mSortColumn

int PluginRegistrationDialog::mSortColumn
private

Definition at line 71 of file PluginRegistrationDialog.h.

Referenced by DoSort(), and SortCompare().

◆ mSortDirection

int PluginRegistrationDialog::mSortDirection
private

Definition at line 72 of file PluginRegistrationDialog.h.

Referenced by DoSort(), and SortCompare().

◆ mStates

wxArrayString PluginRegistrationDialog::mStates
private

◆ mType

EffectType PluginRegistrationDialog::mType
private

Definition at line 65 of file PluginRegistrationDialog.h.


The documentation for this class was generated from the following files:
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
PluginRegistrationDialog::mType
EffectType mType
Definition: PluginRegistrationDialog.h:65
PluginRegistrationDialog::Populate
void Populate()
Definition: PluginRegistrationDialog.cpp:407
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
PluginTypeEffect
@ PluginTypeEffect
Definition: PluginManager.h:35
PluginRegistrationDialog::SortCompare
static int wxCALLBACK SortCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
Definition: PluginRegistrationDialog.cpp:725
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
PluginManager::Save
void Save()
Save to preferences.
Definition: PluginManager.cpp:1210
ID_SelectAll
@ ID_SelectAll
Definition: PluginRegistrationDialog.cpp:355
STATE_COUNT
@ STATE_COUNT
Definition: PluginRegistrationDialog.cpp:344
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
ID_ShowAll
@ ID_ShowAll
Definition: PluginRegistrationDialog.cpp:349
ID_Disable
@ ID_Disable
Definition: PluginRegistrationDialog.cpp:357
PluginRegistrationDialog::mItems
ItemDataMap mItems
Definition: PluginRegistrationDialog.h:69
pdlgHideStopButton
@ pdlgHideStopButton
Definition: ProgressDialog.h:38
Format
Abstract base class used in importing a file.
ShuttleGuiBase::AddRadioButtonToGroup
wxRadioButton * AddRadioButtonToGroup(const TranslatableString &Prompt, int selector=1, int initValue=0)
Definition: ShuttleGui.cpp:574
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
XO
#define XO(s)
Definition: Internat.h:31
ModuleManager::RegisterEffectPlugin
bool RegisterEffectPlugin(const PluginID &provider, const PluginPath &path, TranslatableString &errMsg)
Definition: ModuleManager.cpp:490
COL_State
@ COL_State
Definition: PluginRegistrationDialog.cpp:363
PluginRegistrationDialog
Definition: PluginRegistrationDialog.h:25
ID_ClearAll
@ ID_ClearAll
Definition: PluginRegistrationDialog.cpp:354
PluginRegistrationDialog::mSortDirection
int mSortDirection
Definition: PluginRegistrationDialog.h:72
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
PluginType
PluginType
Definition: PluginManager.h:32
COL_Path
@ COL_Path
Definition: PluginRegistrationDialog.cpp:364
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:727
COL_Name
@ COL_Name
Definition: PluginRegistrationDialog.cpp:362
XXO
#define XXO(s)
Definition: Internat.h:44
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:601
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
ModuleManager
Definition: ModuleManager.h:71
ProgressDialog
ProgressDialog Class.
Definition: ProgressDialog.h:51
PluginRegistrationDialog::OnListChar
void OnListChar(wxKeyEvent &evt)
Definition: PluginRegistrationDialog.cpp:792
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
ModuleManager::Get
static ModuleManager & Get()
Definition: ModuleManager.cpp:395
PluginRegistrationDialog::mEffects
wxListCtrl * mEffects
Definition: PluginRegistrationDialog.h:76
ID_Enable
@ ID_Enable
Definition: PluginRegistrationDialog.cpp:356
PluginRegistrationDialog::mFilter
int mFilter
Definition: PluginRegistrationDialog.h:66
STATE_Enabled
@ STATE_Enabled
Definition: PluginRegistrationDialog.cpp:340
STATE_New
@ STATE_New
Definition: PluginRegistrationDialog.cpp:342
WindowAccessible
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
ID_ShowEnabled
@ ID_ShowEnabled
Definition: PluginRegistrationDialog.cpp:350
ShuttleGuiBase::AddRadioButton
wxRadioButton * AddRadioButton(const TranslatableString &Prompt, int selector=0, int initValue=0)
Definition: ShuttleGui.cpp:568
PluginManager::UnregisterPlugin
void UnregisterPlugin(const PluginID &ID)
Definition: PluginManager.cpp:1434
PluginRegistrationDialog::DoSort
void DoSort(int col)
Definition: PluginRegistrationDialog.cpp:774
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
PluginRegistrationDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
Definition: PluginRegistrationDialog.cpp:416
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:663
ID_ShowNew
@ ID_ShowNew
Definition: PluginRegistrationDialog.cpp:352
PluginManager::Get
static PluginManager & Get()
Definition: PluginManager.cpp:695
PluginRegistrationDialog::mSortColumn
int mSortColumn
Definition: PluginRegistrationDialog.h:71
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
PluginManager
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Definition: PluginManager.h:174
PluginManager::AllPlugins
Range AllPlugins()
Definition: PluginManager.h:280
_
#define _(s)
Definition: Internat.h:75
ShuttleGui::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) -> typename std::enable_if< std::is_base_of< Argument, Tag >::value, ShuttleGui & >::type
Definition: ShuttleGui.h:699
PluginRegistrationDialog::mStates
wxArrayString mStates
Definition: PluginRegistrationDialog.h:68
ID_List
@ ID_List
Definition: PluginRegistrationDialog.cpp:353
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2444
PluginRegistrationDialog::mLongestPath
PluginPath mLongestPath
Definition: PluginRegistrationDialog.h:74
PluginRegistrationDialog::RegenerateEffectsList
void RegenerateEffectsList(int iShowWhat)
Definition: PluginRegistrationDialog.cpp:616
ID_ShowDisabled
@ ID_ShowDisabled
Definition: PluginRegistrationDialog.cpp:351
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:238
PluginTypeStub
@ PluginTypeStub
Definition: PluginManager.h:34
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
TranslatableString::Join
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.
Definition: TranslatableString.cpp:124
safenew
#define safenew
Definition: MemoryX.h:10
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
STATE_Disabled
@ STATE_Disabled
Definition: PluginRegistrationDialog.cpp:341
PluginRegistrationDialog::SetState
void SetState(int i, bool toggle, bool state=true)
Definition: PluginRegistrationDialog.cpp:677