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.

120 lines
4.7KB

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