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.

juce_DrawableRectangle.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_DRAWABLERECTANGLE_H_INCLUDED
  18. #define JUCE_DRAWABLERECTANGLE_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A Drawable object which draws a rectangle.
  22. For details on how to change the fill and stroke, see the DrawableShape class.
  23. @see Drawable, DrawableShape
  24. */
  25. class JUCE_API DrawableRectangle : public DrawableShape
  26. {
  27. public:
  28. //==============================================================================
  29. DrawableRectangle();
  30. DrawableRectangle (const DrawableRectangle& other);
  31. /** Destructor. */
  32. ~DrawableRectangle();
  33. //==============================================================================
  34. /** Sets the rectangle's bounds. */
  35. void setRectangle (const RelativeParallelogram& newBounds);
  36. /** Returns the rectangle's bounds. */
  37. const RelativeParallelogram& getRectangle() const noexcept { return bounds; }
  38. /** Returns the corner size to be used. */
  39. const RelativePoint& getCornerSize() const noexcept { return cornerSize; }
  40. /** Sets a new corner size for the rectangle */
  41. void setCornerSize (const RelativePoint& newSize);
  42. //==============================================================================
  43. /** @internal */
  44. Drawable* createCopy() const;
  45. /** @internal */
  46. void refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder);
  47. /** @internal */
  48. ValueTree createValueTree (ComponentBuilder::ImageProvider* imageProvider) const;
  49. /** @internal */
  50. static const Identifier valueTreeType;
  51. //==============================================================================
  52. /** Internally-used class for wrapping a DrawableRectangle's state into a ValueTree. */
  53. class ValueTreeWrapper : public DrawableShape::FillAndStrokeState
  54. {
  55. public:
  56. ValueTreeWrapper (const ValueTree& state);
  57. RelativeParallelogram getRectangle() const;
  58. void setRectangle (const RelativeParallelogram& newBounds, UndoManager*);
  59. void setCornerSize (const RelativePoint& cornerSize, UndoManager*);
  60. RelativePoint getCornerSize() const;
  61. Value getCornerSizeValue (UndoManager*);
  62. static const Identifier topLeft, topRight, bottomLeft, cornerSize;
  63. };
  64. private:
  65. friend class Drawable::Positioner<DrawableRectangle>;
  66. RelativeParallelogram bounds;
  67. RelativePoint cornerSize;
  68. void rebuildPath();
  69. bool registerCoordinates (RelativeCoordinatePositionerBase&);
  70. void recalculateCoordinates (Expression::Scope*);
  71. DrawableRectangle& operator= (const DrawableRectangle&);
  72. JUCE_LEAK_DETECTOR (DrawableRectangle)
  73. };
  74. #endif // JUCE_DRAWABLERECTANGLE_H_INCLUDED