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.

113 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. //==============================================================================
  19. /**
  20. Shows a set of file paths in a list, allowing them to be added, removed or
  21. re-ordered.
  22. @see FileSearchPath
  23. */
  24. class JUCE_API FileSearchPathListComponent : public Component,
  25. public SettableTooltipClient,
  26. public FileDragAndDropTarget,
  27. private ButtonListener, // (can't use Button::Listener due to idiotic VC2005 bug)
  28. private ListBoxModel
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates an empty FileSearchPathListComponent. */
  33. FileSearchPathListComponent();
  34. /** Destructor. */
  35. ~FileSearchPathListComponent();
  36. //==============================================================================
  37. /** Returns the path as it is currently shown. */
  38. const FileSearchPath& getPath() const noexcept { return path; }
  39. /** Changes the current path. */
  40. void setPath (const FileSearchPath& newPath);
  41. /** Sets a file or directory to be the default starting point for the browser to show.
  42. This is only used if the current file hasn't been set.
  43. */
  44. void setDefaultBrowseTarget (const File& newDefaultDirectory);
  45. /** A set of colour IDs to use to change the colour of various aspects of the label.
  46. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  47. methods.
  48. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  49. */
  50. enum ColourIds
  51. {
  52. backgroundColourId = 0x1004100, /**< The background colour to fill the component with.
  53. Make this transparent if you don't want the background to be filled. */
  54. };
  55. //==============================================================================
  56. /** @internal */
  57. int getNumRows() override;
  58. /** @internal */
  59. void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override;
  60. /** @internal */
  61. void deleteKeyPressed (int lastRowSelected) override;
  62. /** @internal */
  63. void returnKeyPressed (int lastRowSelected) override;
  64. /** @internal */
  65. void listBoxItemDoubleClicked (int row, const MouseEvent&) override;
  66. /** @internal */
  67. void selectedRowsChanged (int lastRowSelected) override;
  68. /** @internal */
  69. void resized() override;
  70. /** @internal */
  71. void paint (Graphics&) override;
  72. /** @internal */
  73. bool isInterestedInFileDrag (const StringArray&) override;
  74. /** @internal */
  75. void filesDropped (const StringArray& files, int, int) override;
  76. /** @internal */
  77. void buttonClicked (Button*) override;
  78. private:
  79. //==============================================================================
  80. FileSearchPath path;
  81. File defaultBrowseTarget;
  82. ListBox listBox;
  83. TextButton addButton, removeButton, changeButton;
  84. DrawableButton upButton, downButton;
  85. void changed();
  86. void updateButtons();
  87. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent)
  88. };