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_AnimatedAppComponent.h 2.7KB

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