2
* Animation plugin for compiz/beryl
6
* Copyright : (C) 2006 Erkin Bahceci
7
* E-mail : erkinbah@gmail.com
9
* Based on Wobbly and Minimize plugins by
11
* E-mail : davidr@novell.com>
13
* Particle system added by : (C) 2006 Dennis Kasprzyk
14
* E-mail : onestone@beryl-project.org
16
* Beam-Up added by : Florencio Guimaraes
17
* E-mail : florencio@nexcorp.com.br
19
* Hexagon tessellator added by : Mike Slegeir
20
* E-mail : mikeslegeir@mail.utexas.edu>
22
* This program is free software; you can redistribute it and/or
23
* modify it under the terms of the GNU General Public License
24
* as published by the Free Software Foundation; either version 2
25
* of the License, or (at your option) any later version.
27
* This program is distributed in the hope that it will be useful,
28
* but WITHOUT ANY WARRANTY; without even the implied warranty of
29
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
* GNU General Public License for more details.
32
* You should have received a copy of the GNU General Public License
33
* along with this program; if not, write to the Free Software
34
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39
// ===================== Effect: Curved Fold =========================
41
FoldAnim::FoldAnim (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
GridZoomAnim::GridZoomAnim (w, curWindowEvent, duration, info, icon)
53
FoldAnim::getFadeProgress ()
55
// if shade/unshade, don't do anything
56
if (mCurWindowEvent == WindowEventShade ||
57
mCurWindowEvent == WindowEventUnshade)
61
return ZoomAnim::getFadeProgress ();
63
return progressLinear ();
66
CurvedFoldAnim::CurvedFoldAnim (CompWindow *w,
67
WindowEvent curWindowEvent,
69
const AnimEffect info,
70
const CompRect &icon) :
71
Animation::Animation (w, curWindowEvent, duration, info, icon),
72
TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
73
FoldAnim::FoldAnim (w, curWindowEvent, duration, info, icon)
78
CurvedFoldAnim::initGrid ()
81
mGridHeight = optValI (AnimationOptions::MagicLampWavyGridRes); // TODO new option
85
CurvedFoldAnim::getObjectZ (GridAnim::GridModel *mModel,
86
float forwardProgress,
88
float relDistToCenter,
92
(1 - pow (pow (2 * relDistToCenter, 1.3), 2)) *
94
mModel->scale ().x ());
98
CurvedFoldAnim::step ()
100
GridZoomAnim::step ();
102
float forwardProgress = getActualProgress ();
104
CompRect winRect (mAWindow->savedRectsValid () ?
105
mAWindow->saveWinRect () :
106
mWindow->geometry ());
107
CompRect inRect (mAWindow->savedRectsValid () ?
108
mAWindow->savedInRect () :
109
mWindow->inputRect ());
110
CompRect outRect (mAWindow->savedRectsValid () ?
111
mAWindow->savedOutRect () :
112
mWindow->outputRect ());
113
CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
114
mAWindow->savedOutExtents () :
117
int wx = winRect.x ();
118
int wy = winRect.y ();
119
int wheight = winRect.height ();
121
int oy = outRect.y ();
122
int owidth = outRect.width ();
123
int oheight = outRect.height ();
125
float curveMaxAmp = (0.4 * pow ((float)oheight /
126
::screen->height (), 0.4) *
127
optValF (AnimationOptions::CurvedFoldAmpMult));
129
float sinForProg = sin (forwardProgress * M_PI / 2);
131
GridModel::GridObject *object = mModel->objects ();
132
unsigned int n = mModel->numObjects ();
133
for (unsigned int i = 0; i < n; i++, object++)
135
Point3d &objPos = object->position ();
137
if (i % 2 == 0) // object is at the left side
139
float objGridY = object->gridPosition ().y ();
142
(oheight * objGridY -
143
outExtents.top) * mModel->scale ().y ());
145
if (mCurWindowEvent == WindowEventShade ||
146
mCurWindowEvent == WindowEventUnshade)
148
// Execute shade mode
150
// find position in window contents
151
// (window contents correspond to 0.0-1.0 range)
152
float relPosInWinContents =
153
(objGridY * oheight -
154
mDecorTopHeight) / wheight;
155
float relDistToCenter = fabs (relPosInWinContents - 0.5);
162
else if (objGridY == 1)
165
(1 - forwardProgress) * origy +
167
(oy + mDecorTopHeight + mDecorBottomHeight));
173
(1 - forwardProgress) * origy +
174
forwardProgress * (oy + mDecorTopHeight));
176
getObjectZ (mModel, forwardProgress, sinForProg, relDistToCenter,
182
// Execute normal mode
184
// find position within window borders
185
// (border contents correspond to 0.0-1.0 range)
186
float relPosInWinBorders =
187
(objGridY * oheight -
188
(inRect.y () - oy)) / inRect.height ();
189
float relDistToCenter = fabs (relPosInWinBorders - 0.5);
191
// prevent top & bottom shadows from extending too much
192
if (relDistToCenter > 0.5)
193
relDistToCenter = 0.5;
196
(1 - forwardProgress) * origy +
197
forwardProgress * (inRect.y () + inRect.height () / 2.0));
199
getObjectZ (mModel, forwardProgress, sinForProg, relDistToCenter,
203
else // object is at the right side
205
// Set y/z position to the y/z position of the object at the left
206
// on the same row (previous object)
207
Point3d &leftObjPos = (object - 1)->position ();
208
objPos.setY (leftObjPos.y ());
209
objPos.setZ (leftObjPos.z ());
213
(owidth * object->gridPosition ().x () -
214
outExtents.left) * mModel->scale ().x ());
220
CurvedFoldAnim::updateBB (CompOutput &output)
222
if (optValF (AnimationOptions::CurvedFoldAmpMult) < 0) // if outward
224
GridZoomAnim::updateBB (output); // goes through all objects
228
// Just consider the corner objects
230
GridModel::GridObject *objects = mModel->objects ();
231
unsigned int n = mModel->numObjects ();
232
for (unsigned int i = 0; i < n; i++)
234
Point3d &pos = objects[i].position ();
235
GLVector coords (pos.x (), pos.y (), 0, 1);
236
mAWindow->expandBBWithPoint2DTransform (coords, mTransform);
240
// skip to the last row after considering the first row
241
// (each row has 2 objects)
248
CurvedFoldAnim::zoomToIcon ()
250
return ((mCurWindowEvent == WindowEventMinimize ||
251
mCurWindowEvent == WindowEventUnminimize) &&
252
optValB (AnimationOptions::CurvedFoldZoomToTaskbar));