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.

105 lines
3.9KB

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