2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
23 ==============================================================================
29 //==============================================================================
31 A button that contains a filled shape.
33 @see Button, ImageButton, TextButton, ArrowButton
37 class JUCE_API ShapeButton
: public Button
40 //==============================================================================
41 /** Creates a ShapeButton.
43 @param name a name to give the component - see Component::setName()
44 @param normalColour the colour to fill the shape with when the mouse isn't over
45 @param overColour the colour to use when the mouse is over the shape
46 @param downColour the colour to use when the button is in the pressed-down state
48 ShapeButton (const String
& name
,
54 ~ShapeButton() override
;
56 //==============================================================================
57 /** Sets the shape to use.
59 @param newShape the shape to use
60 @param resizeNowToFitThisShape if true, the button will be resized to fit the shape's bounds
61 @param maintainShapeProportions if true, the shape's proportions will be kept fixed when
63 @param hasDropShadow if true, the button will be given a drop-shadow effect
65 void setShape (const Path
& newShape
,
66 bool resizeNowToFitThisShape
,
67 bool maintainShapeProportions
,
70 /** Set the colours to use for drawing the shape.
72 @param normalColour the colour to fill the shape with when the mouse isn't over
73 @param overColour the colour to use when the mouse is over the shape
74 @param downColour the colour to use when the button is in the pressed-down state
76 void setColours (Colour normalColour
,
80 /** Sets the colours to use for drawing the shape when the button's toggle state is 'on'. To enable this behaviour, use the
81 shouldUseOnColours() method.
83 @param normalColourOn the colour to fill the shape with when the mouse isn't over and the button's toggle state is 'on'
84 @param overColourOn the colour to use when the mouse is over the shape and the button's toggle state is 'on'
85 @param downColourOn the colour to use when the button is in the pressed-down state and the button's toggle state is 'on'
87 void setOnColours (Colour normalColourOn
,
91 /** Set whether the button should use the 'on' set of colours when its toggle state is 'on'.
92 By default these will be the same as the normal colours but the setOnColours method can be
93 used to provide a different set of colours.
95 void shouldUseOnColours (bool shouldUse
);
97 /** Sets up an outline to draw around the shape.
99 @param outlineColour the colour to use
100 @param outlineStrokeWidth the thickness of line to draw
102 void setOutline (Colour outlineColour
, float outlineStrokeWidth
);
104 /** This lets you specify a border to be left around the edge of the button when
107 void setBorderSize (BorderSize
<int> border
);
110 void paintButton (Graphics
&, bool, bool) override
;
113 //==============================================================================
114 Colour normalColour
, overColour
, downColour
,
115 normalColourOn
, overColourOn
, downColourOn
, outlineColour
;
117 DropShadowEffect shadow
;
119 BorderSize
<int> border
;
120 bool maintainShapeProportions
;
123 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton
)