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.

121 lines
4.2KB

  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. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. Shows a set of file paths in a list, allowing them to be added, removed or
  24. re-ordered.
  25. @see FileSearchPath
  26. @tags{GUI}
  27. */
  28. class JUCE_API FileSearchPathListComponent : public Component,
  29. public SettableTooltipClient,
  30. public FileDragAndDropTarget,
  31. private ListBoxModel
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates an empty FileSearchPathListComponent. */
  36. FileSearchPathListComponent();
  37. /** Destructor. */
  38. ~FileSearchPathListComponent() override;
  39. //==============================================================================
  40. /** Returns the path as it is currently shown. */
  41. const FileSearchPath& getPath() const noexcept { return path; }
  42. /** Changes the current path. */
  43. void setPath (const FileSearchPath& newPath);
  44. /** Sets a file or directory to be the default starting point for the browser to show.
  45. This is only used if the current file hasn't been set.
  46. */
  47. void setDefaultBrowseTarget (const File& newDefaultDirectory);
  48. /** A set of colour IDs to use to change the colour of various aspects of the label.
  49. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  50. methods.
  51. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  52. */
  53. enum ColourIds
  54. {
  55. backgroundColourId = 0x1004100, /**< The background colour to fill the component with.
  56. Make this transparent if you don't want the background to be filled. */
  57. };
  58. //==============================================================================
  59. /** @internal */
  60. int getNumRows() override;
  61. /** @internal */
  62. void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override;
  63. /** @internal */
  64. void deleteKeyPressed (int lastRowSelected) override;
  65. /** @internal */
  66. void returnKeyPressed (int lastRowSelected) override;
  67. /** @internal */
  68. void listBoxItemDoubleClicked (int row, const MouseEvent&) override;
  69. /** @internal */
  70. void selectedRowsChanged (int lastRowSelected) override;
  71. /** @internal */
  72. void resized() override;
  73. /** @internal */
  74. void paint (Graphics&) override;
  75. /** @internal */
  76. bool isInterestedInFileDrag (const StringArray&) override;
  77. /** @internal */
  78. void filesDropped (const StringArray& files, int, int) override;
  79. private:
  80. //==============================================================================
  81. FileSearchPath path;
  82. File defaultBrowseTarget;
  83. ListBox listBox;
  84. TextButton addButton, removeButton, changeButton;
  85. DrawableButton upButton, downButton;
  86. void changed();
  87. void updateButtons();
  88. void addPath();
  89. void deleteSelected();
  90. void editSelected();
  91. void moveSelection (int);
  92. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent)
  93. };
  94. } // namespace juce