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.

juce_FileTreeComponent.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A component that displays the files in a directory as a treeview.
  23. This implements the DirectoryContentsDisplayComponent base class so that
  24. it can be used in a FileBrowserComponent.
  25. To attach a listener to it, use its DirectoryContentsDisplayComponent base
  26. class and the FileBrowserListener class.
  27. @see DirectoryContentsList, FileListComponent
  28. @tags{GUI}
  29. */
  30. class JUCE_API FileTreeComponent : public TreeView,
  31. public DirectoryContentsDisplayComponent
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates a listbox to show the contents of a specified directory.
  36. */
  37. FileTreeComponent (DirectoryContentsList& listToShow);
  38. /** Destructor. */
  39. ~FileTreeComponent() override;
  40. //==============================================================================
  41. /** Returns the number of files the user has got selected.
  42. @see getSelectedFile
  43. */
  44. int getNumSelectedFiles() const override { return TreeView::getNumSelectedItems(); }
  45. /** Returns one of the files that the user has currently selected.
  46. The index should be in the range 0 to (getNumSelectedFiles() - 1).
  47. @see getNumSelectedFiles
  48. */
  49. File getSelectedFile (int index = 0) const override;
  50. /** Deselects any files that are currently selected. */
  51. void deselectAllFiles() override;
  52. /** Scrolls the list to the top. */
  53. void scrollToTop() override;
  54. /** If the specified file is in the list, it will become the only selected item
  55. (and if the file isn't in the list, all other items will be deselected). */
  56. void setSelectedFile (const File&) override;
  57. /** Updates the files in the list. */
  58. void refresh();
  59. /** Setting a name for this allows tree items to be dragged.
  60. The string that you pass in here will be returned by the getDragSourceDescription()
  61. of the items in the tree. For more info, see TreeViewItem::getDragSourceDescription().
  62. */
  63. void setDragAndDropDescription (const String& description);
  64. /** Returns the last value that was set by setDragAndDropDescription().
  65. */
  66. const String& getDragAndDropDescription() const noexcept { return dragAndDropDescription; }
  67. /** Changes the height of the treeview items. */
  68. void setItemHeight (int newHeight);
  69. /** Returns the height of the treeview items. */
  70. int getItemHeight() const noexcept { return itemHeight; }
  71. private:
  72. //==============================================================================
  73. String dragAndDropDescription;
  74. int itemHeight;
  75. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent)
  76. };
  77. } // namespace juce