Merge lp:~mc-return/compiz/compiz.merge-plugin-simple-animations into lp:compiz/0.9.8

Proposed by MC Return on 2012-07-16
Status: Superseded
Proposed branch: lp:~mc-return/compiz/compiz.merge-plugin-simple-animations
Merge into: lp:compiz/0.9.8
Diff against target: 1778 lines (+1716/-0)
12 files modified
plugins/simple-animations/CMakeLists.txt (+8/-0)
plugins/simple-animations/animationsim.xml.in (+235/-0)
plugins/simple-animations/src/animationsim.cpp (+160/-0)
plugins/simple-animations/src/animationsim.h (+405/-0)
plugins/simple-animations/src/bounce.cpp (+76/-0)
plugins/simple-animations/src/expand-piecewise.cpp (+90/-0)
plugins/simple-animations/src/expand.cpp (+70/-0)
plugins/simple-animations/src/fan.cpp (+51/-0)
plugins/simple-animations/src/flyin.cpp (+86/-0)
plugins/simple-animations/src/pulse.cpp (+50/-0)
plugins/simple-animations/src/rotatein.cpp (+210/-0)
plugins/simple-animations/src/sheet.cpp (+275/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-plugin-simple-animations
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing on 2012-08-28
MC Return Resubmit on 2012-08-11
Sam Spilsbury 2012-07-16 Needs Fixing on 2012-08-11
Review via email: mp+115048@code.launchpad.net

This proposal has been superseded by a proposal from 2013-04-02.

Commit message

Added the plug-in "Simple Animations" converted from git to bzr (including full history) to lp:compiz

Description of the change

Adds the plug-in "Simple Animations" converted from git to bzr (including full history) to lp:compiz

To post a comment you must log in.
MC Return (mc-return) wrote :

Worked in Compiz 0.9.5+ versions. Currently unfortunately fails to build:

In file included from /home/mcr2010/src/compiz/plugins/simple-animations/src/bounce.cpp:37:0:
/home/mcr2010/src/compiz/plugins/simple-animations/src/animationsim.h:114:7: error: no unique final overrider for ‘virtual bool Animation::requiresTransformedWindow() const’ in ‘FlyInAnim’
/home/mcr2010/src/compiz/plugins/simple-animations/src/animationsim.h:225:7: error: no unique final overrider for ‘virtual bool Animation::requiresTransformedWindow() const’ in ‘BounceAnim’
/home/mcr2010/src/compiz/plugins/simple-animations/src/animationsim.h:311:7: error: no unique final overrider for ‘virtual bool Animation::requiresTransformedWindow() const’ in ‘PulseSingleAnim’
/home/mcr2010/src/compiz/plugins/simple-animations/src/animationsim.h:351:7: error: no unique final overrider for ‘virtual bool Animation::requiresTransformedWindow() const’ in ‘FanSingleAnim’
make[2]: *** [CMakeFiles/animationsim.dir/src/bounce.cpp.o] Error 1
make[1]: *** [CMakeFiles/animationsim.dir/all] Error 2
make: *** [all] Error 2

Sam Spilsbury (smspillaz) wrote :

You just need to implement requiresTransformedWindow () in all of those clases.

just something like

bool requiresTransformedWindow () { return true; }

3287. By MC Return on 2012-07-16

Fixed compilation by adding the required protected bool requiresTransformedWindow () to the classes FlyInAnim, BounceAnim, PulseSingleAnim and FanSingleAnim in animationsim.h

MC Return (mc-return) wrote :
Download full text (4.3 KiB)

Now it compiles :)
Some warnings remain:

compiz.merge-plugin-simple-animations/plugins/simple-animations/src/flyin.cpp: In member function ‘virtual void FlyInAnim::applyTransform()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/flyin.cpp:81:42: warning: ‘offsetY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/flyin.cpp:80:42: warning: ‘offsetX’ may be used uninitialized in this function [-Wmaybe-uninitialized]

compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::prePaintWindow()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:112:11: warning: variable ‘originX’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:112:20: warning: variable ‘originY’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::postPaintWindow()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:172:11: warning: variable ‘originX’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:172:20: warning: variable ‘originY’ set but not used [-Wunused-but-set-variable]
[100%] Building CXX object plugins/simple-animations/CMakeFiles/animationsim.dir/__/__/generated/animationsim_options.cpp.o
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:214:55: warning: ‘angleY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:213:55: warning: ‘angleX’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::prePaintWindow()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:154:55: warning: ‘angleY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:153:55: warning: ‘angleX’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::applyTransform()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:102:51: warning: ‘originY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:102:51: warning: ‘originX’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:84:38: warning: ‘angleY’ may be used uninitialized in this function [-Wmaybe-uninitialized]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:83:38: w...

Read more...

3288. By MC Return on 2012-07-16

Rebased on latest lp:compiz (r3286)

3289. By MC Return on 2012-07-16

Fixed -Wmaybe-uninitialized build warnings

3290. By MC Return on 2012-07-18

Fixed variables 'originX' and 'originY' set but not used [-Wunused-but-set-variable] compiler warnings in RotateInAnim::prePaintWindow () and RotateInAnim::postPaintWindow () (rotatein.cpp)

3291. By MC Return on 2012-07-18

Reverted change in last commit

MC Return (mc-return) wrote :

Remaining warnings:

compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::prePaintWindow()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:112:11: warning: variable ‘originX’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:112:20: warning: variable ‘originY’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp: In member function ‘virtual void RotateInAnim::postPaintWindow()’:
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:172:11: warning: variable ‘originX’ set but not used [-Wunused-but-set-variable]
compiz.merge-plugin-simple-animations/plugins/simple-animations/src/rotatein.cpp:172:20: warning: variable ‘originY’ set but not used [-Wunused-but-set-variable]

3292. By MC Return on 2012-07-22

Fixed variables 'originX' and 'originY' set but not used [-Wunused-but-set-variable] compiler warnings in RotateInAnim::prePaintWindow () and RotateInAnim::postPaintWindow () (rotatein.cpp) by removing the 'originX' and 'originY' variables and the unnecessary, unused calculations with those variables

MC Return (mc-return) wrote :

I've also fixed the [-Wmaybe-uninitialized] warnings for 'parent' in member function ‘virtual void SheetAnim::step()’ in r3292 (forgot to add this info to the commit message).

MC Return (mc-return) wrote :

Tested all of the simple-animations (even with slow animations on).
Everything works smooth and the animations all look really nice. :)

The "Sheet" animation seems to "simplify" the window content - that is the only (minor) animation issue I've found with those.
Also somehow in the "Animation" plug-in the new simple-animations are just available for opening or closing animations, but not for minimizing, but I guess it is designed this way (have not analyzed this behavior yet).

Seems this branch is quite mature now.

3293. By MC Return on 2012-08-06

Merged lp:compiz

Sam Spilsbury (smspillaz) wrote :

Code wise this looks OK, could you tidy up the following things?

15 === added file 'plugins/simple-animations/VERSION'
16 --- plugins/simple-animations/VERSION 1970-01-01 00:00:00 +0000
17 +++ plugins/simple-animations/VERSION 2012-08-06 16:49:52 +0000
18 @@ -0,0 +1,1 @@
19 +0.9.5.0

That can be removed

565 + void step () { TransformAnim::step (); }
566 + bool updateBBUsed () { return true; }
567 + void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
568 + void applyTransform ();
569 + bool requiresTransformedWindow () const { return true; }
570 +

The indentation here is not correct, it can be 2 indents (1 8 wide tab) for updateBBUsed and requiresTransformedWindow

+ bool requiresTransformedWindow () const { return true; }

Ditto

Sam Spilsbury (smspillaz) :
review: Needs Fixing
3294. By MC Return on 2012-08-11

Removed plugins/simple-animations/VERSION

3295. By MC Return on 2012-08-11

Merged lp:compiz

3296. By MC Return on 2012-08-11

Hopefully fixed indentation

MC Return (mc-return) wrote :

> Code wise this looks OK, could you tidy up the following things?

Sure.

> 15 === added file 'plugins/simple-animations/VERSION'
> 16 --- plugins/simple-animations/VERSION 1970-01-01 00:00:00 +0000
> 17 +++ plugins/simple-animations/VERSION 2012-08-06 16:49:52 +0000
> 18 @@ -0,0 +1,1 @@
> 19 +0.9.5.0
>
> That can be removed

Removed in r3294.

> 565 + void step () { TransformAnim::step (); }
> 566 + bool updateBBUsed () { return true; }
> 567 + void updateBB (CompOutput &output) { TransformAnim::updateBB
> (output); }
> 568 + void applyTransform ();
> 569 + bool requiresTransformedWindow () const { return true; }
> 570 +
>
> The indentation here is not correct, it can be 2 indents (1 8 wide tab) for
> updateBBUsed and requiresTransformedWindow
>
> + bool requiresTransformedWindow () const { return true; }
>
> Ditto

Done.

review: Resubmit
3297. By MC Return on 2012-08-11

Reduced the scope of the variable 'distance'

3298. By MC Return on 2012-08-11

Fixed redundant condition checks (x4): If xRot/yRot > 270.0f, the comparison xRot/yRot > 90.0f is always true.

MC Return (mc-return) wrote :

I also ran cppcheck on this plug-in and found a few issues I've now fixed also.

1. Reduced the scope of the float distance

2. Removed redundant condition check of the angle (if the angle is more than 270 it will always be bigger than 90), but please check that again, because it might be a typo and it could also mean that the angle should be between 90 and 270.
The rotatein animation works perfectly though...

