1#ifndef GAME_EDITOR_SMOOTH_VALUE_H
2#define GAME_EDITOR_SMOOTH_VALUE_H
3
4#include <base/bezier.h>
5
6#include "component.h"
7
8/**
9 * A value that is changed smoothly over time.
10 */
11class CSmoothValue : public CEditorComponent
12{
13public:
14 CSmoothValue(float InitialValue, float MinValue, float MaxValue);
15
16 /**
17 * Set a new target which the value should change to.
18 */
19 void SetValue(float Target);
20
21 /**
22 * Change the value by the given amount.
23 */
24 void ChangeValue(float Amount);
25
26 /**
27 * Set the value to the target instantly. If the value was changing the
28 * target will be discarded.
29 */
30 void SetValueInstant(float Target);
31
32 bool UpdateValue();
33
34 float GetValue() const;
35 void SetValueRange(float MinValue, float MaxValue);
36 float GetMinValue() const;
37 float GetMaxValue() const;
38
39private:
40 float ZoomProgress(float CurrentTime) const;
41
42 bool m_Smoothing;
43 float m_Value;
44 CCubicBezier m_ValueSmoothing;
45 float m_ValueSmoothingTarget;
46 float m_ValueSmoothingStart;
47 float m_ValueSmoothingEnd;
48
49 float m_MinValue;
50 float m_MaxValue;
51};
52
53#endif
54