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: Horizontal Folds =========================
41
HorizontalFoldsAnim::HorizontalFoldsAnim (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
FoldAnim::FoldAnim (w, curWindowEvent, duration, info, icon)
53
HorizontalFoldsAnim::initGrid ()
56
if (mCurWindowEvent == WindowEventShade ||
57
mCurWindowEvent == WindowEventUnshade)
59
optValI (AnimationOptions::HorizontalFoldsNumFolds);
62
optValI (AnimationOptions::HorizontalFoldsNumFolds);
66
HorizontalFoldsAnim::getObjectZ (GridAnim::GridModel *mModel,
67
float forwardProgress,
69
float relDistToFoldCenter,
74
mModel->scale ().x () *
75
2 * (0.5 - relDistToFoldCenter));
79
HorizontalFoldsAnim::step ()
81
GridZoomAnim::step ();
83
CompRect winRect (mAWindow->savedRectsValid () ?
84
mAWindow->saveWinRect () :
85
mWindow->geometry ());
86
CompRect inRect (mAWindow->savedRectsValid () ?
87
mAWindow->savedInRect () :
88
mWindow->inputRect ());
89
CompRect outRect (mAWindow->savedRectsValid () ?
90
mAWindow->savedOutRect () :
91
mWindow->outputRect ());
92
CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
93
mAWindow->savedOutExtents () :
96
int wx = winRect.x ();
97
int wy = winRect.y ();
99
int oy = outRect.y ();
100
int owidth = outRect.width ();
101
int oheight = outRect.height ();
104
if (mCurWindowEvent == WindowEventShade ||
105
mCurWindowEvent == WindowEventUnshade)
107
winHeight = winRect.height ();
111
winHeight = inRect.height ();
114
2.0 * optValI (AnimationOptions::HorizontalFoldsNumFolds);
116
0.3 * pow ((winHeight / nHalfFolds) / ::screen->height (), 0.3) *
117
optValF (AnimationOptions::HorizontalFoldsAmpMult);
119
float forwardProgress = getActualProgress ();
121
float sinForProg = sin (forwardProgress * M_PI / 2);
123
GridModel::GridObject *object = mModel->objects ();
124
unsigned int n = mModel->numObjects ();
125
for (unsigned int i = 0; i < n; i++, object++)
127
Point3d &objPos = object->position ();
129
if (i % 2 == 0) // object is at the left side
131
float objGridY = object->gridPosition ().y ();
133
int rowNo = (int)i / mGridWidth;
135
(oheight * objGridY -
136
outExtents.top) * mModel->scale ().y ());
137
if (mCurWindowEvent == WindowEventShade ||
138
mCurWindowEvent == WindowEventUnshade)
140
// Execute shade mode
147
else if (objGridY == 1)
150
(1 - forwardProgress) * origy +
152
(oy + mDecorTopHeight + mDecorBottomHeight));
157
float relDistToFoldCenter = (rowNo % 2 == 1 ? 0.5 : 0);
160
(1 - forwardProgress) * origy +
161
forwardProgress * (oy + mDecorTopHeight));
163
getObjectZ (mModel, forwardProgress, sinForProg,
164
relDistToFoldCenter, foldMaxAmp));
169
// Execute normal mode
171
float relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0);
174
(1 - forwardProgress) * origy +
175
forwardProgress * (inRect.y () + inRect.height () / 2.0));
177
getObjectZ (mModel, forwardProgress, sinForProg,
178
relDistToFoldCenter, foldMaxAmp));
181
else // object is at the right side
183
// Set y/z position to the y/z position of the object at the left
184
// on the same row (previous object)
185
Point3d &leftObjPos = (object - 1)->position ();
186
objPos.setY (leftObjPos.y ());
187
objPos.setZ (leftObjPos.z ());
191
(owidth * object->gridPosition ().x () -
192
outExtents.left) * mModel->scale ().x ());
198
HorizontalFoldsAnim::zoomToIcon ()
200
return ((mCurWindowEvent == WindowEventMinimize ||
201
mCurWindowEvent == WindowEventUnminimize) &&
202
optValB (AnimationOptions::HorizontalFoldsZoomToTaskbar));