Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_TOOLBARBUTTON_H_INCLUDED
  18. #define JUCE_TOOLBARBUTTON_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A type of button designed to go on a toolbar.
  22. This simple button can have two Drawable objects specified - one for normal
  23. use and another one (optionally) for the button's "on" state if it's a
  24. toggle button.
  25. @see Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button
  26. */
  27. class JUCE_API ToolbarButton : public ToolbarItemComponent
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a ToolbarButton.
  32. @param itemId the ID for this toolbar item type. This is passed through to the
  33. ToolbarItemComponent constructor
  34. @param labelText the text to display on the button (if the toolbar is using a style
  35. that shows text labels). This is passed through to the
  36. ToolbarItemComponent constructor
  37. @param normalImage a drawable object that the button should use as its icon. The object
  38. that is passed-in here will be kept by this object and will be
  39. deleted when no longer needed or when this button is deleted.
  40. @param toggledOnImage a drawable object that the button can use as its icon if the button
  41. is in a toggled-on state (see the Button::getToggleState() method). If
  42. nullptr is passed-in here, then the normal image will be used instead,
  43. regardless of the toggle state. The object that is passed-in here will be
  44. owned by this object and will be deleted when no longer needed or when
  45. this button is deleted.
  46. */
  47. ToolbarButton (int itemId,
  48. const String& labelText,
  49. Drawable* normalImage,
  50. Drawable* toggledOnImage);
  51. /** Destructor. */
  52. ~ToolbarButton();
  53. //==============================================================================
  54. /** @internal */
  55. bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize,
  56. int& minSize, int& maxSize) override;
  57. /** @internal */
  58. void paintButtonArea (Graphics&, int width, int height, bool isMouseOver, bool isMouseDown) override;
  59. /** @internal */
  60. void contentAreaChanged (const Rectangle<int>&) override;
  61. /** @internal */
  62. void buttonStateChanged() override;
  63. /** @internal */
  64. void resized() override;
  65. /** @internal */
  66. void enablementChanged() override;
  67. private:
  68. //==============================================================================
  69. ScopedPointer<Drawable> normalImage, toggledOnImage;
  70. Drawable* currentImage;
  71. void updateDrawable();
  72. Drawable* getImageToUse() const;
  73. void setCurrentImage (Drawable*);
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton)
  75. };
  76. #endif // JUCE_TOOLBARBUTTON_H_INCLUDED