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.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. A class that automatically sends analytics events to the Analytics singleton
  18. when a button is clicked.
  19. @see Analytics, AnalyticsDestination::AnalyticsEvent
  20. @tags{Analytics}
  21. */
  22. class JUCE_API ButtonTracker : private Button::Listener
  23. {
  24. public:
  25. //==============================================================================
  26. /**
  27. Creating one of these automatically sends analytics events to the Analytics
  28. singleton when the corresponding button is clicked.
  29. The name and parameters of the analytics event will be populated from the
  30. variables supplied here. If clicking changes the button's state then the
  31. parameters will have a {"ButtonState", "On"/"Off"} entry added.
  32. @param buttonToTrack the button to track
  33. @param triggeredEventName the name of the generated event
  34. @param triggeredEventParameters the parameters to add to the generated
  35. event
  36. @param triggeredEventType (optional) an integer to indicate the event
  37. type, which will be set to 0 if not supplied.
  38. @see Analytics, AnalyticsDestination::AnalyticsEvent
  39. */
  40. ButtonTracker (Button& buttonToTrack,
  41. const String& triggeredEventName,
  42. const StringPairArray& triggeredEventParameters = {},
  43. int triggeredEventType = 0);
  44. /** Destructor. */
  45. ~ButtonTracker() override;
  46. private:
  47. /** @internal */
  48. void buttonClicked (Button*) override;
  49. Button& button;
  50. const String eventName;
  51. const StringPairArray eventParameters;
  52. const int eventType;
  53. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonTracker)
  54. };
  55. } // namespace juce