The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

59 lines
1.8KB

  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. #pragma once
  18. template <class ComponentType>
  19. class ComponentBooleanProperty : public BooleanPropertyComponent,
  20. private ChangeListener
  21. {
  22. public:
  23. ComponentBooleanProperty (const String& name,
  24. const String& onText_,
  25. const String& offText_,
  26. ComponentType* comp,
  27. JucerDocument& doc)
  28. : BooleanPropertyComponent (name, onText_, offText_),
  29. component (comp),
  30. document (doc)
  31. {
  32. document.addChangeListener (this);
  33. }
  34. ~ComponentBooleanProperty()
  35. {
  36. document.removeChangeListener (this);
  37. }
  38. void changeListenerCallback (ChangeBroadcaster*)
  39. {
  40. refresh();
  41. }
  42. protected:
  43. ComponentType* component;
  44. JucerDocument& document;
  45. };