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.5KB

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