diff options
author | Sam Spilsbury <smspillaz@gmail.com> | 2010-08-21 04:28:20 +0800 |
---|---|---|
committer | Sam Spilsbury <smspillaz@gmail.com> | 2010-08-21 04:28:20 +0800 |
commit | 4c9f396838432dea77796ee4c9c6617168401b68 (patch) | |
tree | 8141c1b7b7c60e9b8b0c0f07ae3f4f3cbfa9208b | |
parent | 26d7683f8e72210cdb55ced98440ab1ddb475fc9 (diff) | |
download | simple-animations-4c9f396838432dea77796ee4c9c6617168401b68.tar.gz simple-animations-4c9f396838432dea77796ee4c9c6617168401b68.tar.bz2 |
Add new animation "fan"
-rw-r--r-- | animationsim.xml.in | 15 | ||||
-rw-r--r-- | src/animationsim.cpp | 6 | ||||
-rw-r--r-- | src/animationsim.h | 46 | ||||
-rw-r--r-- | src/fan.cpp | 51 |
4 files changed, 114 insertions, 4 deletions
diff --git a/animationsim.xml.in b/animationsim.xml.in index 3ab745d..358b893 100644 --- a/animationsim.xml.in +++ b/animationsim.xml.in @@ -148,6 +148,17 @@ </option> </subgroup> <subgroup> + <_short>Fan</_short> + <option name="fan_angle" type="float"> + <_short>Fan Angle</_short> + <_long>Angle of windows away from the main window</_long> + <default>35</default> + <min>0</min> + <max>90</max> + <precision>0.1</precision> + </option> + </subgroup> + <subgroup> <_short>Expand Piecewise</_short> <option name="expandpw_horiz_first" type="bool"> <_short>First expand horizontally</_short> @@ -214,6 +225,10 @@ <value>animationsim:Pulse</value> <_name>Pulse</_name> </restriction> + <restriction> + <value>animationsim:Fan</value> + <_name>Fan</_name> + </restriction> </extension> </plugin> diff --git a/src/animationsim.cpp b/src/animationsim.cpp index d9c557b..2aa6178 100644 --- a/src/animationsim.cpp +++ b/src/animationsim.cpp @@ -51,6 +51,7 @@ AnimEffect AnimEffectExpandPW; AnimEffect AnimEffectBounce; AnimEffect AnimEffectSheet; AnimEffect AnimEffectPulse; +AnimEffect AnimEffectFan; void AnimSimScreen::initAnimationList () @@ -86,11 +87,14 @@ AnimSimScreen::initAnimationList () new AnimEffectInfo ("animationsim:Sheet", true, true, true, false, false, &createAnimation<SheetAnim>); - animEffects[i++] = AnimEffectPulse = new AnimEffectInfo ("animationsim:Pulse", true, true, true, false, false, &createAnimation<PulseAnim>); + animEffects[i++] = AnimEffectFan = + new AnimEffectInfo ("animationsim:Fan", + true, true, true, false, false, + &createAnimation<FanAnim>); animSimExtPluginInfo.effectOptions = &getOptions (); diff --git a/src/animationsim.h b/src/animationsim.h index 862aeb1..6f0044e 100644 --- a/src/animationsim.h +++ b/src/animationsim.h @@ -15,9 +15,10 @@ extern AnimEffect AnimEffectRotateIn; extern AnimEffect AnimEffectSheet; extern AnimEffect AnimEffectExpand; extern AnimEffect AnimEffectExpandPW; +extern AnimEffect AnimEffectFan; -// TODO Update this for each added animation effect! (total: 10) -#define NUM_EFFECTS 7 +// TODO Update this for each added animation effect! (total: 8) +#define NUM_EFFECTS 8 // This must have the value of the first "effect setting" above // in AnimAddonScreenOptions @@ -345,7 +346,46 @@ class PulseAnim : public MultiAnim <PulseSingleAnim, 2> MultiAnim <PulseSingleAnim, 2>::MultiAnim (w, curWindowEvent, duration, info, icon) {} -}; +}; + +class FanSingleAnim : public TransformAnim, + virtual public FadeAnim, + virtual public BaseSimAnim +{ + public: + + FanSingleAnim (CompWindow *w, + WindowEvent curWindowEvent, + float duration, + const AnimEffect info, + const CompRect &icon) : + Animation::Animation (w, curWindowEvent, duration, info, icon), + FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon), + BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon), + TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {} + + void step () { TransformAnim::step (); } + void updateBB (CompOutput &output) { TransformAnim::updateBB (output); } + bool updateBBUsed () { return true; } + + float getProgress () { return progressLinear (); } + float getFadeProgress (); + + void applyTransform (); +}; + +class FanAnim : public MultiAnim <FanSingleAnim, 6> +{ + public: + + FanAnim (CompWindow *w, + WindowEvent curWindowEvent, + float duration, + const AnimEffect info, + const CompRect &icon) : + MultiAnim <FanSingleAnim, 6>::MultiAnim + (w, curWindowEvent, duration, info, icon) {} +}; class AnimSimPluginVTable: public CompPlugin::VTableForScreenAndWindow <AnimSimScreen, AnimSimWindow> diff --git a/src/fan.cpp b/src/fan.cpp new file mode 100644 index 0000000..cdb86b3 --- /dev/null +++ b/src/fan.cpp @@ -0,0 +1,51 @@ +#include "animationsim.h" + +float +FanSingleAnim::getFadeProgress () +{ + return getProgress (); +}; + +void +FanSingleAnim::applyTransform () +{ + /* Starting angle is as a percentage of whichever fan number we are + * closest to the center + */ + + ANIMSIM_SCREEN (screen); + + int num = MultiAnim <FanSingleAnim, 6>::getCurrAnimNumber (mAWindow); + + if (num > 2) + num += 1; + + float div = (ass->optionGetFanAngle () * 2) / 6; + float startAng = -(ass->optionGetFanAngle ()) + (div * num); + float currAng = getProgress () * startAng; + float offset = (1 - getProgress ()) * (WIN_H (mWindow) / 2); + + if (num > 3) + num += 1; + + if (num > 3) + { + mTransform.translate (WIN_X (mWindow) + WIN_W (mWindow) - offset, + WIN_Y (mWindow) + WIN_H (mWindow), + 0.0f); + mTransform.rotate (currAng, 0.0f, 0.0f, 1.0f); + mTransform.translate (-(WIN_X (mWindow) + WIN_W (mWindow) - offset), + -(WIN_Y (mWindow) + WIN_H (mWindow)), + 0.0f); + } + else + { + mTransform.translate (WIN_X (mWindow) + offset, + WIN_Y (mWindow) + WIN_H (mWindow), + 0.0f); + mTransform.rotate (currAng, 0.0f, 0.0f, 1.0f); + mTransform.translate (-(WIN_X (mWindow) + offset), + -(WIN_Y (mWindow) + WIN_H (mWindow)), + 0.0f); + } +} |