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.

122 lines
4.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the dRowAudio JUCE module
  4. Copyright 2004-13 by dRowAudio.
  5. ------------------------------------------------------------------------------
  6. dRowAudio is provided under the terms of The MIT License (MIT):
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in all
  14. copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22. ==============================================================================
  23. */
  24. #ifndef __DROWAUDIO_AUDIOFILEDROPTARGET_H__
  25. #define __DROWAUDIO_AUDIOFILEDROPTARGET_H__
  26. #if DROWAUDIO_USE_SOUNDTOUCH
  27. #include "../audio/dRowAudio_AudioFilePlayer.h"
  28. //==============================================================================
  29. /** A Component that acts as a drag and drop target for audio files and
  30. MusicLibraryTable drag sources. This will draw a coloured bezel if it can
  31. read the drag source provided.
  32. */
  33. class AudioFileDropTarget : public Component,
  34. public ComponentListener,
  35. public DragAndDropTarget,
  36. public FileDragAndDropTarget
  37. {
  38. public:
  39. //==============================================================================
  40. /** Creates an AudioFileDropTarget, which controls an AudioFilePlayer.
  41. If you supply a component to attach itself to, the AudioFileDropTarget
  42. will automatically position itself around that component and pass any
  43. mouse events which are not drags onto it.
  44. @see AudioFilePlayer
  45. */
  46. AudioFileDropTarget (AudioFilePlayerExt* audioFilePlayerToControl,
  47. Component* componentToAttachTo = nullptr);
  48. /** Destructor.
  49. */
  50. ~AudioFileDropTarget();
  51. /** Sets the colour of the bezel to be drawn.
  52. */
  53. void setBezelColour (Colour& newColour);
  54. /** Retruns the current bezel colour being used.
  55. */
  56. const Colour getBezelColour() { return bezelColour; }
  57. //==============================================================================
  58. /** @internal */
  59. void paint (Graphics& g);
  60. /** @internal */
  61. bool hitTest (int x, int y);
  62. /** @internal */
  63. void mouseEnter (const MouseEvent& e);
  64. /** @internal */
  65. void mouseExit (const MouseEvent& e);
  66. //==============================================================================
  67. /** @internal */
  68. void componentMovedOrResized (Component& component,
  69. bool wasMoved,
  70. bool wasResized);
  71. //==============================================================================
  72. /** @internal */
  73. bool isInterestedInDragSource (const SourceDetails& dragSourceDetails);
  74. /** @internal */
  75. void itemDragExit (const SourceDetails& dragSourceDetails);
  76. /** @internal */
  77. void itemDropped (const SourceDetails& dragSourceDetails);
  78. //==============================================================================
  79. /** @internal */
  80. bool isInterestedInFileDrag (const StringArray& files);
  81. /** @internal */
  82. void fileDragExit (const StringArray& files);
  83. /** @internal */
  84. void filesDropped (const StringArray& files, int x, int y);
  85. private:
  86. //==============================================================================
  87. AudioFilePlayerExt* audioFilePlayer;
  88. SafePointer<Component> attachedComponent;
  89. bool dragTested, interestedInDrag;
  90. Colour bezelColour;
  91. //==============================================================================
  92. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFileDropTarget);
  93. };
  94. #endif
  95. #endif // __DROWAUDIO_AUDIOFILEDROPTARGET_H__