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.

108 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_DRAWABLERECTANGLE_JUCEHEADER__
  19. #define __JUCE_DRAWABLERECTANGLE_JUCEHEADER__
  20. #include "juce_DrawableShape.h"
  21. #include "../positioning/juce_RelativeParallelogram.h"
  22. //==============================================================================
  23. /**
  24. A Drawable object which draws a rectangle.
  25. For details on how to change the fill and stroke, see the DrawableShape class.
  26. @see Drawable, DrawableShape
  27. */
  28. class JUCE_API DrawableRectangle : public DrawableShape
  29. {
  30. public:
  31. //==============================================================================
  32. DrawableRectangle();
  33. DrawableRectangle (const DrawableRectangle& other);
  34. /** Destructor. */
  35. ~DrawableRectangle();
  36. //==============================================================================
  37. /** Sets the rectangle's bounds. */
  38. void setRectangle (const RelativeParallelogram& newBounds);
  39. /** Returns the rectangle's bounds. */
  40. const RelativeParallelogram& getRectangle() const noexcept { return bounds; }
  41. /** Returns the corner size to be used. */
  42. const RelativePoint& getCornerSize() const noexcept { return cornerSize; }
  43. /** Sets a new corner size for the rectangle */
  44. void setCornerSize (const RelativePoint& newSize);
  45. //==============================================================================
  46. /** @internal */
  47. Drawable* createCopy() const;
  48. /** @internal */
  49. void refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder);
  50. /** @internal */
  51. ValueTree createValueTree (ComponentBuilder::ImageProvider* imageProvider) const;
  52. /** @internal */
  53. static const Identifier valueTreeType;
  54. //==============================================================================
  55. /** Internally-used class for wrapping a DrawableRectangle's state into a ValueTree. */
  56. class ValueTreeWrapper : public DrawableShape::FillAndStrokeState
  57. {
  58. public:
  59. ValueTreeWrapper (const ValueTree& state);
  60. RelativeParallelogram getRectangle() const;
  61. void setRectangle (const RelativeParallelogram& newBounds, UndoManager*);
  62. void setCornerSize (const RelativePoint& cornerSize, UndoManager*);
  63. RelativePoint getCornerSize() const;
  64. Value getCornerSizeValue (UndoManager*) const;
  65. static const Identifier topLeft, topRight, bottomLeft, cornerSize;
  66. };
  67. private:
  68. friend class Drawable::Positioner<DrawableRectangle>;
  69. RelativeParallelogram bounds;
  70. RelativePoint cornerSize;
  71. void rebuildPath();
  72. bool registerCoordinates (RelativeCoordinatePositionerBase&);
  73. void recalculateCoordinates (Expression::Scope*);
  74. DrawableRectangle& operator= (const DrawableRectangle&);
  75. JUCE_LEAK_DETECTOR (DrawableRectangle);
  76. };
  77. #endif // __JUCE_DRAWABLERECTANGLE_JUCEHEADER__