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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A button that contains a filled shape.
  23. @see Button, ImageButton, TextButton, ArrowButton
  24. @tags{GUI}
  25. */
  26. class JUCE_API ShapeButton : public Button
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a ShapeButton.
  31. @param name a name to give the component - see Component::setName()
  32. @param normalColour the colour to fill the shape with when the mouse isn't over
  33. @param overColour the colour to use when the mouse is over the shape
  34. @param downColour the colour to use when the button is in the pressed-down state
  35. */
  36. ShapeButton (const String& name,
  37. Colour normalColour,
  38. Colour overColour,
  39. Colour downColour);
  40. /** Destructor. */
  41. ~ShapeButton() override;
  42. //==============================================================================
  43. /** Sets the shape to use.
  44. @param newShape the shape to use
  45. @param resizeNowToFitThisShape if true, the button will be resized to fit the shape's bounds
  46. @param maintainShapeProportions if true, the shape's proportions will be kept fixed when
  47. the button is resized
  48. @param hasDropShadow if true, the button will be given a drop-shadow effect
  49. */
  50. void setShape (const Path& newShape,
  51. bool resizeNowToFitThisShape,
  52. bool maintainShapeProportions,
  53. bool hasDropShadow);
  54. /** Set the colours to use for drawing the shape.
  55. @param normalColour the colour to fill the shape with when the mouse isn't over
  56. @param overColour the colour to use when the mouse is over the shape
  57. @param downColour the colour to use when the button is in the pressed-down state
  58. */
  59. void setColours (Colour normalColour,
  60. Colour overColour,
  61. Colour downColour);
  62. /** Sets the colours to use for drawing the shape when the button's toggle state is 'on'. To enable this behaviour, use the
  63. shouldUseOnColours() method.
  64. @param normalColourOn the colour to fill the shape with when the mouse isn't over and the button's toggle state is 'on'
  65. @param overColourOn the colour to use when the mouse is over the shape and the button's toggle state is 'on'
  66. @param downColourOn the colour to use when the button is in the pressed-down state and the button's toggle state is 'on'
  67. */
  68. void setOnColours (Colour normalColourOn,
  69. Colour overColourOn,
  70. Colour downColourOn);
  71. /** Set whether the button should use the 'on' set of colours when its toggle state is 'on'.
  72. By default these will be the same as the normal colours but the setOnColours method can be
  73. used to provide a different set of colours.
  74. */
  75. void shouldUseOnColours (bool shouldUse);
  76. /** Sets up an outline to draw around the shape.
  77. @param outlineColour the colour to use
  78. @param outlineStrokeWidth the thickness of line to draw
  79. */
  80. void setOutline (Colour outlineColour, float outlineStrokeWidth);
  81. /** This lets you specify a border to be left around the edge of the button when
  82. drawing the shape.
  83. */
  84. void setBorderSize (BorderSize<int> border);
  85. /** @internal */
  86. void paintButton (Graphics&, bool, bool) override;
  87. private:
  88. //==============================================================================
  89. Colour normalColour, overColour, downColour,
  90. normalColourOn, overColourOn, downColourOn, outlineColour;
  91. bool useOnColours;
  92. DropShadowEffect shadow;
  93. Path shape;
  94. BorderSize<int> border;
  95. bool maintainShapeProportions;
  96. float outlineWidth;
  97. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton)
  98. };
  99. } // namespace juce