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.

juce_BooleanPropertyComponent.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A PropertyComponent that contains an on/off toggle button.
  23. This type of property component can be used if you have a boolean value to
  24. toggle on/off.
  25. @see PropertyComponent
  26. @tags{GUI}
  27. */
  28. class JUCE_API BooleanPropertyComponent : public PropertyComponent
  29. {
  30. protected:
  31. //==============================================================================
  32. /** Creates a button component.
  33. If you use this constructor, you must override the getState() and setState()
  34. methods.
  35. @param propertyName the property name to be passed to the PropertyComponent
  36. @param buttonTextWhenTrue the text shown in the button when the value is true
  37. @param buttonTextWhenFalse the text shown in the button when the value is false
  38. */
  39. BooleanPropertyComponent (const String& propertyName,
  40. const String& buttonTextWhenTrue,
  41. const String& buttonTextWhenFalse);
  42. public:
  43. /** Creates a button component.
  44. Note that if you call this constructor then you must use the Value to interact with the
  45. button state, and you can't override the class with your own setState or getState methods.
  46. If you want to use getState and setState, call the other constructor instead.
  47. @param valueToControl a Value object that this property should refer to.
  48. @param propertyName the property name to be passed to the PropertyComponent
  49. @param buttonText the text shown in the ToggleButton component
  50. */
  51. BooleanPropertyComponent (const Value& valueToControl,
  52. const String& propertyName,
  53. const String& buttonText);
  54. /** Destructor. */
  55. ~BooleanPropertyComponent() override;
  56. //==============================================================================
  57. /** Called to change the state of the boolean value. */
  58. virtual void setState (bool newState);
  59. /** Must return the current value of the property. */
  60. virtual bool getState() const;
  61. //==============================================================================
  62. /** A set of colour IDs to use to change the colour of various aspects of the component.
  63. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  64. methods.
  65. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  66. */
  67. enum ColourIds
  68. {
  69. backgroundColourId = 0x100e801, /**< The colour to fill the background of the button area. */
  70. outlineColourId = 0x100e803, /**< The colour to use to draw an outline around the text area. */
  71. };
  72. //==============================================================================
  73. /** @internal */
  74. void paint (Graphics&) override;
  75. /** @internal */
  76. void refresh() override;
  77. private:
  78. ToggleButton button;
  79. String onText, offText;
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BooleanPropertyComponent)
  81. };
  82. } // namespace juce