diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 9497b4773c..444c106f5a 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -925,19 +925,19 @@ double TimeLine::valueForTime(const int msec) const void TimeLine::addTime(const int msec) { m_Time = qMin(m_Duration, m_Time + msec); - m_Progress = m_Time / m_Duration; + m_Progress = (double)m_Time / m_Duration; } void TimeLine::removeTime(const int msec) { m_Time = qMax(0, m_Time - msec); - m_Progress = m_Time / m_Duration; + m_Progress = (double)m_Time / m_Duration; } void TimeLine::setProgress(const double progress) { m_Progress = progress; - m_Time = (int)(m_Duration * progress); + m_Time = qRound(m_Duration * progress); } double TimeLine::progress() const @@ -945,6 +945,11 @@ double TimeLine::progress() const return m_Progress; } +int TimeLine::time() const + { + return m_Time; + } + void TimeLine::addProgress(const double progress) { m_Progress += progress; diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 8ffb1cf679..737111e80e 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -1084,6 +1084,11 @@ class KWIN_EXPORT TimeLine * and related methods, the y value of the current state x. */ double valueForTime(const int msec) const; + /** + * Returns the current time of the TimeLine, between 0 and duration() + * The value returned is equivalent to the x-axis on a curve. + */ + int time() const; /** * Returns the progress of the TimeLine, between 0.0 and 1.0. * The value returned is equivalent to the y-axis on a curve.