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_ShapeButton.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_SHAPEBUTTON_H_INCLUDED
  18. #define JUCE_SHAPEBUTTON_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A button that contains a filled shape.
  22. @see Button, ImageButton, TextButton, ArrowButton
  23. */
  24. class JUCE_API ShapeButton : public Button
  25. {
  26. public:
  27. //==============================================================================
  28. /** Creates a ShapeButton.
  29. @param name a name to give the component - see Component::setName()
  30. @param normalColour the colour to fill the shape with when the mouse isn't over
  31. @param overColour the colour to use when the mouse is over the shape
  32. @param downColour the colour to use when the button is in the pressed-down state
  33. */
  34. ShapeButton (const String& name,
  35. Colour normalColour,
  36. Colour overColour,
  37. Colour downColour);
  38. /** Destructor. */
  39. ~ShapeButton();
  40. //==============================================================================
  41. /** Sets the shape to use.
  42. @param newShape the shape to use
  43. @param resizeNowToFitThisShape if true, the button will be resized to fit the shape's bounds
  44. @param maintainShapeProportions if true, the shape's proportions will be kept fixed when
  45. the button is resized
  46. @param hasDropShadow if true, the button will be given a drop-shadow effect
  47. */
  48. void setShape (const Path& newShape,
  49. bool resizeNowToFitThisShape,
  50. bool maintainShapeProportions,
  51. bool hasDropShadow);
  52. /** Set the colours to use for drawing the shape.
  53. @param normalColour the colour to fill the shape with when the mouse isn't over
  54. @param overColour the colour to use when the mouse is over the shape
  55. @param downColour the colour to use when the button is in the pressed-down state
  56. */
  57. void setColours (Colour normalColour,
  58. Colour overColour,
  59. Colour downColour);
  60. /** Sets up an outline to draw around the shape.
  61. @param outlineColour the colour to use
  62. @param outlineStrokeWidth the thickness of line to draw
  63. */
  64. void setOutline (Colour outlineColour, float outlineStrokeWidth);
  65. /** This lets you specify a border to be left around the edge of the button when
  66. drawing the shape.
  67. */
  68. void setBorderSize (BorderSize<int> border);
  69. /** @internal */
  70. void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override;
  71. private:
  72. //==============================================================================
  73. Colour normalColour, overColour, downColour, outlineColour;
  74. DropShadowEffect shadow;
  75. Path shape;
  76. BorderSize<int> border;
  77. bool maintainShapeProportions;
  78. float outlineWidth;
  79. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton)
  80. };
  81. #endif // JUCE_SHAPEBUTTON_H_INCLUDED