8 #include <nap/signalslot.h>
24 LinearSmoothedValue(
const T& initValue,
int stepCount) : mNewDestination(initValue), mValue(initValue), mDestination(initValue)
26 mStepCount = stepCount;
36 mNewDestination = initValue;
38 mDestination = initValue;
50 void setValue(
const T& destination) { mNewDestination = destination; }
58 if (mNewDestination != mDestination)
60 mDestination = mNewDestination;
61 mStepCounter = mStepCount;
62 if (mStepCounter == 0)
63 mValue = mDestination;
65 mIncrement = (mDestination - mValue) / T(mStepCount);
70 mValue = mValue + mIncrement;
72 if (mStepCounter == 0)
73 mValue = mDestination;
91 inline bool isRamping()
const {
return mStepCounter > 0 || mDestination != mNewDestination; }
94 T mNewDestination = 0;
100 int mStepCounter = 0;