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.

118 lines
4.2KB

  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. 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. //==============================================================================
  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. private:
  77. //==============================================================================
  78. FileSearchPath path;
  79. File defaultBrowseTarget;
  80. std::unique_ptr<FileChooser> chooser;
  81. ListBox listBox;
  82. TextButton addButton, removeButton, changeButton;
  83. DrawableButton upButton, downButton;
  84. void changed();
  85. void updateButtons();
  86. void addPath();
  87. void deleteSelected();
  88. void editSelected();
  89. void moveSelection (int);
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent)
  91. };
  92. } // namespace juce