The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
6.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_KNOWNPLUGINLIST_JUCEHEADER__
  19. #define __JUCE_KNOWNPLUGINLIST_JUCEHEADER__
  20. #include "juce_PluginDescription.h"
  21. #include "juce_AudioPluginFormat.h"
  22. #include "../../events/juce_ChangeBroadcaster.h"
  23. #include "../../gui/components/menus/juce_PopupMenu.h"
  24. //==============================================================================
  25. /**
  26. Manages a list of plugin types.
  27. This can be easily edited, saved and loaded, and used to create instances of
  28. the plugin types in it.
  29. @see PluginListComponent
  30. */
  31. class JUCE_API KnownPluginList : public ChangeBroadcaster
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates an empty list.
  36. */
  37. KnownPluginList();
  38. /** Destructor. */
  39. ~KnownPluginList();
  40. //==============================================================================
  41. /** Clears the list. */
  42. void clear();
  43. /** Returns the number of types currently in the list.
  44. @see getType
  45. */
  46. int getNumTypes() const throw() { return types.size(); }
  47. /** Returns one of the types.
  48. @see getNumTypes
  49. */
  50. PluginDescription* getType (int index) const throw() { return types [index]; }
  51. /** Looks for a type in the list which comes from this file.
  52. */
  53. PluginDescription* getTypeForFile (const String& fileOrIdentifier) const;
  54. /** Looks for a type in the list which matches a plugin type ID.
  55. The identifierString parameter must have been created by
  56. PluginDescription::createIdentifierString().
  57. */
  58. PluginDescription* getTypeForIdentifierString (const String& identifierString) const;
  59. /** Adds a type manually from its description. */
  60. bool addType (const PluginDescription& type);
  61. /** Removes a type. */
  62. void removeType (int index);
  63. /** Looks for all types that can be loaded from a given file, and adds them
  64. to the list.
  65. If dontRescanIfAlreadyInList is true, then the file will only be loaded and
  66. re-tested if it's not already in the list, or if the file's modification
  67. time has changed since the list was created. If dontRescanIfAlreadyInList is
  68. false, the file will always be reloaded and tested.
  69. Returns true if any new types were added, and all the types found in this
  70. file (even if it was already known and hasn't been re-scanned) get returned
  71. in the array.
  72. */
  73. bool scanAndAddFile (const String& possiblePluginFileOrIdentifier,
  74. bool dontRescanIfAlreadyInList,
  75. OwnedArray <PluginDescription>& typesFound,
  76. AudioPluginFormat& formatToUse);
  77. /** Returns true if the specified file is already known about and if it
  78. hasn't been modified since our entry was created.
  79. */
  80. bool isListingUpToDate (const String& possiblePluginFileOrIdentifier) const;
  81. /** Scans and adds a bunch of files that might have been dragged-and-dropped.
  82. If any types are found in the files, their descriptions are returned in the array.
  83. */
  84. void scanAndAddDragAndDroppedFiles (const StringArray& filenames,
  85. OwnedArray <PluginDescription>& typesFound);
  86. //==============================================================================
  87. /** Sort methods used to change the order of the plugins in the list.
  88. */
  89. enum SortMethod
  90. {
  91. defaultOrder = 0,
  92. sortAlphabetically,
  93. sortByCategory,
  94. sortByManufacturer,
  95. sortByFileSystemLocation
  96. };
  97. //==============================================================================
  98. /** Adds all the plugin types to a popup menu so that the user can select one.
  99. Depending on the sort method, it may add sub-menus for categories,
  100. manufacturers, etc.
  101. Use getIndexChosenByMenu() to find out the type that was chosen.
  102. */
  103. void addToMenu (PopupMenu& menu,
  104. const SortMethod sortMethod) const;
  105. /** Converts a menu item index that has been chosen into its index in this list.
  106. Returns -1 if it's not an ID that was used.
  107. @see addToMenu
  108. */
  109. int getIndexChosenByMenu (int menuResultCode) const;
  110. //==============================================================================
  111. /** Sorts the list. */
  112. void sort (const SortMethod method);
  113. //==============================================================================
  114. /** Creates some XML that can be used to store the state of this list.
  115. */
  116. XmlElement* createXml() const;
  117. /** Recreates the state of this list from its stored XML format.
  118. */
  119. void recreateFromXml (const XmlElement& xml);
  120. private:
  121. //==============================================================================
  122. OwnedArray <PluginDescription> types;
  123. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KnownPluginList);
  124. };
  125. #endif // __JUCE_KNOWNPLUGINLIST_JUCEHEADER__