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.

71 lines
2.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 base class for writing simple one-page graphical apps.
  18. A subclass can inherit from this and implement just a few methods such as
  19. paint() and mouse-handling. The base class provides some simple abstractions
  20. to take care of continuously repainting itself.
  21. @tags{GUI}
  22. */
  23. class AnimatedAppComponent : public Component,
  24. private Timer
  25. {
  26. public:
  27. AnimatedAppComponent();
  28. /** Your subclass can call this to start a timer running which will
  29. call update() and repaint the component at the given frequency.
  30. */
  31. void setFramesPerSecond (int framesPerSecond);
  32. /** Called periodically, at the frequency specified by setFramesPerSecond().
  33. This is a the best place to do things like advancing animation parameters,
  34. checking the mouse position, etc.
  35. */
  36. virtual void update() = 0;
  37. /** Returns the number of times that update() has been called since the component
  38. started running.
  39. */
  40. int getFrameCounter() const noexcept { return totalUpdates; }
  41. /** When called from update(), this returns the number of milliseconds since the
  42. last update call.
  43. This might be useful for accurately timing animations, etc.
  44. */
  45. int getMillisecondsSinceLastUpdate() const noexcept;
  46. private:
  47. //==============================================================================
  48. Time lastUpdateTime;
  49. int totalUpdates;
  50. void timerCallback() override;
  51. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedAppComponent)
  52. };
  53. } // namespace juce