KWin
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
KWin::TimeLine Class Reference

#include <timeline.h>

Inheritance diagram for KWin::TimeLine:

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)
 
TimeLineoperator= (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
 

Detailed Description

The TimeLine class is a helper for controlling animations.

Definition at line 12 of file timeline.cpp.

Member Enumeration Documentation

◆ Direction

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.

◆ RedirectMode

enum class KWin::TimeLine::RedirectMode
strong
Enumerator
Strict 
Relaxed 

Definition at line 197 of file timeline.h.

Constructor & Destructor Documentation

◆ TimeLine() [1/2]

KWin::TimeLine::TimeLine ( std::chrono::milliseconds duration = std::chrono::milliseconds(1000),
Direction direction = Forward )
explicit

Constructs a new instance of TimeLine.

Parameters
durationDuration of the timeline, in milliseconds
directionDirection of the timeline
Since
5.14

Definition at line 26 of file timeline.cpp.

◆ TimeLine() [2/2]

KWin::TimeLine::TimeLine ( const TimeLine & other)

Definition at line 34 of file timeline.cpp.

◆ ~TimeLine()

KWin::TimeLine::~TimeLine ( )
default

Member Function Documentation

◆ advance()

void KWin::TimeLine::advance ( std::chrono::milliseconds timestamp)

Advances the timeline to the specified timestamp.

Definition at line 53 of file timeline.cpp.

◆ direction()

Direction KWin::TimeLine::direction ( ) const

Returns the direction of the timeline.

Returns
Direction of the timeline(TimeLine::Forward or TimeLine::Backward)
See also
setDirection
toggleDirection
Since
5.14

◆ done()

bool KWin::TimeLine::done ( ) const

Returns whether the timeline is finished.

See also
reset
Since
5.14

◆ duration()

std::chrono::milliseconds KWin::TimeLine::duration ( ) const

Returns the duration of the timeline.

Returns
Duration of the timeline, in milliseconds
See also
setDuration
Since
5.14

◆ easingCurve()

QEasingCurve KWin::TimeLine::easingCurve ( ) const

Returns the easing curve of the timeline.

See also
setEasingCurve
Since
5.14

◆ elapsed()

std::chrono::milliseconds KWin::TimeLine::elapsed ( ) const

Returns the number of elapsed milliseconds.

See also
setElapsed
Since
5.14

◆ operator=()

TimeLine & KWin::TimeLine::operator= ( const TimeLine & other)

Definition at line 203 of file timeline.cpp.

◆ progress()

qreal KWin::TimeLine::progress ( ) const
Returns
a value between 0 and 1 defining the progress of the timeline
Since
5.23

Definition at line 41 of file timeline.cpp.

◆ reset()

void KWin::TimeLine::reset ( )

Resets the timeline to initial state.

Since
5.14

Definition at line 176 of file timeline.cpp.

◆ running()

bool KWin::TimeLine::running ( ) const

Returns whether the timeline is currently in progress.

See also
done
Since
5.14

Definition at line 165 of file timeline.cpp.

◆ setDirection()

void KWin::TimeLine::setDirection ( TimeLine::Direction direction)

Sets the direction of the timeline.

Parameters
directionThe new direction of the timeline
See also
direction
toggleDirection
Since
5.14

Definition at line 122 of file timeline.cpp.

◆ setDuration()

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.

Note
The new duration should be a positive number, i.e. it should be greater or equal to 1.
Parameters
durationThe new duration of the timeline, in milliseconds
See also
duration
Since
5.14

Definition at line 103 of file timeline.cpp.

◆ setEasingCurve() [1/2]

void KWin::TimeLine::setEasingCurve ( const QEasingCurve & easingCurve)

Sets new easing curve.

Parameters
easingCurveAn easing curve to be set
See also
easingCurve
Since
5.14

Definition at line 155 of file timeline.cpp.

◆ setEasingCurve() [2/2]

void KWin::TimeLine::setEasingCurve ( QEasingCurve::Type type)

Sets new easing curve by providing its type.

Parameters
typeType of the easing curve(e.g. QEasingCurve::InCubic, etc)
See also
easingCurve
Since
5.14

Definition at line 160 of file timeline.cpp.

◆ setElapsed()

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.

Note
The new number of elapsed milliseconds should be a non-negative number, i.e. it should be greater or equal to 0.
Parameters
elapsedThe new number of elapsed milliseconds
See also
elapsed
Since
5.14

Definition at line 80 of file timeline.cpp.

◆ setSourceRedirectMode()

void KWin::TimeLine::setSourceRedirectMode ( RedirectMode mode)

Sets the redirect mode for the source position.

Parameters
modeThe new mode.
Since
5.15

Definition at line 188 of file timeline.cpp.

◆ setTargetRedirectMode()

void KWin::TimeLine::setTargetRedirectMode ( RedirectMode mode)

Sets the redirect mode for the target position.

Parameters
modeThe new mode.
Since
5.15

Definition at line 198 of file timeline.cpp.

◆ sourceRedirectMode()

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.

See also
targetRedirectMode
Since
5.15

◆ targetRedirectMode()

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.

See also
sourceRedirectMode
Since
5.15

◆ toggleDirection()

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.

See also
direction
setDirection
Since
5.14

Definition at line 145 of file timeline.cpp.

◆ value()

qreal KWin::TimeLine::value ( ) const

Returns the current value of the timeline.

Since
5.14

Definition at line 46 of file timeline.cpp.

Member Data Documentation

◆ direction

TimeLine::Direction KWin::TimeLine::direction

Definition at line 16 of file timeline.cpp.

◆ done

bool KWin::TimeLine::done = false

Definition at line 21 of file timeline.cpp.

◆ duration

std::chrono::milliseconds KWin::TimeLine::duration

Definition at line 15 of file timeline.cpp.

◆ easingCurve

QEasingCurve KWin::TimeLine::easingCurve

Definition at line 17 of file timeline.cpp.

◆ elapsed

std::chrono::milliseconds KWin::TimeLine::elapsed = std::chrono::milliseconds::zero()

Definition at line 19 of file timeline.cpp.

◆ lastTimestamp

std::optional<std::chrono::milliseconds> KWin::TimeLine::lastTimestamp = std::nullopt

Definition at line 20 of file timeline.cpp.

◆ sourceRedirectMode

TimeLine::RedirectMode KWin::TimeLine::sourceRedirectMode = RedirectMode::Relaxed

Definition at line 22 of file timeline.cpp.

◆ targetRedirectMode

TimeLine::RedirectMode KWin::TimeLine::targetRedirectMode = RedirectMode::Strict

Definition at line 23 of file timeline.cpp.


The documentation for this class was generated from the following files: