KWin/Animations: Difference between revisions

From KDE Community Wiki
(Created page with "There are many different animations in the KWin effects. The animations differ in animation duration and the kind of animation. The idea is to have this in a more consistent w...")
 
No edit summary
Line 68: Line 68:
=== coverswitch ===
=== coverswitch ===
=== cube ===
=== cube ===
=== cubeslide ===
=== dashboard ===
=== dashboard ===
=== desktopgrid ===
=== desktopgrid ===

Revision as of 07:51, 6 October 2012

There are many different animations in the KWin effects. The animations differ in animation duration and the kind of animation. The idea is to have this in a more consistent way by e.g. all fade animations having the same duration and animation behavior.

To be able to do so, it is first required to gather all the animation data.

How to Find the Animation

All animations are defined in the effects source code which are located in kwin/effects in the kde-workspace git repository. Most of the animations use one or many QTimeLine for controlling the animation. These are mostly defined in variables called timeline. To find the animations which are going on one can look into a method called prePaintScreen which gets the time since the last rendered frame. There is some code which adds the time to the QTimeLine. For example in the DimScreenEffect this looks like the following:

void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
    if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
        timeline.setCurrentTime(timeline.currentTime() + time);
    if (mActivated && deactivateAnimation)
        timeline.setCurrentTime(timeline.currentTime() - time);
    if (mActivated && effects->activeFullScreenEffect())
        timeline.setCurrentTime(timeline.currentTime() - time);
    if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.currentValue() != 1.0)
        timeline.setCurrentTime(timeline.currentTime() + time);
    effects->prePaintScreen(data, time);
}

From this we see that only one animation in variable "timeline" is defined.

Finding the Animation Duration

The animation duration is somewhere in the effect defined. In most cases it is either a hardcoded value or comes from a configuration value, which also includes the default hardcoded. If you have your variable look for a code section like:

variableName.setDuration(animationTime(250));

Which would tell us that the duration is 250 msec. For a configurable duration it can look like:

rotationDuration = animationTime(CubeConfig::rotationDuration() != 0 ? CubeConfig::rotationDuration() : 500);
timeLine.setDuration(rotationDuration);

This would tell us that the default animation duration is 500 msec.

Finding the Curve Shape

Each QTimeLine has either a CurveShape or a QEasingCurve assigned which describes how the animation looks like over time. If the animation uses a CurveShape you can find a code fragment looking like:

variableName.setCurveShape(QTimeLine::EaseInOutCurve);

This would tell us, that it is using an EaseInOutCurve.

If it uses a QEasingCurve it should look like:

variableName.setEasingCurve(QEasingCurve::InOutQuad);

This would tell us it is using an InOutQuad.

If there is no call for setting either the CurveShape or the EasingCurve on the QTimeLine the default behavior is a EaseInOutCurve.

Effects

Please use the following table if an effect uses an animation:

Animation Duration Shape
What gets animated (e.g. fade windows, dim windows) Duration in msec CurveShape or EasingCurve

blur

none

boxswitch

Can be ignored, scheduled for removal

coverswitch

cube

cubeslide

dashboard

desktopgrid

dialogparent

diminactive

dimscreen

Animation Duration Shape
Dim windows 250 EaseInOutCurve
Undim windows 250 EaseInOutCurve

explosion

fade

fadedesktop

fallapart

flipswitch

glide

highlightwindow

invert

login

logout

lookingglass

magiclamp

magnifier

minimizeanimation

mousemark

outline

presentwindows

resize

scalein

screenshot

sheet

showfps

showpaint

slide

slideback

slidingpopups

snaphelper

startupfeedback

taskbarthumbnail

thumbnailaside

trackmouse

translucency

windowgeometry

windowstrip

wobblywindows

zoom