ASPiK SDK
timingfunctions.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __timingfunctions__
6 #define __timingfunctions__
7 
8 #include "animator.h"
9 #include "itimingfunction.h"
10 #include <map>
11 
12 namespace VSTGUI {
13 namespace Animation {
14 
15 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 {
21 public:
22  explicit TimingFunctionBase (uint32_t length) : length (length) {}
23 
24  uint32_t getLength () const { return length; }
25  bool isDone (uint32_t milliseconds) override { return milliseconds >= length; }
26 protected:
27  uint32_t length; // in milliseconds
28 };
29 
30 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 {
36 public:
37  explicit LinearTimingFunction (uint32_t length);
38 
39 protected:
40  float getPosition (uint32_t milliseconds) override;
41 };
42 
43 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
48 {
49 public:
50  PowerTimingFunction (uint32_t length, float factor);
51 
52 protected:
53  float getPosition (uint32_t milliseconds) override;
54 
55  float factor;
56 };
57 
58 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 {
64 public:
65  InterpolationTimingFunction (uint32_t length, float startPos = 0.f, float endPos = 1.f);
66 
67  void addPoint (float time, float pos);
68 
69 protected:
70  float getPosition (uint32_t milliseconds) override;
71 
72  using PointMap = std::map<uint32_t, float>;
73  PointMap points;
74 };
75 
76 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
81 {
82 public:
83  RepeatTimingFunction (TimingFunctionBase* tf, int32_t repeatCount, bool autoReverse = true);
84  ~RepeatTimingFunction () noexcept override;
85 
86  float getPosition (uint32_t milliseconds) override;
87  bool isDone (uint32_t milliseconds) override;
88 protected:
90  int32_t repeatCount;
91  uint32_t runCounter;
92  bool autoReverse;
93  bool isReverse;
94 };
95 
96 }} // namespaces
97 
98 #endif // __timingfunctions__
void addPoint(float time, float pos)
both values are normalized ones
Definition: timingfunctions.cpp:69
Definition: timingfunctions.h:47
Definition: timingfunctions.h:80
Animation timing function interface.
Definition: itimingfunction.h:17
Definition: timingfunctions.h:19
Definition: customcontrols.cpp:8
Definition: timingfunctions.h:34
Definition: timingfunctions.h:62