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 component that simply displays an image.
33 Use setImage to give it an image, and it'll display it - simple as that!
37 class JUCE_API ImageComponent
: public Component
,
38 public SettableTooltipClient
41 //==============================================================================
42 /** Creates an ImageComponent. */
43 ImageComponent (const String
& componentName
= String());
46 ~ImageComponent() override
;
48 //==============================================================================
49 /** Sets the image that should be displayed. */
50 void setImage (const Image
& newImage
);
52 /** Sets the image that should be displayed, and its placement within the component. */
53 void setImage (const Image
& newImage
,
54 RectanglePlacement placementToUse
);
56 /** Returns the current image. */
57 const Image
& getImage() const;
59 /** Sets the method of positioning that will be used to fit the image within the component's bounds.
60 By default the positioning is centred, and will fit the image inside the component's bounds
61 whilst keeping its aspect ratio correct, but you can change it to whatever layout you need.
63 void setImagePlacement (RectanglePlacement newPlacement
);
65 /** Returns the current image placement. */
66 RectanglePlacement
getImagePlacement() const;
68 //==============================================================================
70 void paint (Graphics
&) override
;
73 std::unique_ptr
<AccessibilityHandler
> createAccessibilityHandler() override
;
76 RectanglePlacement placement
;
78 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageComponent
)