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.

88 lines
2.9KB

  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. #pragma once
  20. #include "../jucer_JucerDocument.h"
  21. #include "../jucer_PaintRoutine.h"
  22. #include "jucer_SnapGridPainter.h"
  23. class JucerDocumentEditor;
  24. //==============================================================================
  25. /**
  26. */
  27. class PaintRoutineEditor : public Component,
  28. public ChangeListener,
  29. public LassoSource <PaintElement*>,
  30. public FileDragAndDropTarget
  31. {
  32. public:
  33. //==============================================================================
  34. PaintRoutineEditor (PaintRoutine& graphics,
  35. JucerDocument& document,
  36. JucerDocumentEditor* const docHolder);
  37. ~PaintRoutineEditor();
  38. //==============================================================================
  39. void paint (Graphics& g);
  40. void paintOverChildren (Graphics& g);
  41. void resized();
  42. void changeListenerCallback (ChangeBroadcaster*);
  43. void mouseDown (const MouseEvent& e);
  44. void mouseDrag (const MouseEvent& e);
  45. void mouseUp (const MouseEvent& e);
  46. void visibilityChanged();
  47. void findLassoItemsInArea (Array <PaintElement*>& results, const Rectangle<int>& area);
  48. SelectedItemSet <PaintElement*>& getLassoSelection();
  49. bool isInterestedInFileDrag (const StringArray& files);
  50. void filesDropped (const StringArray& filenames, int x, int y);
  51. Rectangle<int> getComponentArea() const;
  52. //==============================================================================
  53. void refreshAllElements();
  54. private:
  55. PaintRoutine& graphics;
  56. JucerDocument& document;
  57. JucerDocumentEditor* const documentHolder;
  58. LassoComponent <PaintElement*> lassoComp;
  59. SnapGridPainter grid;
  60. Image componentOverlay;
  61. float componentOverlayOpacity;
  62. Colour currentBackgroundColour;
  63. void removeAllElementComps();
  64. void updateComponentOverlay();
  65. void updateChildBounds();
  66. };