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

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. Shows a set of file paths in a list, allowing them to be added, removed or
  23. re-ordered.
  24. @see FileSearchPath
  25. @tags{GUI}
  26. */
  27. class JUCE_API FileSearchPathListComponent : public Component,
  28. public SettableTooltipClient,
  29. public FileDragAndDropTarget,
  30. private ListBoxModel
  31. {
  32. public:
  33. //==============================================================================
  34. /** Creates an empty FileSearchPathListComponent. */
  35. FileSearchPathListComponent();
  36. /** Destructor. */
  37. ~FileSearchPathListComponent() override;
  38. //==============================================================================
  39. /** Returns the path as it is currently shown. */
  40. const FileSearchPath& getPath() const noexcept { return path; }
  41. /** Changes the current path. */
  42. void setPath (const FileSearchPath& newPath);
  43. /** Sets a file or directory to be the default starting point for the browser to show.
  44. This is only used if the current file hasn't been set.
  45. */
  46. void setDefaultBrowseTarget (const File& newDefaultDirectory);
  47. /** A set of colour IDs to use to change the colour of various aspects of the label.
  48. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  49. methods.
  50. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  51. */
  52. enum ColourIds
  53. {
  54. backgroundColourId = 0x1004100, /**< The background colour to fill the component with.
  55. Make this transparent if you don't want the background to be filled. */
  56. };
  57. //==============================================================================
  58. /** @internal */
  59. int getNumRows() override;
  60. /** @internal */
  61. void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override;
  62. /** @internal */
  63. void deleteKeyPressed (int lastRowSelected) override;
  64. /** @internal */
  65. void returnKeyPressed (int lastRowSelected) override;
  66. /** @internal */
  67. void listBoxItemDoubleClicked (int row, const MouseEvent&) override;
  68. /** @internal */
  69. void selectedRowsChanged (int lastRowSelected) override;
  70. /** @internal */
  71. void resized() override;
  72. /** @internal */
  73. void paint (Graphics&) override;
  74. /** @internal */
  75. bool isInterestedInFileDrag (const StringArray&) override;
  76. /** @internal */
  77. void filesDropped (const StringArray& files, int, int) override;
  78. private:
  79. //==============================================================================
  80. FileSearchPath path;
  81. File defaultBrowseTarget;
  82. std::unique_ptr<FileChooser> chooser;
  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