VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / buttons / juce_ToolbarButton.h
blobead752e0ba5319c9e74b1afe8917afc154e032d9
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 type of button designed to go on a toolbar.
33 This simple button can have two Drawable objects specified - one for normal
34 use and another one (optionally) for the button's "on" state if it's a
35 toggle button.
37 @see Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button
39 @tags{GUI}
41 class JUCE_API ToolbarButton : public ToolbarItemComponent
43 public:
44 //==============================================================================
45 /** Creates a ToolbarButton.
47 @param itemId the ID for this toolbar item type. This is passed through to the
48 ToolbarItemComponent constructor
49 @param labelText the text to display on the button (if the toolbar is using a style
50 that shows text labels). This is passed through to the
51 ToolbarItemComponent constructor
52 @param normalImage a drawable object that the button should use as its icon. The object
53 that is passed-in here will be kept by this object and will be
54 deleted when no longer needed or when this button is deleted.
55 @param toggledOnImage a drawable object that the button can use as its icon if the button
56 is in a toggled-on state (see the Button::getToggleState() method). If
57 nullptr is passed-in here, then the normal image will be used instead,
58 regardless of the toggle state. The object that is passed-in here will be
59 owned by this object and will be deleted when no longer needed or when
60 this button is deleted.
62 ToolbarButton (int itemId,
63 const String& labelText,
64 std::unique_ptr<Drawable> normalImage,
65 std::unique_ptr<Drawable> toggledOnImage);
67 /** Destructor. */
68 ~ToolbarButton() override;
71 //==============================================================================
72 /** @internal */
73 bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize,
74 int& minSize, int& maxSize) override;
75 /** @internal */
76 void paintButtonArea (Graphics&, int width, int height, bool isMouseOver, bool isMouseDown) override;
77 /** @internal */
78 void contentAreaChanged (const Rectangle<int>&) override;
79 /** @internal */
80 void buttonStateChanged() override;
81 /** @internal */
82 void resized() override;
83 /** @internal */
84 void enablementChanged() override;
86 private:
87 //==============================================================================
88 std::unique_ptr<Drawable> normalImage, toggledOnImage;
89 Drawable* currentImage = nullptr;
91 void updateDrawable();
92 Drawable* getImageToUse() const;
93 void setCurrentImage (Drawable*);
95 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton)
98 } // namespace juce