34
34
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37
#include "animation-internal.h"
39
39
// ===================== Effect: Glide =========================
42
fxGlideGetParams (CompWindow *w,
49
if (aw->com.curAnimEffect == AnimEffectGlide1)
51
*finalDistFac = animGetF (w, ANIM_SCREEN_OPTION_GLIDE1_AWAY_POS);
52
*finalRotAng = animGetF (w, ANIM_SCREEN_OPTION_GLIDE1_AWAY_ANGLE);
56
*finalDistFac = animGetF (w, ANIM_SCREEN_OPTION_GLIDE2_AWAY_POS);
57
*finalRotAng = animGetF (w, ANIM_SCREEN_OPTION_GLIDE2_AWAY_ANGLE);
62
fxGlideAnimProgress (CompWindow *w)
64
float forwardProgress = defaultAnimProgress (w);
66
return decelerateProgress(forwardProgress);
70
applyGlideTransform (CompWindow *w)
74
CompTransform *transform = &aw->com.transform;
41
GlideAnim::GlideAnim (CompWindow *w,
42
WindowEvent curWindowEvent,
44
const AnimEffect info,
45
const CompRect &icon) :
46
Animation::Animation (w, curWindowEvent, duration, info, icon),
47
TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
48
ZoomAnim::ZoomAnim (w, curWindowEvent, duration, info, icon)
52
Glide2Anim::Glide2Anim (CompWindow *w,
53
WindowEvent curWindowEvent,
55
const AnimEffect info,
56
const CompRect &icon) :
57
Animation::Animation (w, curWindowEvent, duration, info, icon),
58
TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
59
GlideAnim::GlideAnim (w, curWindowEvent, duration, info, icon)
64
GlideAnim::getParams (float *finalDistFac,
68
*finalDistFac = optValF (AnimationOptions::Glide1AwayPosition);
69
*finalRotAng = optValF (AnimationOptions::Glide1AwayAngle);
73
Glide2Anim::getParams (float *finalDistFac,
77
*finalDistFac = optValF (AnimationOptions::Glide2AwayPosition);
78
*finalRotAng = optValF (AnimationOptions::Glide2AwayAngle);
82
GlideAnim::getProgress ()
84
float forwardProgress = progressLinear ();
86
return progressDecelerate (forwardProgress);
90
GlideAnim::getFadeProgress ()
93
return ZoomAnim::getFadeProgress ();
95
return getProgress ();
99
GlideAnim::applyTransform ()
102
ZoomAnim::applyTransform ();
76
104
float finalDistFac;
77
105
float finalRotAng;
80
fxGlideGetParams (w, &finalDistFac, &finalRotAng, &thickness);
108
getParams (&finalDistFac, &finalRotAng, &thickness);
82
110
float forwardProgress;
83
if (fxGlideZoomToIcon (w))
86
fxZoomAnimProgress (w, &forwardProgress, &dummy, TRUE);
112
getZoomProgress (&forwardProgress, 0, true);
89
forwardProgress = fxGlideAnimProgress (w);
114
forwardProgress = getProgress ();
91
116
float finalz = finalDistFac * 0.8 * DEFAULT_Z_CAMERA *
94
Vector3d rotAxis = {1, 0, 0};
95
Point3d rotAxisOffset =
96
{WIN_X(w) + WIN_W(w) / 2.0f,
97
WIN_Y(w) + WIN_H(w) / 2.0f,
99
Point3d translation = {0, 0, finalz * forwardProgress};
119
CompRect outRect (mAWindow->savedRectsValid () ?
120
mAWindow->savedOutRect () :
121
mWindow->outputRect ());
123
GLVector rotAxis (1, 0, 0, 0);
124
GLVector rotAxisOffset (outRect.x () + outRect.width () / 2.0f,
125
outRect.y () + outRect.height () / 2.0f,
127
GLVector translation (0, 0, finalz * forwardProgress, 0);
101
129
float rotAngle = finalRotAng * forwardProgress;
102
aw->glideModRotAngle = fmodf(rotAngle + 720, 360.0f);
130
glideModRotAngle = fmodf (rotAngle + 720, 360.0f);
104
132
// put back to window position
105
matrixTranslate (transform, rotAxisOffset.x, rotAxisOffset.y, 0);
133
mTransform.translate (rotAxisOffset);
107
perspectiveDistortAndResetZ (w->screen, transform);
135
perspectiveDistortAndResetZ (mTransform);
109
137
// animation movement
110
matrixTranslate (transform, translation.x, translation.y, translation.z);
138
mTransform.translate (translation);
112
140
// animation rotation
113
matrixRotate (transform, rotAngle, rotAxis.x, rotAxis.y, rotAxis.z);
141
mTransform.rotate (rotAngle, rotAxis);
115
143
// intentional scaling of z by 0 to prevent weird opacity results and
116
144
// flashing that happen when z coords are between 0 and 1 (bug in compiz?)
117
matrixScale (transform, 1.0f, 1.0f, 0.0f);
145
mTransform.scale (1.0f, 1.0f, 0.0f);
119
147
// place window rotation axis at origin
120
matrixTranslate (transform, -rotAxisOffset.x, -rotAxisOffset.y, 0);
124
fxGlideAnimStep (CompWindow *w, float time)
126
defaultAnimStep (w, time);
128
applyGlideTransform (w);
132
fxGlideUpdateWindowAttrib (CompWindow * w,
133
WindowPaintAttrib * wAttrib)
137
if (fxGlideZoomToIcon (w))
139
fxZoomUpdateWindowAttrib (w, wAttrib);
143
float forwardProgress = fxGlideAnimProgress (w);
145
wAttrib->opacity = aw->com.storedOpacity * (1 - forwardProgress);
149
fxGlideUpdateWindowTransform (CompWindow *w,
150
CompTransform *wTransform)
154
applyTransform (wTransform, &aw->com.transform);
158
fxGlideInit (CompWindow * w)
162
if (fxGlideZoomToIcon (w))
164
aw->com.animTotalTime /= ZOOM_PERCEIVED_T;
165
aw->com.animRemainingTime = aw->com.animTotalTime;
168
return defaultAnimInit (w);
171
void fxGlidePrePaintWindow (CompWindow *w)
175
if (90 < aw->glideModRotAngle &&
176
aw->glideModRotAngle < 270)
177
glCullFace(GL_FRONT);
180
void fxGlidePostPaintWindow (CompWindow * w)
184
if (90 < aw->glideModRotAngle &&
185
aw->glideModRotAngle < 270)
190
fxGlideZoomToIcon (CompWindow *w)
194
((aw->com.curWindowEvent == WindowEventMinimize ||
195
aw->com.curWindowEvent == WindowEventUnminimize) &&
196
((aw->com.curAnimEffect == AnimEffectGlide1 &&
197
animGetB (w, ANIM_SCREEN_OPTION_GLIDE1_Z2TOM)) ||
198
(aw->com.curAnimEffect == AnimEffectGlide2 &&
199
animGetB (w, ANIM_SCREEN_OPTION_GLIDE2_Z2TOM))));
148
mTransform.translate (-rotAxisOffset);
152
GlideAnim::adjustDuration ()
156
mTotalTime *= kDurationFactor;
157
mRemainingTime = mTotalTime;
162
GlideAnim::prePaintWindow ()
164
if (90 < glideModRotAngle &&
165
glideModRotAngle < 270)
166
glCullFace (GL_FRONT);
170
GlideAnim::postPaintWindow ()
172
if (90 < glideModRotAngle &&
173
glideModRotAngle < 270)
174
glCullFace (GL_BACK);
178
GlideAnim::zoomToIcon ()
180
return ((mCurWindowEvent == WindowEventMinimize ||
181
mCurWindowEvent == WindowEventUnminimize) &&
182
optValB (AnimationOptions::Glide1ZoomToTaskbar));
186
Glide2Anim::zoomToIcon ()
188
return ((mCurWindowEvent == WindowEventMinimize ||
189
mCurWindowEvent == WindowEventUnminimize) &&
190
optValB (AnimationOptions::Glide2ZoomToTaskbar));