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) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A type of button designed to go on a toolbar.
  24. This simple button can have two Drawable objects specified - one for normal
  25. use and another one (optionally) for the button's "on" state if it's a
  26. toggle button.
  27. @see Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button
  28. */
  29. class JUCE_API ToolbarButton : public ToolbarItemComponent
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates a ToolbarButton.
  34. @param itemId the ID for this toolbar item type. This is passed through to the
  35. ToolbarItemComponent constructor
  36. @param labelText the text to display on the button (if the toolbar is using a style
  37. that shows text labels). This is passed through to the
  38. ToolbarItemComponent constructor
  39. @param normalImage a drawable object that the button should use as its icon. The object
  40. that is passed-in here will be kept by this object and will be
  41. deleted when no longer needed or when this button is deleted.
  42. @param toggledOnImage a drawable object that the button can use as its icon if the button
  43. is in a toggled-on state (see the Button::getToggleState() method). If
  44. nullptr is passed-in here, then the normal image will be used instead,
  45. regardless of the toggle state. The object that is passed-in here will be
  46. owned by this object and will be deleted when no longer needed or when
  47. this button is deleted.
  48. */
  49. ToolbarButton (int itemId,
  50. const String& labelText,
  51. Drawable* normalImage,
  52. Drawable* toggledOnImage);
  53. /** Destructor. */
  54. ~ToolbarButton();
  55. //==============================================================================
  56. /** @internal */
  57. bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize,
  58. int& minSize, int& maxSize) override;
  59. /** @internal */
  60. void paintButtonArea (Graphics&, int width, int height, bool isMouseOver, bool isMouseDown) override;
  61. /** @internal */
  62. void contentAreaChanged (const Rectangle<int>&) override;
  63. /** @internal */
  64. void buttonStateChanged() override;
  65. /** @internal */
  66. void resized() override;
  67. /** @internal */
  68. void enablementChanged() override;
  69. private:
  70. //==============================================================================
  71. ScopedPointer<Drawable> normalImage, toggledOnImage;
  72. Drawable* currentImage;
  73. void updateDrawable();
  74. Drawable* getImageToUse() const;
  75. void setCurrentImage (Drawable*);
  76. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton)
  77. };
  78. } // namespace juce