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.

92 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCER_COMPONENTLAYOUTEDITOR_JUCEHEADER__
  18. #define __JUCER_COMPONENTLAYOUTEDITOR_JUCEHEADER__
  19. #include "jucer_ComponentOverlayComponent.h"
  20. #include "../jucer_JucerDocument.h"
  21. #include "jucer_SnapGridPainter.h"
  22. //==============================================================================
  23. /**
  24. */
  25. class ComponentLayoutEditor : public Component,
  26. public ChangeListener,
  27. public FileDragAndDropTarget,
  28. public DragAndDropTarget,
  29. public LassoSource<Component*>
  30. {
  31. public:
  32. //==============================================================================
  33. ComponentLayoutEditor (JucerDocument& document, ComponentLayout& layout);
  34. ~ComponentLayoutEditor();
  35. //==============================================================================
  36. void paint (Graphics&) override;
  37. void resized() override;
  38. void visibilityChanged() override;
  39. void changeListenerCallback (ChangeBroadcaster*) override;
  40. void mouseDown (const MouseEvent&) override;
  41. void mouseDrag (const MouseEvent&) override;
  42. void mouseUp (const MouseEvent&) override;
  43. bool keyPressed (const KeyPress&) override;
  44. bool isInterestedInFileDrag (const StringArray& files) override;
  45. void filesDropped (const StringArray& filenames, int x, int y) override;
  46. bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) override;
  47. void itemDropped (const SourceDetails& dragSourceDetails) override;
  48. ComponentLayout& getLayout() const noexcept { return layout; }
  49. void findLassoItemsInArea (Array <Component*>& results, const Rectangle<int>& area);
  50. SelectedItemSet<Component*>& getLassoSelection();
  51. //==============================================================================
  52. void refreshAllComponents();
  53. void updateOverlayPositions();
  54. ComponentOverlayComponent* getOverlayCompFor (Component*) const;
  55. Rectangle<int> getComponentArea() const;
  56. Image createComponentLayerSnapshot() const;
  57. private:
  58. JucerDocument& document;
  59. ComponentLayout& layout;
  60. Component* subCompHolder;
  61. LassoComponent<Component*> lassoComp;
  62. SnapGridPainter grid;
  63. bool firstResize;
  64. };
  65. #endif // __JUCER_COMPONENTLAYOUTEDITOR_JUCEHEADER__