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.

79 lines
2.8KB

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