VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / buttons / juce_ShapeButton.h
blob13f5c73e194cdecbc31756e8d23bc7eb1f453525
1 /*
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
8 licensing.
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
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
31 A button that contains a filled shape.
33 @see Button, ImageButton, TextButton, ArrowButton
35 @tags{GUI}
37 class JUCE_API ShapeButton : public Button
39 public:
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,
49 Colour normalColour,
50 Colour overColour,
51 Colour downColour);
53 /** Destructor. */
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
62 the button is resized
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,
68 bool hasDropShadow);
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,
77 Colour overColour,
78 Colour downColour);
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,
88 Colour overColourOn,
89 Colour downColourOn);
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
105 drawing the shape.
107 void setBorderSize (BorderSize<int> border);
109 /** @internal */
110 void paintButton (Graphics&, bool, bool) override;
112 private:
113 //==============================================================================
114 Colour normalColour, overColour, downColour,
115 normalColourOn, overColourOn, downColourOn, outlineColour;
116 bool useOnColours;
117 DropShadowEffect shadow;
118 Path shape;
119 BorderSize<int> border;
120 bool maintainShapeProportions;
121 float outlineWidth;
123 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton)
126 } // namespace juce