openshot-audio  0.1.6
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_IMAGEBUTTON_H_INCLUDED
26 #define JUCE_IMAGEBUTTON_H_INCLUDED
27 
28 
29 //==============================================================================
38 class JUCE_API ImageButton : public Button
39 {
40 public:
41  //==============================================================================
49  explicit ImageButton (const String& name = String::empty);
50 
52  ~ImageButton();
53 
54  //==============================================================================
96  void setImages (bool resizeButtonNowToFitThisImage,
97  bool rescaleImagesWhenButtonSizeChanges,
98  bool preserveImageProportions,
99  const Image& normalImage,
100  float imageOpacityWhenNormal,
101  Colour overlayColourWhenNormal,
102  const Image& overImage,
103  float imageOpacityWhenOver,
104  Colour overlayColourWhenOver,
105  const Image& downImage,
106  float imageOpacityWhenDown,
107  Colour overlayColourWhenDown,
108  float hitTestAlphaThreshold = 0.0f);
109 
111  Image getNormalImage() const;
112 
118  Image getOverImage() const;
119 
125  Image getDownImage() const;
126 
127  //==============================================================================
130  {
131  virtual ~LookAndFeelMethods() {}
132 
133  virtual void drawImageButton (Graphics&, Image*,
134  int imageX, int imageY, int imageW, int imageH,
135  const Colour& overlayColour, float imageOpacity, ImageButton&) = 0;
136  };
137 
138 protected:
139  //==============================================================================
141  bool hitTest (int x, int y) override;
143  void paintButton (Graphics&, bool isMouseOver, bool isButtonDown) override;
144 
145 private:
146  //==============================================================================
147  bool scaleImageToFit, preserveProportions;
148  uint8 alphaThreshold;
149  Rectangle<int> imageBounds;
150  Image normalImage, overImage, downImage;
151  float normalOpacity, overOpacity, downOpacity;
152  Colour normalOverlay, overOverlay, downOverlay;
153 
154  Image getCurrentImage() const;
155 
157 };
158 
159 
160 #endif // JUCE_IMAGEBUTTON_H_INCLUDED
virtual ~LookAndFeelMethods()
Definition: juce_ImageButton.h:131
Definition: juce_ImageButton.h:129
static const String empty
Definition: juce_String.h:152
Definition: juce_Button.h:39
Definition: juce_String.h:43
Definition: juce_ImageButton.h:38
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_Rectangle.h:36
Definition: juce_Colour.h:35
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
Definition: juce_Image.h:54
unsigned char uint8
Definition: juce_MathsFunctions.h:43