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.

111 lines
4.0KB

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