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

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