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.

73 lines
2.6KB

  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. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /**
  21. A class that automatically sends analytics events to the Analytics singleton
  22. when a button is clicked.
  23. @see Analytics, AnalyticsDestination::AnalyticsEvent
  24. */
  25. class JUCE_API ButtonTracker : private Button::Listener
  26. {
  27. public:
  28. //==============================================================================
  29. /**
  30. Creating one of these automatically sends analytics events to the Analytics
  31. singeton when the corresponding button is clicked.
  32. The name and parameters of the analytics event will be populated from the
  33. variables supplied here. If clicking changes the button's state then the
  34. parameters will have a {"ButtonState", "On"/"Off"} entry added.
  35. @param buttonToTrack the button to track
  36. @param triggeredEventName the name of the generated event
  37. @param triggeredEventParameters the parameters to add to the generated
  38. event
  39. @see Analytics, AnalyticsDestination::AnalyticsEvent
  40. */
  41. ButtonTracker (Button& buttonToTrack,
  42. const String& triggeredEventName,
  43. const StringPairArray& triggeredEventParameters = {},
  44. int triggeredEventType = 0);
  45. /** Destructor. */
  46. ~ButtonTracker();
  47. private:
  48. /** @internal */
  49. void buttonClicked (Button*) override;
  50. Button& button;
  51. const String eventName;
  52. const StringPairArray eventParameters;
  53. const int eventType;
  54. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonTracker)
  55. };
  56. } // namespace juce