JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ImageButton.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
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.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
40class JUCE_API ImageButton : public Button
41{
42public:
43 //==============================================================================
51 explicit ImageButton (const String& name = String());
52
54 ~ImageButton() override;
55
56 //==============================================================================
98 void setImages (bool resizeButtonNowToFitThisImage,
99 bool rescaleImagesWhenButtonSizeChanges,
100 bool preserveImageProportions,
101 const Image& normalImage,
102 float imageOpacityWhenNormal,
103 Colour overlayColourWhenNormal,
104 const Image& overImage,
105 float imageOpacityWhenOver,
106 Colour overlayColourWhenOver,
107 const Image& downImage,
108 float imageOpacityWhenDown,
109 Colour overlayColourWhenDown,
110 float hitTestAlphaThreshold = 0.0f);
111
113 Image getNormalImage() const;
114
120 Image getOverImage() const;
121
127 Image getDownImage() const;
128
129 //==============================================================================
131 struct JUCE_API LookAndFeelMethods
132 {
133 virtual ~LookAndFeelMethods() = default;
134
135 virtual void drawImageButton (Graphics&, Image*,
136 int imageX, int imageY, int imageW, int imageH,
137 const Colour& overlayColour, float imageOpacity, ImageButton&) = 0;
138 };
139
140protected:
141 //==============================================================================
143 bool hitTest (int x, int y) override;
145 void paintButton (Graphics&, bool, bool) override;
146
147private:
148 //==============================================================================
149 bool scaleImageToFit, preserveProportions;
150 uint8 alphaThreshold;
151 Rectangle<int> imageBounds;
152 Image normalImage, overImage, downImage;
153 float normalOpacity, overOpacity, downOpacity;
154 Colour normalOverlay, overOverlay, downOverlay;
155
156 Image getCurrentImage() const;
157
159};
160
161} // namespace juce
A base class for buttons.
Definition juce_Button.h:43
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
A graphics context, used for drawing a component or image.
As the title suggests, this is a button containing an image.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Manages a rectangle and allows geometric operations to be performed on it.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
This abstract base class is implemented by LookAndFeel classes.