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.

87 lines
3.1KB

  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. #pragma once
  19. #include "jucer_ComponentOverlayComponent.h"
  20. #include "../jucer_JucerDocument.h"
  21. #include "jucer_SnapGridPainter.h"
  22. //==============================================================================
  23. class ComponentLayoutEditor : public Component,
  24. public FileDragAndDropTarget,
  25. public DragAndDropTarget,
  26. public LassoSource<Component*>,
  27. private ChangeListener
  28. {
  29. public:
  30. //==============================================================================
  31. ComponentLayoutEditor (JucerDocument&, ComponentLayout&);
  32. ~ComponentLayoutEditor() override;
  33. //==============================================================================
  34. void paint (Graphics&) override;
  35. void resized() override;
  36. void visibilityChanged() override;
  37. void mouseDown (const MouseEvent&) override;
  38. void mouseDrag (const MouseEvent&) override;
  39. void mouseUp (const MouseEvent&) override;
  40. bool keyPressed (const KeyPress&) override;
  41. bool isInterestedInFileDrag (const StringArray& files) override;
  42. void filesDropped (const StringArray& filenames, int x, int y) override;
  43. bool isInterestedInDragSource (const SourceDetails& dragSourceDetails) override;
  44. void itemDropped (const SourceDetails& dragSourceDetails) override;
  45. ComponentLayout& getLayout() const noexcept { return layout; }
  46. void findLassoItemsInArea (Array <Component*>& results, const Rectangle<int>& area) override;
  47. SelectedItemSet<Component*>& getLassoSelection() override;
  48. //==============================================================================
  49. void refreshAllComponents();
  50. void updateOverlayPositions();
  51. ComponentOverlayComponent* getOverlayCompFor (Component*) const;
  52. Rectangle<int> getComponentArea() const;
  53. Image createComponentLayerSnapshot() const;
  54. private:
  55. void changeListenerCallback (ChangeBroadcaster*) override;
  56. JucerDocument& document;
  57. ComponentLayout& layout;
  58. Component* subCompHolder;
  59. LassoComponent<Component*> lassoComp;
  60. SnapGridPainter grid;
  61. bool firstResize;
  62. };