Audio plugin host https://kx.studio/carla
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.

113 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. /**
  22. A base class for components that display a list of the files in a directory.
  23. @see DirectoryContentsList
  24. */
  25. class JUCE_API DirectoryContentsDisplayComponent
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a DirectoryContentsDisplayComponent for a given list of files. */
  30. DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow);
  31. /** Destructor. */
  32. virtual ~DirectoryContentsDisplayComponent();
  33. //==============================================================================
  34. /** The list that this component is displaying */
  35. DirectoryContentsList& directoryContentsList;
  36. //==============================================================================
  37. /** Returns the number of files the user has got selected.
  38. @see getSelectedFile
  39. */
  40. virtual int getNumSelectedFiles() const = 0;
  41. /** Returns one of the files that the user has currently selected.
  42. The index should be in the range 0 to (getNumSelectedFiles() - 1).
  43. @see getNumSelectedFiles
  44. */
  45. virtual File getSelectedFile (int index) const = 0;
  46. /** Deselects any selected files. */
  47. virtual void deselectAllFiles() = 0;
  48. /** Scrolls this view to the top. */
  49. virtual void scrollToTop() = 0;
  50. /** If the specified file is in the list, it will become the only selected item
  51. (and if the file isn't in the list, all other items will be deselected). */
  52. virtual void setSelectedFile (const File&) = 0;
  53. //==============================================================================
  54. /** Adds a listener to be told when files are selected or clicked.
  55. @see removeListener
  56. */
  57. void addListener (FileBrowserListener* listener);
  58. /** Removes a listener.
  59. @see addListener
  60. */
  61. void removeListener (FileBrowserListener* listener);
  62. //==============================================================================
  63. /** A set of colour IDs to use to change the colour of various aspects of the list.
  64. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  65. methods.
  66. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  67. */
  68. enum ColourIds
  69. {
  70. highlightColourId = 0x1000540, /**< The colour to use to fill a highlighted row of the list. */
  71. textColourId = 0x1000541, /**< The colour for the text. */
  72. };
  73. //==============================================================================
  74. /** @internal */
  75. void sendSelectionChangeMessage();
  76. /** @internal */
  77. void sendDoubleClickMessage (const File&);
  78. /** @internal */
  79. void sendMouseClickMessage (const File&, const MouseEvent&);
  80. protected:
  81. //==============================================================================
  82. ListenerList<FileBrowserListener> listeners;
  83. private:
  84. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsDisplayComponent)
  85. };