juce_DrawableRectangle.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 draws a rectangle.
  24. For details on how to change the fill and stroke, see the DrawableShape class.
  25. @see Drawable, DrawableShape
  26. @tags{GUI}
  27. */
  28. class JUCE_API DrawableRectangle : public DrawableShape
  29. {
  30. public:
  31. //==============================================================================
  32. DrawableRectangle();
  33. DrawableRectangle (const DrawableRectangle&);
  34. /** Destructor. */
  35. ~DrawableRectangle() override;
  36. //==============================================================================
  37. /** Sets the rectangle's bounds. */
  38. void setRectangle (Parallelogram<float> newBounds);
  39. /** Returns the rectangle's bounds. */
  40. Parallelogram<float> getRectangle() const noexcept { return bounds; }
  41. /** Returns the corner size to be used. */
  42. Point<float> getCornerSize() const noexcept { return cornerSize; }
  43. /** Sets a new corner size for the rectangle */
  44. void setCornerSize (Point<float> newSize);
  45. //==============================================================================
  46. /** @internal */
  47. std::unique_ptr<Drawable> createCopy() const override;
  48. private:
  49. Parallelogram<float> bounds;
  50. Point<float> cornerSize;
  51. void rebuildPath();
  52. DrawableRectangle& operator= (const DrawableRectangle&);
  53. JUCE_LEAK_DETECTOR (DrawableRectangle)
  54. };
  55. } // namespace juce