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.

157 lines
6.4KB

  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 JUCE_DRAWABLECOMPOSITE_H_INCLUDED
  18. #define JUCE_DRAWABLECOMPOSITE_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A drawable object which acts as a container for a set of other Drawables.
  22. @see Drawable
  23. */
  24. class JUCE_API DrawableComposite : public Drawable
  25. {
  26. public:
  27. //==============================================================================
  28. /** Creates a composite Drawable. */
  29. DrawableComposite();
  30. /** Creates a copy of a DrawableComposite. */
  31. DrawableComposite (const DrawableComposite& other);
  32. /** Destructor. */
  33. ~DrawableComposite();
  34. //==============================================================================
  35. /** Sets the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  36. @see setContentArea
  37. */
  38. void setBoundingBox (const RelativeParallelogram& newBoundingBox);
  39. /** Returns the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  40. @see setBoundingBox
  41. */
  42. const RelativeParallelogram& getBoundingBox() const noexcept { return bounds; }
  43. /** Changes the bounding box transform to match the content area, so that any sub-items will
  44. be drawn at their untransformed positions.
  45. */
  46. void resetBoundingBoxToContentArea();
  47. /** Returns the main content rectangle.
  48. The content area is actually defined by the markers named "left", "right", "top" and
  49. "bottom", but this method is a shortcut that returns them all at once.
  50. @see contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  51. */
  52. RelativeRectangle getContentArea() const;
  53. /** Changes the main content area.
  54. The content area is actually defined by the markers named "left", "right", "top" and
  55. "bottom", but this method is a shortcut that sets them all at once.
  56. @see setBoundingBox, contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  57. */
  58. void setContentArea (const RelativeRectangle& newArea);
  59. /** Resets the content area and the bounding transform to fit around the area occupied
  60. by the child components (ignoring any markers).
  61. */
  62. void resetContentAreaAndBoundingBoxToFitChildren();
  63. //==============================================================================
  64. /** The name of the marker that defines the left edge of the content area. */
  65. static const char* const contentLeftMarkerName;
  66. /** The name of the marker that defines the right edge of the content area. */
  67. static const char* const contentRightMarkerName;
  68. /** The name of the marker that defines the top edge of the content area. */
  69. static const char* const contentTopMarkerName;
  70. /** The name of the marker that defines the bottom edge of the content area. */
  71. static const char* const contentBottomMarkerName;
  72. //==============================================================================
  73. /** @internal */
  74. Drawable* createCopy() const;
  75. /** @internal */
  76. void refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder);
  77. /** @internal */
  78. ValueTree createValueTree (ComponentBuilder::ImageProvider* imageProvider) const;
  79. /** @internal */
  80. static const Identifier valueTreeType;
  81. /** @internal */
  82. Rectangle<float> getDrawableBounds() const;
  83. /** @internal */
  84. void childBoundsChanged (Component*) override;
  85. /** @internal */
  86. void childrenChanged() override;
  87. /** @internal */
  88. void parentHierarchyChanged() override;
  89. /** @internal */
  90. MarkerList* getMarkers (bool xAxis) override;
  91. //==============================================================================
  92. /** Internally-used class for wrapping a DrawableComposite's state into a ValueTree. */
  93. class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase
  94. {
  95. public:
  96. ValueTreeWrapper (const ValueTree& state);
  97. ValueTree getChildList() const;
  98. ValueTree getChildListCreating (UndoManager* undoManager);
  99. RelativeParallelogram getBoundingBox() const;
  100. void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager);
  101. void resetBoundingBoxToContentArea (UndoManager* undoManager);
  102. RelativeRectangle getContentArea() const;
  103. void setContentArea (const RelativeRectangle& newArea, UndoManager* undoManager);
  104. MarkerList::ValueTreeWrapper getMarkerList (bool xAxis) const;
  105. MarkerList::ValueTreeWrapper getMarkerListCreating (bool xAxis, UndoManager* undoManager);
  106. static const Identifier topLeft, topRight, bottomLeft;
  107. private:
  108. static const Identifier childGroupTag, markerGroupTagX, markerGroupTagY;
  109. };
  110. private:
  111. //==============================================================================
  112. RelativeParallelogram bounds;
  113. MarkerList markersX, markersY;
  114. bool updateBoundsReentrant;
  115. friend class Drawable::Positioner<DrawableComposite>;
  116. bool registerCoordinates (RelativeCoordinatePositionerBase&);
  117. void recalculateCoordinates (Expression::Scope*);
  118. void updateBoundsToFitChildren();
  119. DrawableComposite& operator= (const DrawableComposite&);
  120. JUCE_LEAK_DETECTOR (DrawableComposite)
  121. };
  122. #endif // JUCE_DRAWABLECOMPOSITE_H_INCLUDED