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.

119 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A drawable object which acts as a container for a set of other Drawables.
  24. Note that although this is a Component, it takes ownership of its child components
  25. and will delete them, so that you can use it as a self-contained graphic object.
  26. The intention is that you should not add your own components to it, only add other
  27. Drawable objects.
  28. @see Drawable
  29. @tags{GUI}
  30. */
  31. class JUCE_API DrawableComposite : public Drawable
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates a composite Drawable. */
  36. DrawableComposite();
  37. /** Creates a copy of a DrawableComposite. */
  38. DrawableComposite (const DrawableComposite&);
  39. /** Destructor. */
  40. ~DrawableComposite();
  41. //==============================================================================
  42. /** Sets the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  43. @see setContentArea
  44. */
  45. void setBoundingBox (Parallelogram<float> newBoundingBox);
  46. /** Sets the rectangle that defines the target position of the content rectangle when the drawable is rendered.
  47. @see setContentArea
  48. */
  49. void setBoundingBox (Rectangle<float> newBoundingBox);
  50. /** Returns the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
  51. @see setBoundingBox
  52. */
  53. Parallelogram<float> getBoundingBox() const noexcept { return bounds; }
  54. /** Changes the bounding box transform to match the content area, so that any sub-items will
  55. be drawn at their untransformed positions.
  56. */
  57. void resetBoundingBoxToContentArea();
  58. /** Returns the main content rectangle.
  59. @see contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  60. */
  61. Rectangle<float> getContentArea() const noexcept { return contentArea; }
  62. /** Changes the main content area.
  63. @see setBoundingBox, contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
  64. */
  65. void setContentArea (Rectangle<float> newArea);
  66. /** Resets the content area and the bounding transform to fit around the area occupied
  67. by the child components.
  68. */
  69. void resetContentAreaAndBoundingBoxToFitChildren();
  70. //==============================================================================
  71. /** @internal */
  72. Drawable* createCopy() const override;
  73. /** @internal */
  74. Rectangle<float> getDrawableBounds() const override;
  75. /** @internal */
  76. void childBoundsChanged (Component*) override;
  77. /** @internal */
  78. void childrenChanged() override;
  79. /** @internal */
  80. void parentHierarchyChanged() override;
  81. /** @internal */
  82. Path getOutlineAsPath() const override;
  83. private:
  84. //==============================================================================
  85. Parallelogram<float> bounds;
  86. Rectangle<float> contentArea;
  87. bool updateBoundsReentrant = false;
  88. void updateBoundsToFitChildren();
  89. DrawableComposite& operator= (const DrawableComposite&);
  90. JUCE_LEAK_DETECTOR (DrawableComposite)
  91. };
  92. } // namespace juce