Audio plugin host https://kx.studio/carla
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.

118 lines
4.2KB

  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. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A drawable object which acts as a container for a set of other Drawables.
  23. Note that although this is a Component, it takes ownership of its child components
  24. and will delete them, so that you can use it as a self-contained graphic object.
  25. The intention is that you should not add your own components to it, only add other
  26. Drawable objects.
  27. @see Drawable
  28. @tags{GUI}
  29. */
  30. class JUCE_API DrawableComposite : public Drawable
  31. {
  32. public:
  33. //==============================================================================
  34. /** Creates a composite Drawable. */
  35. DrawableComposite();
  36. /** Creates a copy of a DrawableComposite. */
  37. DrawableComposite (const DrawableComposite&);
  38. /** Destructor. */
  39. ~DrawableComposite() override;
  40. //==============================================================================
  41. /** Sets the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  42. @see setContentArea
  43. */
  44. void setBoundingBox (Parallelogram<float> newBoundingBox);
  45. /** Sets the rectangle that defines the target position of the content rectangle when the drawable is rendered.
  46. @see setContentArea
  47. */
  48. void setBoundingBox (Rectangle<float> newBoundingBox);
  49. /** Returns the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  50. @see setBoundingBox
  51. */
  52. Parallelogram<float> getBoundingBox() const noexcept { return bounds; }
  53. /** Changes the bounding box transform to match the content area, so that any sub-items will
  54. be drawn at their untransformed positions.
  55. */
  56. void resetBoundingBoxToContentArea();
  57. /** Returns the main content rectangle.
  58. @see contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  59. */
  60. Rectangle<float> getContentArea() const noexcept { return contentArea; }
  61. /** Changes the main content area.
  62. @see setBoundingBox, contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  63. */
  64. void setContentArea (Rectangle<float> newArea);
  65. /** Resets the content area and the bounding transform to fit around the area occupied
  66. by the child components.
  67. */
  68. void resetContentAreaAndBoundingBoxToFitChildren();
  69. //==============================================================================
  70. /** @internal */
  71. std::unique_ptr<Drawable> createCopy() const override;
  72. /** @internal */
  73. Rectangle<float> getDrawableBounds() const override;
  74. /** @internal */
  75. void childBoundsChanged (Component*) override;
  76. /** @internal */
  77. void childrenChanged() override;
  78. /** @internal */
  79. void parentHierarchyChanged() override;
  80. /** @internal */
  81. Path getOutlineAsPath() const override;
  82. private:
  83. //==============================================================================
  84. Parallelogram<float> bounds;
  85. Rectangle<float> contentArea;
  86. bool updateBoundsReentrant = false;
  87. void updateBoundsToFitChildren();
  88. DrawableComposite& operator= (const DrawableComposite&);
  89. JUCE_LEAK_DETECTOR (DrawableComposite)
  90. };
  91. } // namespace juce