3. Not fixed yet: (warning) Member variable 'ExtensionPluginAnimSim::mOutput' is not initialized in the constructor.
Should this be fixed ?

3299. By MC Return on 2012-08-11

Fixed begginning -> beginning typo in tooltip

3300. By MC Return on 2012-08-12

Removed redundant newlines

3301. By MC Return on 2012-08-27

Added support for unminimize animations and simplified the code by also using the new class AnimEffectUsedFor like it was done for animationaddon.cpp already

Daniel van Vugt (vanvugt) wrote :

/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/src/animationsim.cpp: In member function ‘void AnimSimScreen::initAnimationList()’:
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/src/animationsim.cpp:90:35: error: no matching function for call to ‘AnimEffectInfo::AnimEffectInfo(const char [19], AnimEffectUsedFor&, bool, bool, bool, bool, bool, <unresolved overloaded function type>)’
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/src/animationsim.cpp:90:35: note: candidates are:
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/../animation/include/animation/animeffect.h:34:6: note: AnimEffectInfo::AnimEffectInfo(const char*, AnimEffectUsedFor, CreateAnimFunc, bool)
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/../animation/include/animation/animeffect.h:34:6: note: candidate expects 4 arguments, 8 provided
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/../animation/include/animation/animeffect.h:31:7: note: AnimEffectInfo::AnimEffectInfo(const AnimEffectInfo&)
/home/dan/bzr/compiz/tmp.simple/plugins/simple-animations/../animation/include/animation/animeffect.h:31:7: note: candidate expects 1 argument, 8 provided
make[2]: *** [plugins/simple-animations/CMakeFiles/animationsim.dir/src/animationsim.cpp.o] Error 1
make[1]: *** [plugins/simple-animations/CMakeFiles/animationsim.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

review: Needs Fixing

Unmerged revisions

3301. By MC Return on 2012-08-27

Added support for unminimize animations and simplified the code by also using the new class AnimEffectUsedFor like it was done for animationaddon.cpp already

3300. By MC Return on 2012-08-12

Removed redundant newlines

3299. By MC Return on 2012-08-11

Fixed begginning -> beginning typo in tooltip

3298. By MC Return on 2012-08-11

Fixed redundant condition checks (x4): If xRot/yRot > 270.0f, the comparison xRot/yRot > 90.0f is always true.

3297. By MC Return on 2012-08-11

Reduced the scope of the variable 'distance'

3296. By MC Return on 2012-08-11

Hopefully fixed indentation

3295. By MC Return on 2012-08-11

Merged lp:compiz

3294. By MC Return on 2012-08-11

Removed plugins/simple-animations/VERSION

3293. By MC Return on 2012-08-06

Merged lp:compiz

3292. By MC Return on 2012-07-22

Fixed variables 'originX' and 'originY' set but not used [-Wunused-but-set-variable] compiler warnings in RotateInAnim::prePaintWindow () and RotateInAnim::postPaintWindow () (rotatein.cpp) by removing the 'originX' and 'originY' variables and the unnecessary, unused calculations with those variables

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'plugins/simple-animations'
2=== added file 'plugins/simple-animations/CMakeLists.txt'
3--- plugins/simple-animations/CMakeLists.txt 1970-01-01 00:00:00 +0000
4+++ plugins/simple-animations/CMakeLists.txt 2012-08-27 11:08:22 +0000
5@@ -0,0 +1,8 @@
6+find_package (Compiz REQUIRED)
7+
8+include (FindOpenGL)
9+include (CompizPlugin)
10+
11+if (OPENGL_GLU_FOUND)
12+ compiz_plugin (animationsim PLUGINDEPS composite opengl animation LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
13+endif (OPENGL_GLU_FOUND)
14
15=== added file 'plugins/simple-animations/animationsim.xml.in'
16--- plugins/simple-animations/animationsim.xml.in 1970-01-01 00:00:00 +0000
17+++ plugins/simple-animations/animationsim.xml.in 2012-08-27 11:08:22 +0000
18@@ -0,0 +1,235 @@
19+<compiz>
20+ <plugin name="animationsim" useBcop="true">
21+ <_short>Simple Animations</_short>
22+ <_long>Animations that are simple on the eye</_long>
23+ <category>Effects</category>
24+ <deps>
25+ <requirement>
26+ <plugin>animation</plugin>
27+ </requirement>
28+ <relation type="after">
29+ <plugin>animation</plugin>
30+ </relation>
31+ </deps>
32+ <options>
33+
34+ <group>
35+ <_short>Effect Settings</_short>
36+
37+ <subgroup>
38+ <_short>Fly In</_short>
39+ <option name="flyin_direction" type="int">
40+ <_short>Fly In Direction</_short>
41+ <_long>The direction in which the fly in should take place</_long>
42+ <default>0</default>
43+ <desc>
44+ <value>0</value>
45+ <name>Up</name>
46+ </desc>
47+ <desc>
48+ <value>1</value>
49+ <name>Left</name>
50+ </desc>
51+ <desc>
52+ <value>2</value>
53+ <name>Down</name>
54+ </desc>
55+ <desc>
56+ <value>3</value>
57+ <name>Right</name>
58+ </desc>
59+ <desc>
60+ <value>4</value>
61+ <name>User Defined</name>
62+ </desc>
63+ <min>0</min>
64+ <max>4</max>
65+ </option>
66+ <option name="flyin_direction_x" type="float">
67+ <_short>UD Direction X</_short>
68+ <_long>Direction and Distance X for user defined fly in</_long>
69+ <default>0</default>
70+ <min>-1000</min>
71+ <max>1000</max>
72+ <precision>0.01</precision>
73+ </option>
74+ <option name="flyin_direction_y" type="float">
75+ <_short>UD Direction Y</_short>
76+ <_long>Direction and Distance Y for user defined fly in</_long>
77+ <default>0</default>
78+ <min>-1000</min>
79+ <max>1000</max>
80+ <precision>0.01</precision>
81+ </option>
82+ <option name="flyin_fade" type="bool">
83+ <_short>Fade</_short>
84+ <_long>Fade when flying in</_long>
85+ <default>True</default>
86+ </option>
87+ <option name="flyin_distance" type="float">
88+ <_short>Distance</_short>
89+ <_long>Distance to fly in</_long>
90+ <default>20</default>
91+ <min>5</min>
92+ <max>1000</max>
93+ <precision>0.01</precision>
94+ </option>
95+ </subgroup>
96+ <subgroup>
97+ <_short>Rotate In</_short>
98+ <option name="rotatein_direction" type="int">
99+ <_short>Rotate In Direction</_short>
100+ <_long>The direction in which the window rotates</_long>
101+ <default>3</default>
102+ <desc>
103+ <value>1</value>
104+ <name>Up</name>
105+ </desc>
106+ <desc>
107+ <value>2</value>
108+ <name>Left</name>
109+ </desc>
110+ <desc>
111+ <value>3</value>
112+ <name>Down</name>
113+ </desc>
114+ <desc>
115+ <value>4</value>
116+ <name>Right</name>
117+ </desc>
118+ <min>1</min>
119+ <max>4</max>
120+ </option>
121+ <option name="rotatein_angle" type="float">
122+ <_short>Angle</_short>
123+ <_long>Angle to start from</_long>
124+ <default>90</default>
125+ <min>-720</min>
126+ <max>720</max>
127+ </option>
128+ </subgroup>
129+ <subgroup>
130+ <_short>Bounce</_short>
131+ <option name="bounce_max_size" type="float">
132+ <_short>Maximum Size</_short>
133+ <_long>Maximum scale factor of window when bouncing</_long>
134+ <default>1.2</default>
135+ <min>1.0</min>
136+ <max>3.0</max>
137+ </option>
138+ <option name="bounce_min_size" type="float">
139+ <_short>Minimum Size</_short>
140+ <_long>Minimum scale factor of window when bouncing</_long>
141+ <default>0.6</default>
142+ <min>0.1</min>
143+ <max>1.0</max>
144+ </option>
145+ <option name="bounce_number" type="int">
146+ <_short>Number of Bounces</_short>
147+ <_long>How many bounces during the animation</_long>
148+ <default>3</default>
149+ <min>0</min>
150+ <max>10</max>
151+ </option>
152+ <option name="bounce_fade" type="bool">
153+ <_short>Fade</_short>
154+ <_long>Fade when flying in</_long>
155+ <default>True</default>
156+ </option>
157+ </subgroup>
158+ <subgroup>
159+ <_short>Sheet</_short>
160+ <option name="sheet_start_percent" type="float">
161+ <_short>Starting Percent</_short>
162+ <_long>How wide the beginning of the sheet animation should be compared to the end</_long>
163+ <default>80.0</default>
164+ <min>1.0</min>
165+ <max>150.0</max>
166+ </option>
167+ </subgroup>
168+ <subgroup>
169+ <_short>Fan</_short>
170+ <option name="fan_angle" type="float">
171+ <_short>Fan Angle</_short>
172+ <_long>Angle of windows away from the main window</_long>
173+ <default>35</default>
174+ <min>0</min>
175+ <max>90</max>
176+ <precision>0.1</precision>
177+ </option>
178+ </subgroup>
179+ <subgroup>
180+ <_short>Expand Piecewise</_short>
181+ <option name="expandpw_horiz_first" type="bool">
182+ <_short>First expand horizontally</_short>
183+ <_long>If checked, initially expand horizontally, then vertically</_long>
184+ <default>True</default>
185+ </option>
186+ <option name="expandpw_initial_horiz" type="int">
187+ <_short>Initial horizontal size</_short>
188+ <_long>Number of pixels initially in horizontal direction</_long>
189+ <default>20</default>
190+ <min>0</min>
191+ <max>50</max>
192+ </option>
193+ <option name="expandpw_initial_vert" type="int">
194+ <_short>Initial vertical size</_short>
195+ <_long>Number of pixels initially in vertical direction</_long>
196+ <default>20</default>
197+ <min>0</min>
198+ <max>50</max>
199+ </option>
200+ <option name="expandpw_delay" type="float">
201+ <_short>Delay</_short>
202+ <_long>Delay between expanding horizontally and vertically (expressed as a fraction)</_long>
203+ <default>0.25</default>
204+ <min>0.0</min>
205+ <max>1.0</max>
206+ </option>
207+ </subgroup>
208+
209+ </group>
210+
211+ </options>
212+
213+ <extension base_plugin="animation">
214+ <base_option>open_effects</base_option>
215+ <base_option>open_random_effects</base_option>
216+ <base_option>close_effects</base_option>
217+ <base_option>close_random_effects</base_option>
218+ <restriction>
219+ <value>animationsim:Fly In</value>
220+ <_name>Fly In</_name>
221+ </restriction>
222+ <restriction>
223+ <value>animationsim:Bounce</value>
224+ <_name>Bounce</_name>
225+ </restriction>
226+ <restriction>
227+ <value>animationsim:Rotate In</value>
228+ <_name>Rotate In</_name>
229+ </restriction>
230+ <restriction>
231+ <value>animationsim:Sheet</value>
232+ <_name>Sheet</_name>
233+ </restriction>
234+ <restriction>
235+ <value>animationsim:Expand</value>
236+ <_name>Expand</_name>
237+ </restriction>
238+ <restriction>
239+ <value>animationsim:Expand Piecewise</value>
240+ <_name>Expand Piecewise</_name>
241+ </restriction>
242+ <restriction>
243+ <value>animationsim:Pulse</value>
244+ <_name>Pulse</_name>
245+ </restriction>
246+ <restriction>
247+ <value>animationsim:Fan</value>
248+ <_name>Fan</_name>
249+ </restriction>
250+ </extension>
251+
252+ </plugin>
253+</compiz>
254
255=== added directory 'plugins/simple-animations/src'
256=== added file 'plugins/simple-animations/src/animationsim.cpp'
257--- plugins/simple-animations/src/animationsim.cpp 1970-01-01 00:00:00 +0000
258+++ plugins/simple-animations/src/animationsim.cpp 2012-08-27 11:08:22 +0000
259@@ -0,0 +1,160 @@
260+/**
261+ * Example Animation extension plugin for compiz
262+ *
263+ *
264+ * This program is free software; you can redistribute it and/or
265+ * modify it under the terms of the GNU General Public License
266+ * as published by the Free Software Foundation; either version 2
267+ * of the License, or (at your option) any later version.
268+ *
269+ * This program is distributed in the hope that it will be useful,
270+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
271+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
272+ * GNU General Public License for more details.
273+ *
274+ * You should have received a copy of the GNU General Public License
275+ * along with this program; if not, write to the Free Software
276+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
277+ **/
278+
279+#include "animationsim.h"
280+
281+COMPIZ_PLUGIN_20090315 (animationsim, AnimSimPluginVTable);
282+
283+AnimEffect animEffects[NUM_EFFECTS];
284+
285+ExtensionPluginAnimSim animSimExtPluginInfo (CompString ("animationsim"),
286+ NUM_EFFECTS, animEffects, NULL,
287+ NUM_NONEFFECT_OPTIONS);
288+
289+ExtensionPluginInfo *
290+BaseSimAnim::getExtensionPluginInfo ()
291+{
292+ return &animSimExtPluginInfo;
293+}
294+
295+BaseSimAnim::BaseSimAnim (CompWindow *w,
296+ WindowEvent curWindowEvent,
297+ float duration,
298+ const AnimEffect info,
299+ const CompRect &icon) :
300+ Animation::Animation (w, curWindowEvent, duration, info, icon),
301+ mCScreen (CompositeScreen::get (::screen)),
302+ mGScreen (GLScreen::get (::screen))
303+{
304+}
305+
306+AnimEffect AnimEffectFlyIn;
307+AnimEffect AnimEffectRotateIn;
308+AnimEffect AnimEffectExpand;
309+AnimEffect AnimEffectExpandPW;
310+AnimEffect AnimEffectBounce;
311+AnimEffect AnimEffectSheet;
312+AnimEffect AnimEffectPulse;
313+AnimEffect AnimEffectFan;
314+
315+void
316+AnimSimScreen::initAnimationList ()
317+{
318+ int i = 0;
319+ AnimEffectUsedFor usedFor = AnimEffectUsedFor::all()
320+ .exclude(AnimEventFocus)
321+ .exclude(AnimEventShade);
322+
323+ animEffects[i++] = AnimEffectFlyIn =
324+ new AnimEffectInfo ("animationsim:Fly In", usedFor,
325+ &createAnimation<FlyInAnim>);
326+
327+ animEffects[i++] = AnimEffectRotateIn =
328+ new AnimEffectInfo ("animationsim:Rotate In", usedFor,
329+ &createAnimation<RotateInAnim>);
330+
331+ animEffects[i++] = AnimEffectExpand =
332+ new AnimEffectInfo ("animationsim:Expand", usedFor,
333+ &createAnimation<ExpandAnim>);
334+
335+ animEffects[i++] = AnimEffectExpandPW =
336+ new AnimEffectInfo ("animationsim:Expand Piecewise", usedFor,
337+ &createAnimation<ExpandPWAnim>);
338+
339+ animEffects[i++] = AnimEffectBounce =
340+ new AnimEffectInfo ("animationsim:Bounce", usedFor,
341+ &createAnimation<BounceAnim>);
342+
343+ animEffects[i++] = AnimEffectSheet =
344+ new AnimEffectInfo ("animationsim:Sheet", usedFor,
345+ &createAnimation<SheetAnim>);
346+ animEffects[i++] = AnimEffectPulse =
347+ new AnimEffectInfo ("animationsim:Pulse", usedFor,
348+ true, true, true, false, false,
349+ &createAnimation<PulseAnim>);
350+ animEffects[i++] = AnimEffectFan =
351+ new AnimEffectInfo ("animationsim:Fan", usedFor,
352+ &createAnimation<FanAnim>);
353+
354+ animSimExtPluginInfo.effectOptions = &getOptions ();
355+
356+ AnimScreen *as = AnimScreen::get (::screen);
357+
358+ // Extends animation plugin with this set of animation effects.
359+ as->addExtension (&animSimExtPluginInfo);
360+}
361+
362+AnimSimScreen::AnimSimScreen (CompScreen *s) :
363+ //cScreen (CompositeScreen::get (s)),
364+ //gScreen (GLScreen::get (s)),
365+ //aScreen (as),
366+ PluginClassHandler <AnimSimScreen, CompScreen> (s),
367+ mOutput (s->fullscreenOutput ())
368+{
369+ initAnimationList ();
370+}
371+
372+AnimSimScreen::~AnimSimScreen ()
373+{
374+ AnimScreen *as = AnimScreen::get (::screen);
375+
376+ as->removeExtension (&animSimExtPluginInfo);
377+
378+ for (int i = 0; i < NUM_EFFECTS; i++)
379+ {
380+ delete animEffects[i];
381+ animEffects[i] = NULL;
382+ }
383+}
384+
385+AnimSimWindow::AnimSimWindow (CompWindow *w) :
386+ PluginClassHandler<AnimSimWindow, CompWindow> (w),
387+ mWindow (w),
388+ aWindow (AnimWindow::get (w))
389+{
390+}
391+
392+AnimSimWindow::~AnimSimWindow ()
393+{
394+ Animation *curAnim = aWindow->curAnimation ();
395+
396+ if (!curAnim)
397+ return;
398+
399+ // We need to interrupt and clean up the animation currently being played
400+ // by animationsim for this window (if any)
401+ if (curAnim->remainingTime () > 0 &&
402+ curAnim->getExtensionPluginInfo ()->name ==
403+ CompString ("animationsim"))
404+ {
405+ aWindow->postAnimationCleanUp ();
406+ }
407+}
408+
409+bool
410+AnimSimPluginVTable::init ()
411+{
412+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) |
413+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) |
414+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) |
415+ !CompPlugin::checkPluginABI ("animation", ANIMATION_ABI))
416+ return false;
417+
418+ return true;
419+}
420
421=== added file 'plugins/simple-animations/src/animationsim.h'
422--- plugins/simple-animations/src/animationsim.h 1970-01-01 00:00:00 +0000
423+++ plugins/simple-animations/src/animationsim.h 2012-08-27 11:08:22 +0000
424@@ -0,0 +1,405 @@
425+#include <string.h>
426+#include <stdlib.h>
427+#include <math.h>
428+
429+#include <core/core.h>
430+#include <composite/composite.h>
431+#include <opengl/opengl.h>
432+#include <animation/animation.h>
433+
434+#include "animationsim_options.h"
435+
436+extern AnimEffect AnimEffectFlyIn;
437+extern AnimEffect AnimEffectBounce;
438+extern AnimEffect AnimEffectRotateIn;
439+extern AnimEffect AnimEffectSheet;
440+extern AnimEffect AnimEffectExpand;
441+extern AnimEffect AnimEffectExpandPW;
442+extern AnimEffect AnimEffectFan;
443+
444+// TODO Update this for each added animation effect! (total: 8)
445+#define NUM_EFFECTS 8
446+
447+// This must have the value of the first "effect setting" above
448+// in AnimAddonScreenOptions
449+#define NUM_NONEFFECT_OPTIONS AnimationsimOptions::FlyinDirection
450+
451+#define WIN_X(w) ((w)->x () - (w)->input ().left)
452+#define WIN_Y(w) ((w)->y () - (w)->input ().top)
453+#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
454+#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
455+
456+class ExtensionPluginAnimSim : public ExtensionPluginInfo
457+{
458+public:
459+ ExtensionPluginAnimSim (const CompString &name,
460+ unsigned int nEffects,
461+ AnimEffect *effects,
462+ CompOption::Vector *effectOptions,
463+ unsigned int firstEffectOptionIndex) :
464+ ExtensionPluginInfo (name, nEffects, effects, effectOptions,
465+ firstEffectOptionIndex) {}
466+ ~ExtensionPluginAnimSim () {}
467+
468+ const CompOutput *output () { return mOutput; }
469+
470+private:
471+ const CompOutput *mOutput;
472+};
473+
474+/// Base class for all polygon- and particle-based animations
475+class BaseSimAnim :
476+virtual public Animation
477+{
478+public:
479+ BaseSimAnim (CompWindow *w,
480+ WindowEvent curWindowEvent,
481+ float duration,
482+ const AnimEffect info,
483+ const CompRect &icon);
484+ ~BaseSimAnim () {}
485+
486+protected:
487+ /// Gets info about the extension plugin that implements this animation.
488+ ExtensionPluginInfo *getExtensionPluginInfo ();
489+
490+ CompositeScreen *mCScreen;
491+ GLScreen *mGScreen;
492+
493+};
494+
495+
496+class AnimSimScreen :
497+ public PluginClassHandler <AnimSimScreen, CompScreen>,
498+ public AnimationsimOptions
499+{
500+
501+public:
502+ AnimSimScreen (CompScreen *);
503+ ~AnimSimScreen ();
504+
505+protected:
506+ void initAnimationList ();
507+
508+ CompOutput &mOutput;
509+};
510+
511+class AnimSimWindow :
512+ public PluginClassHandler<AnimSimWindow, CompWindow>
513+{
514+public:
515+ AnimSimWindow (CompWindow *);
516+ ~AnimSimWindow ();
517+
518+protected:
519+ CompWindow *mWindow; ///< Window being animated.
520+ AnimWindow *aWindow;
521+};
522+
523+/*
524+typedef struct _WaveParam
525+{
526+ float halfWidth;
527+ float amp;
528+ float pos;
529+} WaveParam;
530+*/
531+
532+#define ANIMSIM_SCREEN(s) \
533+ AnimSimScreen *ass = AnimSimScreen::get (s);
534+
535+#define ANIMSIM_WINDOW(w) \
536+ AnimSimWindow *asw = AnimSimWindow::get (w);
537+
538+class FlyInAnim : public FadeAnim,
539+ virtual public BaseSimAnim,
540+ virtual public TransformAnim
541+{
542+ public:
543+
544+ FlyInAnim (CompWindow *w,
545+ WindowEvent curWindowEvent,
546+ float duration,
547+ const AnimEffect info,
548+ const CompRect &icon) :
549+ Animation::Animation (w, curWindowEvent, duration, info, icon),
550+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
551+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
552+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon) {}
553+
554+ protected:
555+ void step () { TransformAnim::step (); }
556+ bool updateBBUsed () { return true; }
557+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
558+ void applyTransform ();
559+ bool requiresTransformedWindow () const { return true; }
560+
561+ float getFadeProgress ()
562+ {
563+ return progressDecelerate (progressLinear ());
564+ }
565+};
566+
567+class RotateInAnim: public TransformAnim,
568+ virtual public BaseSimAnim
569+{
570+ public:
571+
572+ RotateInAnim (CompWindow *w,
573+ WindowEvent curWindowEvent,
574+ float duration,
575+ const AnimEffect info,
576+ const CompRect &icon) :
577+ Animation::Animation (w, curWindowEvent, duration, info, icon),
578+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
579+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
580+
581+ protected:
582+
583+ void step () { TransformAnim::step (); }
584+ bool updateBBUsed () { return true; }
585+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
586+ void applyTransform ();
587+ void prePaintWindow ();
588+ void postPaintWindow ();
589+
590+ inline float getProgress ()
591+ {
592+ return progressDecelerate (progressLinear ());
593+ }
594+};
595+
596+class ExpandAnim: public TransformAnim,
597+ virtual public BaseSimAnim
598+{
599+ public:
600+
601+ ExpandAnim (CompWindow *w,
602+ WindowEvent curWindowEvent,
603+ float duration,
604+ const AnimEffect info,
605+ const CompRect &icon) :
606+ Animation::Animation (w, curWindowEvent, duration, info, icon),
607+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
608+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
609+
610+ protected:
611+
612+ inline float getProgress ()
613+ {
614+ return progressDecelerate (progressLinear ());
615+ }
616+
617+ void applyTransform ();
618+ bool updateBBUsed () { return true; }
619+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
620+};
621+
622+class ExpandPWAnim: public TransformAnim,
623+ virtual public BaseSimAnim
624+{
625+ public:
626+
627+ ExpandPWAnim (CompWindow *w,
628+ WindowEvent curWindowEvent,
629+ float duration,
630+ const AnimEffect info,
631+ const CompRect &icon) :
632+ Animation::Animation (w, curWindowEvent, duration, info, icon),
633+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
634+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon)
635+ {
636+ }
637+
638+ protected:
639+
640+ inline float getProgress ()
641+ {
642+ return progressDecelerate (progressLinear ());
643+ }
644+
645+ void applyTransform ();
646+ bool updateBBUsed () { return true; }
647+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
648+};
649+
650+class BounceAnim: public FadeAnim,
651+ virtual public TransformAnim,
652+ virtual public BaseSimAnim
653+{
654+ public:
655+
656+ BounceAnim (CompWindow *w,
657+ WindowEvent curWindowEvent,
658+ float duration,
659+ const AnimEffect info,
660+ const CompRect &icon) :
661+ Animation::Animation (w, curWindowEvent, duration, info, icon),
662+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
663+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
664+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon)
665+ {
666+ ANIMSIM_SCREEN (screen);
667+
668+ bounceCount = ass->optionGetBounceNumber ();
669+ nBounce = 1;
670+ targetScale = ass->optionGetBounceMinSize ();
671+ currentScale = ass->optionGetBounceMaxSize ();
672+ bounceNeg = false;
673+ currBounceProgress = 0.0f;
674+ lastProgressMax = 0.0f;
675+ }
676+
677+ protected:
678+
679+ void step () { TransformAnim::step (); }
680+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
681+ bool updateBBUsed () { return true; }
682+ bool requiresTransformedWindow () const { return true; }
683+
684+ void applyTransform ();
685+
686+ float getProgress ();
687+ float getFadeProgress ()
688+ {
689+ return progressDecelerate (progressLinear ());
690+ }
691+
692+ int bounceCount;
693+ int nBounce;
694+ float targetScale;
695+ float currentScale;
696+ bool bounceNeg;
697+ float currBounceProgress;
698+ float lastProgressMax;
699+};
700+
701+class SheetAnim : public GridAnim,
702+ virtual public BaseSimAnim
703+{
704+ public:
705+
706+ SheetAnim (CompWindow *w,
707+ WindowEvent curWindowEvent,
708+ float duration,
709+ const AnimEffect info,
710+ const CompRect &icon);
711+
712+ class WaveParam
713+ {
714+ public:
715+ float halfWidth;
716+ float amp;
717+ float pos;
718+ };
719+
720+ protected:
721+
722+ void initGrid ()
723+ {
724+ mGridWidth = 30;
725+ mGridHeight = 30;
726+ }
727+
728+ void step ();
729+ void updateBB (CompOutput &output);
730+ bool updateBBUsed () { return true; }
731+ bool stepRegionUsed () { return true; }
732+
733+ int sheetsWaveCount;
734+ std::vector <WaveParam> sheetsWaves;
735+};
736+
737+class PulseSingleAnim : public TransformAnim,
738+ virtual public FadeAnim,
739+ virtual public BaseSimAnim
740+{
741+ public:
742+
743+ PulseSingleAnim (CompWindow *w,
744+ WindowEvent curWindowEvent,
745+ float duration,
746+ const AnimEffect info,
747+ const CompRect &icon) :
748+ Animation::Animation (w, curWindowEvent, duration, info, icon),
749+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon),
750+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
751+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
752+
753+ void step () { TransformAnim::step (); }
754+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
755+ bool updateBBUsed () { return true; }
756+
757+ float getProgress () { return progressLinear (); }
758+ float getFadeProgress ();
759+
760+ void applyTransform ();
761+
762+ protected:
763+
764+ bool requiresTransformedWindow () const { return true; }
765+};
766+
767+class PulseAnim : public MultiAnim <PulseSingleAnim, 2>
768+{
769+ public:
770+
771+ PulseAnim (CompWindow *w,
772+ WindowEvent curWindowEvent,
773+ float duration,
774+ const AnimEffect info,
775+ const CompRect &icon) :
776+ MultiAnim <PulseSingleAnim, 2>::MultiAnim
777+ (w, curWindowEvent, duration, info, icon) {}
778+
779+};
780+
781+class FanSingleAnim : public TransformAnim,
782+ virtual public FadeAnim,
783+ virtual public BaseSimAnim
784+{
785+ public:
786+
787+ FanSingleAnim (CompWindow *w,
788+ WindowEvent curWindowEvent,
789+ float duration,
790+ const AnimEffect info,
791+ const CompRect &icon) :
792+ Animation::Animation (w, curWindowEvent, duration, info, icon),
793+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon),
794+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
795+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
796+
797+ void step () { TransformAnim::step (); }
798+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
799+ bool updateBBUsed () { return true; }
800+
801+ float getProgress () { return progressLinear (); }
802+ float getFadeProgress ();
803+
804+ void applyTransform ();
805+
806+ protected:
807+
808+ bool requiresTransformedWindow () const { return true; }
809+};
810+
811+class FanAnim : public MultiAnim <FanSingleAnim, 6>
812+{
813+ public:
814+
815+ FanAnim (CompWindow *w,
816+ WindowEvent curWindowEvent,
817+ float duration,
818+ const AnimEffect info,
819+ const CompRect &icon) :
820+ MultiAnim <FanSingleAnim, 6>::MultiAnim
821+ (w, curWindowEvent, duration, info, icon) {}
822+};
823+
824+class AnimSimPluginVTable:
825+ public CompPlugin::VTableForScreenAndWindow <AnimSimScreen, AnimSimWindow>
826+{
827+ public:
828+ bool init ();
829+};
830
831=== added file 'plugins/simple-animations/src/bounce.cpp'
832--- plugins/simple-animations/src/bounce.cpp 1970-01-01 00:00:00 +0000
833+++ plugins/simple-animations/src/bounce.cpp 2012-08-27 11:08:22 +0000
834@@ -0,0 +1,76 @@
835+/*
836+ * Animation plugin for compiz/beryl
837+ *
838+ * animation.c
839+ *
840+ * Copyright : (C) 2006 Erkin Bahceci
841+ * E-mail : erkinbah@gmail.com
842+ *
843+ * Based on Wobbly and Minimize plugins by
844+ * : David Reveman
845+ * E-mail : davidr@novell.com>
846+ *
847+ * Particle system added by : (C) 2006 Dennis Kasprzyk
848+ * E-mail : onestone@beryl-project.org
849+ *
850+ * Beam-Up added by : Florencio Guimaraes
851+ * E-mail : florencio@nexcorp.com.br
852+ *
853+ * Hexagon tessellator added by : Mike Slegeir
854+ * E-mail : mikeslegeir@mail.utexas.edu>
855+ *
856+ * This program is free software; you can redistribute it and/or
857+ * modify it under the terms of the GNU General Public License
858+ * as published by the Free Software Foundation; either version 2
859+ * of the License, or (at your option) any later version.
860+ *
861+ * This program is distributed in the hope that it will be useful,
862+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
863+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
864+ * GNU General Public License for more details.
865+ *
866+ * You should have received a copy of the GNU General Public License
867+ * along with this program; if not, write to the Free Software
868+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
869+ */
870+
871+#include "animationsim.h"
872+
873+// ===================== Effect: Bounce =========================
874+
875+float
876+BounceAnim::getProgress ()
877+{
878+ return progressLinear ();
879+}
880+
881+void
882+BounceAnim::applyTransform ()
883+{
884+ float scale = 1.0f - (targetScale * (currBounceProgress) + currentScale * (1.0f - currBounceProgress));
885+ float forwardProgress = getProgress ();;
886+ float forwardProgressInc = 1.0f / bounceCount;
887+
888+ /* last bounce, enure we are going for 0.0 */
889+ currBounceProgress = (((1 - forwardProgress) - lastProgressMax) / forwardProgressInc);
890+
891+ if (currBounceProgress > 1.0f)
892+ {
893+ currentScale = targetScale;
894+ targetScale = -targetScale + targetScale / 2.0f;
895+ lastProgressMax = 1.0f - forwardProgress;
896+ currBounceProgress = 0.0f;
897+ nBounce++;
898+ }
899+
900+ GLMatrix *transform = &mTransform;
901+
902+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
903+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f, 0.0f);
904+
905+ transform->scale (scale, scale, 1.0f);
906+
907+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
908+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f), 0.0f);
909+
910+}
911
912=== added file 'plugins/simple-animations/src/expand-piecewise.cpp'
913--- plugins/simple-animations/src/expand-piecewise.cpp 1970-01-01 00:00:00 +0000
914+++ plugins/simple-animations/src/expand-piecewise.cpp 2012-08-27 11:08:22 +0000
915@@ -0,0 +1,90 @@
916+/*
917+ * Animation plugin for compiz/beryl
918+ *
919+ * animation.c
920+ *
921+ * Copyright : (C) 2006 Erkin Bahceci
922+ * E-mail : erkinbah@gmail.com
923+ *
924+ * Based on Wobbly and Minimize plugins by
925+ * : David Reveman
926+ * E-mail : davidr@novell.com>
927+ *
928+ * Particle system added by : (C) 2006 Dennis Kasprzyk
929+ * E-mail : onestone@beryl-project.org
930+ *
931+ * Beam-Up added by : Florencio Guimaraes
932+ * E-mail : florencio@nexcorp.com.br
933+ *
934+ * Hexagon tessellator added by : Mike Slegeir
935+ * E-mail : mikeslegeir@mail.utexas.edu>
936+ *
937+ * This program is free software; you can redistribute it and/or
938+ * modify it under the terms of the GNU General Public License
939+ * as published by the Free Software Foundation; either version 2
940+ * of the License, or (at your option) any later version.
941+ *
942+ * This program is distributed in the hope that it will be useful,
943+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
944+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
945+ * GNU General Public License for more details.
946+ *
947+ * You should have received a copy of the GNU General Public License
948+ * along with this program; if not, write to the Free Software
949+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
950+ */
951+
952+#include "animationsim.h"
953+#define DELTA 0.0001f
954+
955+// ===================== Effect: ExpandPW =========================
956+
957+void
958+ExpandPWAnim::applyTransform ()
959+{
960+ ANIMSIM_SCREEN (screen);
961+
962+ GLMatrix *transform = &mTransform;
963+
964+ float forwardProgress = 1.0f - getProgress ();
965+
966+ float initialXScale = ass->optionGetExpandpwInitialHoriz () / (float) mWindow->width ();
967+ float initialYScale = ass->optionGetExpandpwInitialVert () / (float) mWindow->height ();
968+
969+ // animation movement
970+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
971+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
972+ 0.0f);
973+
974+ float xScale;
975+ float yScale;
976+ float switchPointP;
977+ float switchPointN;
978+ float delay = ass->optionGetExpandpwDelay ();
979+
980+ if (ass->optionGetExpandpwHorizFirst ())
981+ {
982+ switchPointP = mWindow->width () / (float) (mWindow->width () + mWindow->height ()) + mWindow->height () / (float) (mWindow->width () + mWindow->height ()) * delay;
983+ switchPointN = mWindow->width () / (float) (mWindow->width () + mWindow->height ()) - mWindow->width () / (float) (mWindow->width () + mWindow->height ()) * delay;
984+ if(switchPointP >= 1.0f) switchPointP = 1.0f - DELTA;
985+ if(switchPointN <= 0.0f) switchPointN = 0.0f + DELTA;
986+ xScale = initialXScale + (1.0f - initialXScale) * (forwardProgress < switchPointN ? 1.0f - (switchPointN - forwardProgress)/switchPointN : 1.0f);
987+ yScale = initialYScale + (1.0f - initialYScale) * (forwardProgress > switchPointP ? (forwardProgress - switchPointP)/(1.0f-switchPointP) : 0.0f);
988+ }
989+ else
990+ {
991+ switchPointP = mWindow->height () / (float) (mWindow->width () + mWindow->height ()) + mWindow->width () / (float) (mWindow->width () + mWindow->height ()) * delay;
992+ switchPointN = mWindow->height () / (float) (mWindow->width () + mWindow->height ()) - mWindow->height () / (float) (mWindow->width () + mWindow->height ()) * delay;
993+ if(switchPointP >= 1.0f) switchPointP = 1.0f - DELTA;
994+ if(switchPointN <= 0.0f) switchPointN = 0.0f + DELTA;
995+ xScale = initialXScale + (1.0f - initialXScale) * (forwardProgress > switchPointP ? (forwardProgress - switchPointP)/(1.0f-switchPointP) : 0.0f);
996+ yScale = initialYScale + (1.0f - initialYScale) * (forwardProgress < switchPointN ? 1.0f - (switchPointN - forwardProgress)/switchPointN : 1.0f);
997+ }
998+
999+ transform->scale (xScale, yScale, 0.0f);
1000+
1001+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
1002+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
1003+ 0.0f);
1004+
1005+}
1006
1007=== added file 'plugins/simple-animations/src/expand.cpp'
1008--- plugins/simple-animations/src/expand.cpp 1970-01-01 00:00:00 +0000
1009+++ plugins/simple-animations/src/expand.cpp 2012-08-27 11:08:22 +0000
1010@@ -0,0 +1,70 @@
1011+/*
1012+ * Animation plugin for compiz/beryl
1013+ *
1014+ * animation.c
1015+ *
1016+ * Copyright : (C) 2006 Erkin Bahceci
1017+ * E-mail : erkinbah@gmail.com
1018+ *
1019+ * Based on Wobbly and Minimize plugins by
1020+ * : David Reveman
1021+ * E-mail : davidr@novell.com>
1022+ *
1023+ * Particle system added by : (C) 2006 Dennis Kasprzyk
1024+ * E-mail : onestone@beryl-project.org
1025+ *
1026+ * Beam-Up added by : Florencio Guimaraes
1027+ * E-mail : florencio@nexcorp.com.br
1028+ *
1029+ * Hexagon tessellator added by : Mike Slegeir
1030+ * E-mail : mikeslegeir@mail.utexas.edu>
1031+ *
1032+ * This program is free software; you can redistribute it and/or
1033+ * modify it under the terms of the GNU General Public License
1034+ * as published by the Free Software Foundation; either version 2
1035+ * of the License, or (at your option) any later version.
1036+ *
1037+ * This program is distributed in the hope that it will be useful,
1038+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1039+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1040+ * GNU General Public License for more details.
1041+ *
1042+ * You should have received a copy of the GNU General Public License
1043+ * along with this program; if not, write to the Free Software
1044+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1045+ */
1046+
1047+#include "animationsim.h"
1048+
1049+// ===================== Effect: Expand =========================
1050+
1051+void
1052+ExpandAnim::applyTransform ()
1053+{
1054+ GLMatrix *transform = &mTransform;
1055+ float defaultXScale = 0.3f;
1056+ float forwardProgress;
1057+ float expandProgress;
1058+ const float expandPhaseEnd = 0.5f;
1059+
1060+ forwardProgress = getProgress ();
1061+
1062+ if ((1 - forwardProgress) < expandPhaseEnd)
1063+ expandProgress = (1 - forwardProgress) / expandPhaseEnd;
1064+ else
1065+ expandProgress = 1.0f;
1066+
1067+ // animation movement
1068+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
1069+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
1070+ 0.0f);
1071+
1072+ transform->scale (defaultXScale + (1.0f - defaultXScale) *
1073+ expandProgress,
1074+ (1 - forwardProgress), 0.0f);
1075+
1076+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
1077+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
1078+ 0.0f);
1079+
1080+}
1081
1082=== added file 'plugins/simple-animations/src/fan.cpp'
1083--- plugins/simple-animations/src/fan.cpp 1970-01-01 00:00:00 +0000
1084+++ plugins/simple-animations/src/fan.cpp 2012-08-27 11:08:22 +0000
1085@@ -0,0 +1,51 @@
1086+#include "animationsim.h"
1087+
1088+float
1089+FanSingleAnim::getFadeProgress ()
1090+{
1091+ return getProgress ();
1092+};
1093+
1094+void
1095+FanSingleAnim::applyTransform ()
1096+{
1097+ /* Starting angle is as a percentage of whichever fan number we are
1098+ * closest to the center
1099+ */
1100+
1101+ ANIMSIM_SCREEN (screen);
1102+
1103+ int num = MultiAnim <FanSingleAnim, 6>::getCurrAnimNumber (mAWindow);
1104+
1105+ if (num > 2)
1106+ num += 1;
1107+
1108+ float div = (ass->optionGetFanAngle () * 2) / 6;
1109+ float startAng = -(ass->optionGetFanAngle ()) + (div * num);
1110+ float currAng = getProgress () * startAng;
1111+ float offset = (1 - getProgress ()) * (WIN_H (mWindow) / 2);
1112+
1113+ if (num > 3)
1114+ num += 1;
1115+
1116+ if (num > 3)
1117+ {
1118+ mTransform.translate (WIN_X (mWindow) + WIN_W (mWindow) - offset,
1119+ WIN_Y (mWindow) + WIN_H (mWindow),
1120+ 0.0f);
1121+ mTransform.rotate (currAng, 0.0f, 0.0f, 1.0f);
1122+ mTransform.translate (-(WIN_X (mWindow) + WIN_W (mWindow) - offset),
1123+ -(WIN_Y (mWindow) + WIN_H (mWindow)),
1124+ 0.0f);
1125+ }
1126+ else
1127+ {
1128+ mTransform.translate (WIN_X (mWindow) + offset,
1129+ WIN_Y (mWindow) + WIN_H (mWindow),
1130+ 0.0f);
1131+ mTransform.rotate (currAng, 0.0f, 0.0f, 1.0f);
1132+ mTransform.translate (-(WIN_X (mWindow) + offset),
1133+ -(WIN_Y (mWindow) + WIN_H (mWindow)),
1134+ 0.0f);
1135+ }
1136+}
1137
1138=== added file 'plugins/simple-animations/src/flyin.cpp'
1139--- plugins/simple-animations/src/flyin.cpp 1970-01-01 00:00:00 +0000
1140+++ plugins/simple-animations/src/flyin.cpp 2012-08-27 11:08:22 +0000
1141@@ -0,0 +1,86 @@
1142+/*
1143+ * Animation plugin for compiz/beryl
1144+ *
1145+ * animation.c
1146+ *
1147+ * Copyright : (C) 2006 Erkin Bahceci
1148+ * E-mail : erkinbah@gmail.com
1149+ *
1150+ * Based on Wobbly and Minimize plugins by
1151+ * : David Reveman
1152+ * E-mail : davidr@novell.com>
1153+ *
1154+ * Particle system added by : (C) 2006 Dennis Kasprzyk
1155+ * E-mail : onestone@beryl-project.org
1156+ *
1157+ * Beam-Up added by : Florencio Guimaraes
1158+ * E-mail : florencio@nexcorp.com.br
1159+ *
1160+ * Hexagon tessellator added by : Mike Slegeir
1161+ * E-mail : mikeslegeir@mail.utexas.edu>
1162+ *
1163+ * This program is free software; you can redistribute it and/or
1164+ * modify it under the terms of the GNU General Public License
1165+ * as published by the Free Software Foundation; either version 2
1166+ * of the License, or (at your option) any later version.
1167+ *
1168+ * This program is distributed in the hope that it will be useful,
1169+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1170+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1171+ * GNU General Public License for more details.
1172+ *
1173+ * You should have received a copy of the GNU General Public License
1174+ * along with this program; if not, write to the Free Software
1175+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1176+ */
1177+
1178+#include "animationsim.h"
1179+
1180+// ===================== Effect: Flyin =========================
1181+
1182+void
1183+FlyInAnim::applyTransform ()
1184+{
1185+ GLMatrix *transform = &mTransform;
1186+ float offsetX = 0, offsetY = 0;
1187+ float xTrans, yTrans;
1188+ float forwardProgress;
1189+
1190+ ANIMSIM_SCREEN (screen);
1191+
1192+ int direction = ass->optionGetFlyinDirection ();
1193+ float distance = ass->optionGetFlyinDistance ();
1194+
1195+ switch (direction)
1196+ {
1197+ case 0:
1198+ offsetX = 0;
1199+ offsetY = distance;
1200+ break;
1201+ case 1:
1202+ offsetX = distance;
1203+ offsetY = 0;
1204+ break;
1205+ case 2:
1206+ offsetX = 0;
1207+ offsetY = -distance;
1208+ break;
1209+ case 3:
1210+ offsetX = -distance;
1211+ offsetY = 0;
1212+ break;
1213+ case 4:
1214+ offsetX = ass->optionGetFlyinDirectionX ();
1215+ offsetY = ass->optionGetFlyinDirectionY ();
1216+ break;
1217+ }
1218+
1219+ forwardProgress = progressLinear ();
1220+ xTrans = -(forwardProgress * offsetX);
1221+ yTrans = -(forwardProgress * offsetY);
1222+ Point3d translation = Point3d (xTrans, yTrans, 0);
1223+
1224+ // animation movement
1225+ transform->translate (translation.x (), translation.y (), translation.z ());
1226+
1227+}
1228
1229=== added file 'plugins/simple-animations/src/pulse.cpp'
1230--- plugins/simple-animations/src/pulse.cpp 1970-01-01 00:00:00 +0000
1231+++ plugins/simple-animations/src/pulse.cpp 2012-08-27 11:08:22 +0000
1232@@ -0,0 +1,50 @@
1233+#include "animationsim.h"
1234+
1235+/* Keep the "principal" window at 100% opacity, only fade out
1236+ * the window that is "pulsing" away
1237+ */
1238+
1239+float
1240+PulseSingleAnim::getFadeProgress ()
1241+{
1242+ int num = MultiAnim <PulseSingleAnim, 2>::getCurrAnimNumber (mAWindow);
1243+
1244+ if (num == 1)
1245+ return 1 - getProgress ();
1246+ else
1247+ return 0.0f;
1248+};
1249+
1250+void
1251+PulseSingleAnim::applyTransform ()
1252+{
1253+ float scale = 1.0f + (1- getProgress ());
1254+
1255+ /* Add a bit of a "kick" for open, close,
1256+ * minimize, unminimize, etc anims */
1257+
1258+ switch (mCurWindowEvent)
1259+ {
1260+ case WindowEventOpen:
1261+ case WindowEventClose:
1262+ case WindowEventMinimize:
1263+ case WindowEventUnminimize:
1264+ scale -= 0.2f;
1265+ default:
1266+ break;
1267+ }
1268+
1269+ if (MultiAnim <PulseSingleAnim, 2>::getCurrAnimNumber (mAWindow) == 0)
1270+ if (scale > 1.0f)
1271+ scale = 1.0f;
1272+
1273+ GLMatrix *transform = &mTransform;
1274+
1275+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
1276+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f, 0.0f);
1277+
1278+ transform->scale (scale, scale, 1.0f);
1279+
1280+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
1281+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f), 0.0f);
1282+}
1283\ No newline at end of file
1284
1285=== added file 'plugins/simple-animations/src/rotatein.cpp'
1286--- plugins/simple-animations/src/rotatein.cpp 1970-01-01 00:00:00 +0000
1287+++ plugins/simple-animations/src/rotatein.cpp 2012-08-27 11:08:22 +0000
1288@@ -0,0 +1,210 @@
1289+/*
1290+ * Animation plugin for compiz/beryl
1291+ *
1292+ * animation.c
1293+ *
1294+ * Copyright : (C) 2006 Erkin Bahceci
1295+ * E-mail : erkinbah@gmail.com
1296+ *
1297+ * Based on Wobbly and Minimize plugins by
1298+ * : David Reveman
1299+ * E-mail : davidr@novell.com>
1300+ *
1301+ * Particle system added by : (C) 2006 Dennis Kasprzyk
1302+ * E-mail : onestone@beryl-project.org
1303+ *
1304+ * Beam-Up added by : Florencio Guimaraes
1305+ * E-mail : florencio@nexcorp.com.br
1306+ *
1307+ * Hexagon tessellator added by : Mike Slegeir
1308+ * E-mail : mikeslegeir@mail.utexas.edu>
1309+ *
1310+ * This program is free software; you can redistribute it and/or
1311+ * modify it under the terms of the GNU General Public License
1312+ * as published by the Free Software Foundation; either version 2
1313+ * of the License, or (at your option) any later version.
1314+ *
1315+ * This program is distributed in the hope that it will be useful,
1316+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1317+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1318+ * GNU General Public License for more details.
1319+ *
1320+ * You should have received a copy of the GNU General Public License
1321+ * along with this program; if not, write to the Free Software
1322+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1323+ */
1324+
1325+#include "animationsim.h"
1326+
1327+// ===================== Effect: RotateIn =========================
1328+
1329+void
1330+RotateInAnim::applyTransform ()
1331+{
1332+ ANIMSIM_SCREEN (screen);
1333+
1334+ GLMatrix *transform = &mTransform;
1335+ float xRot, yRot;
1336+ float angleX = 0, angleY = 0;
1337+ float originX = 0, originY = 0;
1338+ float forwardProgress;
1339+
1340+ int direction = ass->optionGetRotateinDirection ();
1341+
1342+ switch (direction)
1343+ {
1344+ case 1:
1345+ angleX = 0;
1346+ angleY = -ass->optionGetRotateinAngle ();
1347+ originX = WIN_X (mWindow);
1348+ originY = WIN_Y (mWindow) + WIN_H (mWindow);
1349+ break;
1350+ case 2:
1351+ angleX = ass->optionGetRotateinAngle ();
1352+ angleY = 0;
1353+ originX = WIN_X (mWindow);
1354+ originY = WIN_Y (mWindow);
1355+ break;
1356+ case 3:
1357+ angleX = 0;
1358+ angleY = ass->optionGetRotateinAngle ();
1359+ originX = WIN_X (mWindow);
1360+ originY = WIN_Y (mWindow);
1361+ break;
1362+ case 4:
1363+ angleX = -ass->optionGetRotateinAngle ();
1364+ angleY = 0;
1365+ originX = WIN_X (mWindow) + WIN_W (mWindow);
1366+ originY = WIN_Y (mWindow);
1367+ break;
1368+ }
1369+
1370+ forwardProgress = getProgress ();
1371+ xRot = (forwardProgress * angleX);
1372+ yRot = (forwardProgress * angleY);
1373+
1374+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
1375+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
1376+ 0.0f);
1377+
1378+ perspectiveDistortAndResetZ (*transform);
1379+
1380+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
1381+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
1382+ 0.0f);
1383+
1384+ // animation movement
1385+ transform->translate (originX, originY, 0.0f);
1386+
1387+ transform->rotate (yRot, 1.0f, 0.0f, 0.0f);
1388+ transform->rotate (xRot, 0.0f, 1.0f, 0.0f);
1389+
1390+ transform->translate (-originX, -originY, 0.0f);
1391+
1392+}
1393+
1394+void
1395+RotateInAnim::prePaintWindow ()
1396+{
1397+ float forwardProgress = getProgress ();
1398+ float xRot, yRot;
1399+ float angleX = 0, angleY = 0;
1400+ Bool xInvert = FALSE, yInvert = FALSE;
1401+ int currentCull, invertCull;
1402+
1403+ glGetIntegerv (GL_CULL_FACE_MODE, &currentCull);
1404+ invertCull = (currentCull == GL_BACK) ? GL_FRONT : GL_BACK;
1405+
1406+ ANIMSIM_SCREEN (screen);
1407+
1408+ int direction = ass->optionGetRotateinDirection ();
1409+
1410+ switch (direction)
1411+ {
1412+ case 1:
1413+ angleX = 0;
1414+ angleY = -ass->optionGetRotateinAngle ();
1415+ break;
1416+ case 2:
1417+ angleX = ass->optionGetRotateinAngle ();
1418+ angleY = 0;
1419+ break;
1420+ case 3:
1421+ angleX = 0;
1422+ angleY = ass->optionGetRotateinAngle ();
1423+ break;
1424+ case 4:
1425+ angleX = -ass->optionGetRotateinAngle ();
1426+ angleY = 0;
1427+ break;
1428+ }
1429+
1430+ /* FIXME: This could be fancy vectorial normal direction calculation */
1431+
1432+ xRot = fabs(fmodf(forwardProgress * angleX, 360.0f));
1433+ yRot = fabs(fmodf(forwardProgress * angleY, 360.0f));
1434+
1435+ if (xRot > 270.0f)
1436+ xInvert = TRUE;
1437+
1438+ if (yRot > 270.0f)
1439+ yInvert = TRUE;
1440+
1441+ if ((xInvert || yInvert) && !(xInvert && yInvert))
1442+ glCullFace (invertCull);
1443+}
1444+
1445+void
1446+RotateInAnim::postPaintWindow ()
1447+{
1448+ float forwardProgress = getProgress ();
1449+ float xRot, yRot;
1450+ float angleX = 0, angleY = 0;
1451+ Bool xInvert = FALSE, yInvert = FALSE;
1452+ int currentCull, invertCull;
1453+
1454+ glGetIntegerv (GL_CULL_FACE_MODE, &currentCull);
1455+ invertCull = (currentCull == GL_BACK) ? GL_FRONT : GL_BACK;
1456+
1457+ ANIMSIM_SCREEN (screen);
1458+
1459+ int direction = ass->optionGetRotateinDirection ();
1460+
1461+ switch (direction)
1462+ {
1463+ case 1:
1464+ angleX = 0;
1465+ angleY = -ass->optionGetRotateinAngle ();
1466+ break;
1467+ case 2:
1468+ angleX = ass->optionGetRotateinAngle ();
1469+ angleY = 0;
1470+ break;
1471+ case 3:
1472+ angleX = 0;
1473+ angleY = ass->optionGetRotateinAngle ();
1474+ break;
1475+ case 4:
1476+ angleX = -ass->optionGetRotateinAngle ();
1477+ angleY = 0;
1478+ break;
1479+ }
1480+
1481+ /* FIXME: This could be fancy vectorial normal direction calculation */
1482+
1483+ xRot = fabs(fmodf(forwardProgress * angleX, 360.0f));
1484+ yRot = fabs(fmodf(forwardProgress * angleY, 360.0f));
1485+
1486+ if (xRot > 270.0f)
1487+ xInvert = TRUE;
1488+
1489+ if (yRot > 270.0f)
1490+ yInvert = TRUE;
1491+
1492+ /* We have to assume that invertCull will be
1493+ * the actual inversion of our previous cull
1494+ */
1495+
1496+ if ((xInvert || yInvert) && !(xInvert && yInvert))
1497+ glCullFace (invertCull);
1498+}
1499
1500=== added file 'plugins/simple-animations/src/sheet.cpp'
1501--- plugins/simple-animations/src/sheet.cpp 1970-01-01 00:00:00 +0000
1502+++ plugins/simple-animations/src/sheet.cpp 2012-08-27 11:08:22 +0000
1503@@ -0,0 +1,275 @@
1504+/*
1505+ * Animation plugin for compiz/beryl
1506+ *
1507+ * animation.c
1508+ *
1509+ * Copyright : (C) 2006 Erkin Bahceci
1510+ * E-mail : erkinbah@gmail.com
1511+ *
1512+ * Based on Wobbly and Minimize plugins by
1513+ * : David Reveman
1514+ * E-mail : davidr@novell.com>
1515+ *
1516+ * Particle system added by : (C) 2006 Dennis Kasprzyk
1517+ * E-mail : onestone@beryl-project.org
1518+ *
1519+ * Beam-Up added by : Florencio Guimaraes
1520+ * E-mail : florencio@nexcorp.com.br
1521+ *
1522+ * Hexagon tessellator added by : Mike Slegeir
1523+ * E-mail : mikeslegeir@mail.utexas.edu>
1524+ *
1525+ * This program is free software; you can redistribute it and/or
1526+ * modify it under the terms of the GNU General Public License
1527+ * as published by the Free Software Foundation; either version 2
1528+ * of the License, or (at your option) any later version.
1529+ *
1530+ * This program is distributed in the hope that it will be useful,
1531+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1532+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1533+ * GNU General Public License for more details.
1534+ *
1535+ * You should have received a copy of the GNU General Public License
1536+ * along with this program; if not, write to the Free Software
1537+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1538+ */
1539+
1540+#include "animationsim.h"
1541+
1542+SheetAnim::SheetAnim (CompWindow *w,
1543+ WindowEvent curWindowEvent,
1544+ float duration,
1545+ const AnimEffect info,
1546+ const CompRect &minIcon) :
1547+ Animation::Animation (w, curWindowEvent, duration, info, minIcon),
1548+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, minIcon),
1549+ GridAnim::GridAnim (w, curWindowEvent, duration, info, minIcon)
1550+{
1551+ int maxWaves;
1552+ float waveAmpMin, waveAmpMax;
1553+ CompWindow *parent = 0;
1554+ CompRect icon = minIcon;
1555+
1556+ foreach (parent, screen->windows ())
1557+ {
1558+ if (parent->transientFor () == w->id () && parent->id () != w->id ())
1559+ break;
1560+ }
1561+
1562+ if (parent)
1563+ {
1564+ icon.setX (WIN_X (parent) + WIN_W (parent) / 2.0f);
1565+ icon.setY (WIN_Y (parent));
1566+ icon.setWidth (WIN_W (w));
1567+ }
1568+ else
1569+ {
1570+ icon.setX (screen->width () / 2.0f);
1571+ icon.setY (0.0f);;
1572+ icon.setWidth (WIN_W (w));
1573+ }
1574+
1575+ maxWaves = 0;
1576+ waveAmpMin = 0.0f;
1577+ waveAmpMax = 0.0f;
1578+
1579+ if (maxWaves == 0)
1580+ {
1581+ sheetsWaveCount = 0;
1582+ }
1583+ else
1584+ {
1585+ // Initialize waves
1586+
1587+ float distance = WIN_Y(w) + WIN_H(w) - icon.y ();
1588+
1589+ sheetsWaveCount =
1590+ 1 + (float)maxWaves *distance;
1591+
1592+ if (sheetsWaves.empty ())
1593+ {
1594+ sheetsWaves.resize (sheetsWaveCount);
1595+ }
1596+ // Compute wave parameters
1597+
1598+ int ampDirection = (RAND_FLOAT() < 0.5 ? 1 : -1);
1599+ float minHalfWidth = 0.22f;
1600+ float maxHalfWidth = 0.38f;
1601+
1602+ for (unsigned int i = 0; i < sheetsWaves.size (); i++)
1603+ {
1604+ sheetsWaves[i].amp =
1605+ ampDirection * (waveAmpMax - waveAmpMin) *
1606+ rand() / RAND_MAX + ampDirection * waveAmpMin;
1607+ sheetsWaves[i].halfWidth =
1608+ RAND_FLOAT() * (maxHalfWidth -
1609+ minHalfWidth) + minHalfWidth;
1610+
1611+ // avoid offset at top and bottom part by added waves
1612+ float availPos = 1 - 2 * sheetsWaves[i].halfWidth;
1613+ float posInAvailSegment = 0;
1614+
1615+ if (i > 0)
1616+ posInAvailSegment =
1617+ (availPos / sheetsWaveCount) * rand() / RAND_MAX;
1618+
1619+ sheetsWaves[i].pos =
1620+ (posInAvailSegment +
1621+ i * availPos / sheetsWaveCount +
1622+ sheetsWaves[i].halfWidth);
1623+
1624+ // switch wave direction
1625+ ampDirection *= -1;
1626+ }
1627+ }
1628+}
1629+
1630+void
1631+SheetAnim::updateBB (CompOutput &output)
1632+{
1633+ // TODO: Just consider the corner objects
1634+
1635+ CompositeScreen::get (screen)->damageScreen (); // XXX: *COUGH!!!!*
1636+}
1637+
1638+void
1639+SheetAnim::step ()
1640+{
1641+ GridModel *model = mModel;
1642+ CompRect &icon = mIcon;
1643+ CompWindow *parent = 0;
1644+
1645+ foreach (parent, screen->windows ())
1646+ {
1647+ if (parent->transientFor () == mWindow->id () && parent->id () != mWindow->id ())
1648+ break;
1649+ }
1650+
1651+ if (parent)
1652+ {
1653+ icon.setX (WIN_X (parent) + WIN_W (parent) / 2.0f);
1654+ icon.setY (WIN_Y (parent));
1655+ icon.setWidth (WIN_W (mWindow));
1656+ }
1657+ else
1658+ {
1659+ icon.setX (screen->width () / 2.0f);
1660+ icon.setY (0.0f);;
1661+ icon.setWidth (WIN_W (mWindow));
1662+ }
1663+
1664+ float forwardProgress = progressLinear ();
1665+
1666+ if (sheetsWaveCount > 0 && sheetsWaves.empty ())
1667+ return;
1668+
1669+ float iconCloseEndY;
1670+ float iconFarEndY;
1671+ float winFarEndY;
1672+ float winVisibleCloseEndY;
1673+ float winw = WIN_W(mWindow);
1674+ float winh = WIN_H(mWindow);
1675+
1676+
1677+ iconFarEndY = icon.y ();
1678+ iconCloseEndY = icon.y () + icon.height ();
1679+ winFarEndY = WIN_Y(mWindow) + winh;
1680+ winVisibleCloseEndY = WIN_Y(mWindow);
1681+ if (winVisibleCloseEndY < iconCloseEndY)
1682+ winVisibleCloseEndY = iconCloseEndY;
1683+
1684+
1685+ float preShapePhaseEnd = 0.22f;
1686+ float preShapeProgress = 0;
1687+ float postStretchProgress = 0;
1688+ float stretchProgress = 0;
1689+ float stretchPhaseEnd =
1690+ preShapePhaseEnd + (1 - preShapePhaseEnd) *
1691+ (iconCloseEndY -
1692+ winVisibleCloseEndY) / ((iconCloseEndY - winFarEndY) +
1693+ (iconCloseEndY - winVisibleCloseEndY));
1694+ if (stretchPhaseEnd < preShapePhaseEnd + 0.1)
1695+ stretchPhaseEnd = preShapePhaseEnd + 0.1;
1696+
1697+ if (forwardProgress < preShapePhaseEnd)
1698+ {
1699+ preShapeProgress = forwardProgress / preShapePhaseEnd;
1700+
1701+ // Slow down "shaping" toward the end
1702+ preShapeProgress = 1 - progressDecelerate (1 - preShapeProgress);
1703+ }
1704+
1705+ if (forwardProgress < preShapePhaseEnd)
1706+ {
1707+ stretchProgress = forwardProgress / stretchPhaseEnd;
1708+ }
1709+ else
1710+ {
1711+ if (forwardProgress < stretchPhaseEnd)
1712+ {
1713+ stretchProgress = forwardProgress / stretchPhaseEnd;
1714+ }
1715+ else
1716+ {
1717+ postStretchProgress =
1718+ (forwardProgress - stretchPhaseEnd) / (1 - stretchPhaseEnd);
1719+ }
1720+ }
1721+
1722+ GridModel::GridObject *object = mModel->objects ();
1723+ unsigned int i;
1724+ for (i = 0; i < mModel->numObjects (); i++, object++)
1725+ {
1726+ float origx = mWindow->x () + (winw * object->gridPosition ().x () -
1727+ mWindow->output ().left) * model->scale ().x ();
1728+ float origy = mWindow->y () + (winh * object->gridPosition ().y () -
1729+ mWindow->output ().top) * model->scale ().y ();
1730+ float icony = icon.y () + icon.height ();
1731+
1732+ float stretchedPos;
1733+ Point3d &objPos = object->position ();
1734+ stretchedPos =
1735+ object->gridPosition ().y () * origy +
1736+ (1 - object->gridPosition ().y ()) * icony;
1737+
1738+ // Compute current y position
1739+ if (forwardProgress < preShapePhaseEnd)
1740+ {
1741+ objPos.setY ((1 - stretchProgress) * origy +
1742+ stretchProgress * stretchedPos);
1743+ }
1744+ else
1745+ {
1746+ if (forwardProgress < stretchPhaseEnd)
1747+ {
1748+ objPos.setY ((1 - stretchProgress) * origy +
1749+ stretchProgress * stretchedPos);
1750+ }
1751+ else
1752+ {
1753+ objPos.setY ((1 - postStretchProgress) *
1754+ stretchedPos +
1755+ postStretchProgress *
1756+ (stretchedPos + (iconCloseEndY - winFarEndY)));
1757+ }
1758+ }
1759+
1760+ // Compute "target shape" x position
1761+ float yProgress = (iconCloseEndY - object->position ().y () ) / (iconCloseEndY - winFarEndY);
1762+
1763+ float targetx = yProgress * (origx - icon.x ())
1764+ + icon.x () + icon.width () * (object->gridPosition ().x () - 0.5);
1765+
1766+ // Compute current x position
1767+ if (forwardProgress < preShapePhaseEnd)
1768+ objPos.setX ((1 - preShapeProgress) * origx + preShapeProgress * targetx);
1769+ else
1770+ objPos.setX (targetx);
1771+
1772+ if (object->position ().y () < iconFarEndY)
1773+ objPos.setY (iconFarEndY);
1774+
1775+ // No need to set object->position.z to 0, since they won't be used
1776+ // due to modelAnimIs3D being FALSE for magic lamp.
1777+ }
1778+}

Subscribers

People subscribed via source and target branches