KWin
|
#include <timeline.h>
Public Types | |
enum | Direction { Forward , Backward } |
enum class | RedirectMode { Strict , Relaxed } |
Public Member Functions | |
TimeLine (std::chrono::milliseconds duration=std::chrono::milliseconds(1000), Direction direction=Forward) | |
TimeLine (const TimeLine &other) | |
~TimeLine () | |
qreal | value () const |
void | advance (std::chrono::milliseconds timestamp) |
std::chrono::milliseconds | elapsed () const |
void | setElapsed (std::chrono::milliseconds elapsed) |
std::chrono::milliseconds | duration () const |
void | setDuration (std::chrono::milliseconds duration) |
Direction | direction () const |
void | setDirection (Direction direction) |
void | toggleDirection () |
QEasingCurve | easingCurve () const |
void | setEasingCurve (const QEasingCurve &easingCurve) |
void | setEasingCurve (QEasingCurve::Type type) |
bool | running () const |
bool | done () const |
void | reset () |
RedirectMode | sourceRedirectMode () const |
void | setSourceRedirectMode (RedirectMode mode) |
RedirectMode | targetRedirectMode () const |
void | setTargetRedirectMode (RedirectMode mode) |
TimeLine & | operator= (const TimeLine &other) |
qreal | progress () const |
Public Attributes | |
std::chrono::milliseconds | duration |
Direction | direction |
QEasingCurve | easingCurve |
std::chrono::milliseconds | elapsed = std::chrono::milliseconds::zero() |
std::optional< std::chrono::milliseconds > | lastTimestamp = std::nullopt |
bool | done = false |
RedirectMode | sourceRedirectMode = RedirectMode::Relaxed |
RedirectMode | targetRedirectMode = RedirectMode::Strict |
The TimeLine class is a helper for controlling animations.
Definition at line 12 of file timeline.cpp.
Direction of the timeline.
When the direction of the timeline is Forward, the progress value will go from 0.0 to 1.0.
When the direction of the timeline is Backward, the progress value will go from 1.0 to 0.0.
Enumerator | |
---|---|
Forward | |
Backward |
Definition at line 34 of file timeline.h.
|
strong |
Enumerator | |
---|---|
Strict | |
Relaxed |
Definition at line 197 of file timeline.h.
|
explicit |
Constructs a new instance of TimeLine.
duration | Duration of the timeline, in milliseconds |
direction | Direction of the timeline |
Definition at line 26 of file timeline.cpp.
KWin::TimeLine::TimeLine | ( | const TimeLine & | other | ) |
Definition at line 34 of file timeline.cpp.
|
default |
void KWin::TimeLine::advance | ( | std::chrono::milliseconds | timestamp | ) |
Advances the timeline to the specified timestamp.
Definition at line 53 of file timeline.cpp.
Direction KWin::TimeLine::direction | ( | ) | const |
Returns the direction of the timeline.
bool KWin::TimeLine::done | ( | ) | const |
std::chrono::milliseconds KWin::TimeLine::duration | ( | ) | const |
Returns the duration of the timeline.
QEasingCurve KWin::TimeLine::easingCurve | ( | ) | const |
std::chrono::milliseconds KWin::TimeLine::elapsed | ( | ) | const |
Definition at line 203 of file timeline.cpp.
qreal KWin::TimeLine::progress | ( | ) | const |
Definition at line 41 of file timeline.cpp.
void KWin::TimeLine::reset | ( | ) |
bool KWin::TimeLine::running | ( | ) | const |
Returns whether the timeline is currently in progress.
Definition at line 165 of file timeline.cpp.
void KWin::TimeLine::setDirection | ( | TimeLine::Direction | direction | ) |
Sets the direction of the timeline.
direction | The new direction of the timeline |
Definition at line 122 of file timeline.cpp.
void KWin::TimeLine::setDuration | ( | std::chrono::milliseconds | duration | ) |
Sets the duration of the timeline.
In addition to setting new value of duration, the timeline will try to retarget the number of elapsed milliseconds to match as close as possible old progress value. If the new duration is much smaller than old duration, there is a big chance that the timeline will be finished after setting new duration.
duration | The new duration of the timeline, in milliseconds |
Definition at line 103 of file timeline.cpp.
void KWin::TimeLine::setEasingCurve | ( | const QEasingCurve & | easingCurve | ) |
Sets new easing curve.
easingCurve | An easing curve to be set |
Definition at line 155 of file timeline.cpp.
void KWin::TimeLine::setEasingCurve | ( | QEasingCurve::Type | type | ) |
Sets new easing curve by providing its type.
type | Type of the easing curve(e.g. QEasingCurve::InCubic, etc) |
Definition at line 160 of file timeline.cpp.
void KWin::TimeLine::setElapsed | ( | std::chrono::milliseconds | elapsed | ) |
Sets the number of elapsed milliseconds.
This method overwrites previous value of elapsed milliseconds. If the new value of elapsed milliseconds is greater or equal to duration of the timeline, the timeline will be finished, i.e. proceeding TimeLine::done method calls will return true
. Please don't use it. Instead, use TimeLine::update.
elapsed | The new number of elapsed milliseconds |
Definition at line 80 of file timeline.cpp.
void KWin::TimeLine::setSourceRedirectMode | ( | RedirectMode | mode | ) |
Sets the redirect mode for the source position.
mode | The new mode. |
Definition at line 188 of file timeline.cpp.
void KWin::TimeLine::setTargetRedirectMode | ( | RedirectMode | mode | ) |
Sets the redirect mode for the target position.
mode | The new mode. |
Definition at line 198 of file timeline.cpp.
RedirectMode KWin::TimeLine::sourceRedirectMode | ( | ) | const |
Returns the redirect mode for the source position.
The redirect mode controls behavior of the timeline when its direction is changed at the source position, e.g. what should we do when the timeline initially goes forward and we change its direction to go backward.
In the strict mode, the timeline will stop.
In the relaxed mode, the timeline will go in the new direction. For example, if the timeline goes forward(from 0 to 1), then with the new direction it will go backward(from 1 to 0).
The default is RedirectMode::Relaxed.
RedirectMode KWin::TimeLine::targetRedirectMode | ( | ) | const |
Returns the redirect mode for the target position.
The redirect mode controls behavior of the timeline when its direction is changed at the target position.
In the strict mode, subsequent update calls won't have any effect on the current value of the timeline.
In the relaxed mode, the timeline will go in the new direction.
The default is RedirectMode::Strict.
void KWin::TimeLine::toggleDirection | ( | ) |
Toggles the direction of the timeline.
If the direction of the timeline was TimeLine::Forward, it becomes TimeLine::Backward, and vice verca.
Definition at line 145 of file timeline.cpp.
qreal KWin::TimeLine::value | ( | ) | const |
TimeLine::Direction KWin::TimeLine::direction |
Definition at line 16 of file timeline.cpp.
bool KWin::TimeLine::done = false |
Definition at line 21 of file timeline.cpp.
std::chrono::milliseconds KWin::TimeLine::duration |
Definition at line 15 of file timeline.cpp.
QEasingCurve KWin::TimeLine::easingCurve |
Definition at line 17 of file timeline.cpp.
std::chrono::milliseconds KWin::TimeLine::elapsed = std::chrono::milliseconds::zero() |
Definition at line 19 of file timeline.cpp.
std::optional<std::chrono::milliseconds> KWin::TimeLine::lastTimestamp = std::nullopt |
Definition at line 20 of file timeline.cpp.
TimeLine::RedirectMode KWin::TimeLine::sourceRedirectMode = RedirectMode::Relaxed |
Definition at line 22 of file timeline.cpp.
TimeLine::RedirectMode KWin::TimeLine::targetRedirectMode = RedirectMode::Strict |
Definition at line 23 of file timeline.cpp.