summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animationsim.cpp560
-rw-r--r--src/animationsim.h315
-rw-r--r--src/bounce.cpp76
-rw-r--r--src/expand-piecewise.cpp90
-rw-r--r--src/expand.cpp71
-rw-r--r--src/flyin.cpp87
-rw-r--r--src/rotatein.cpp228
-rw-r--r--src/sheet.cpp277
8 files changed, 1704 insertions, 0 deletions
diff --git a/src/animationsim.cpp b/src/animationsim.cpp
new file mode 100644
index 0000000..c35f9a7
--- /dev/null
+++ b/src/animationsim.cpp
@@ -0,0 +1,560 @@
+/**
+ * Example Animation extension plugin for compiz
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ **/
+
+#include "animationsim.h"
+
+COMPIZ_PLUGIN_20090315 (animationsim, AnimSimPluginVTable);
+
+AnimEffect animEffects[NUM_EFFECTS];
+
+ExtensionPluginAnimSim animSimExtPluginInfo (CompString ("animationsim"),
+ NUM_EFFECTS, animEffects, NULL,
+ NUM_NONEFFECT_OPTIONS);
+
+ExtensionPluginInfo *
+BaseSimAnim::getExtensionPluginInfo ()
+{
+ return &animSimExtPluginInfo;
+}
+
+BaseSimAnim::BaseSimAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ mCScreen (CompositeScreen::get (::screen)),
+ mGScreen (GLScreen::get (::screen))
+{
+}
+
+AnimEffect AnimEffectFlyIn;
+AnimEffect AnimEffectRotateIn;
+AnimEffect AnimEffectExpand;
+AnimEffect AnimEffectExpandPW;
+AnimEffect AnimEffectBounce;
+AnimEffect AnimEffectSheet;
+
+void
+AnimSimScreen::initAnimationList ()
+{
+ int i = 0;
+
+ animEffects[i++] = AnimEffectFlyIn =
+ new AnimEffectInfo ("animationsim:Fly In",
+ true, true, true, false, false,
+ &createAnimation<FlyInAnim>);
+
+ animEffects[i++] = AnimEffectRotateIn =
+ new AnimEffectInfo ("animationsim:Rotate In",
+ true, true, true, false, false,
+ &createAnimation<RotateInAnim>);
+
+ animEffects[i++] = AnimEffectExpand =
+ new AnimEffectInfo ("animationsim:Expand",
+ true, true, true, false, false,
+ &createAnimation<ExpandAnim>);
+
+ animEffects[i++] = AnimEffectExpandPW =
+ new AnimEffectInfo ("animationsim:Expand Piecewise",
+ true, true, true, false, false,
+ &createAnimation<ExpandPWAnim>);
+
+ animEffects[i++] = AnimEffectBounce =
+ new AnimEffectInfo ("animationsim:Bounce",
+ true, true, true, false, false,
+ &createAnimation<BounceAnim>);
+
+ animEffects[i++] = AnimEffectSheet =
+ new AnimEffectInfo ("animationsim:Sheet",
+ true, true, true, false, false,
+ &createAnimation<SheetAnim>);
+
+ animSimExtPluginInfo.effectOptions = &getOptions ();
+
+ AnimScreen *as = AnimScreen::get (::screen);
+
+ // Extends animation plugin with this set of animation effects.
+ as->addExtension (&animSimExtPluginInfo);
+}
+
+AnimSimScreen::AnimSimScreen (CompScreen *s) :
+ //cScreen (CompositeScreen::get (s)),
+ //gScreen (GLScreen::get (s)),
+ //aScreen (as),
+ PluginClassHandler <AnimSimScreen, CompScreen> (s),
+ mOutput (s->fullscreenOutput ())
+{
+ initAnimationList ();
+}
+
+AnimSimScreen::~AnimSimScreen ()
+{
+ AnimScreen *as = AnimScreen::get (::screen);
+
+ as->removeExtension (&animSimExtPluginInfo);
+
+ for (int i = 0; i < NUM_EFFECTS; i++)
+ {
+ delete animEffects[i];
+ animEffects[i] = NULL;
+ }
+}
+
+AnimSimWindow::AnimSimWindow (CompWindow *w) :
+ PluginClassHandler<AnimSimWindow, CompWindow> (w),
+ mWindow (w),
+ aWindow (AnimWindow::get (w))
+{
+}
+
+AnimSimWindow::~AnimSimWindow ()
+{
+ Animation *curAnim = aWindow->curAnimation ();
+
+ if (!curAnim)
+ return;
+
+ // We need to interrupt and clean up the animation currently being played
+ // by animationsim for this window (if any)
+ if (curAnim->remainingTime () > 0 &&
+ curAnim->getExtensionPluginInfo ()->name ==
+ CompString ("animationsim"))
+ {
+ aWindow->postAnimationCleanUp ();
+ }
+}
+
+bool
+AnimSimPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) |
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) |
+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) |
+ !CompPlugin::checkPluginABI ("animation", ANIMATION_ABI))
+ return false;
+
+ return true;
+}
+#if 0
+
+
+int animDisplayPrivateIndex;
+CompMetadata animMetadata;
+
+AnimEffect animEffects[NUM_EFFECTS];
+
+ExtensionPluginInfo animExtensionPluginInfo = {
+ .nEffects = NUM_EFFECTS,
+ .effects = animEffects,
+
+ .nEffectOptions = ANIMSIM_SCREEN_OPTION_NUM,
+};
+
+OPTION_GETTERS (GET_ANIMSIM_DISPLAY (w->screen->display)->animBaseFunc,
+ &animExtensionPluginInfo, NUM_NONEFFECT_OPTIONS)
+
+static Bool
+animSetScreenOptions (CompPlugin *plugin,
+ CompScreen * screen,
+ const char *name,
+ CompOptionValue * value)
+{
+ CompOption *o;
+ int index;
+
+ ANIMSIM_SCREEN (screen);
+
+ o = compFindOption (as->opt, NUM_OPTIONS (as), name, &index);
+ if (!o)
+ return FALSE;
+
+ switch (index)
+ {
+ default:
+ return compSetScreenOption (screen, o, value);
+ break;
+ }
+
+ return FALSE;
+}
+
+static const CompMetadataOptionInfo animEgScreenOptionInfo[] = {
+ { "bounce_max_size", "float", "<min>1.0</min>", 0, 0 },
+ { "bounce_min_size", "float", "<max>1.0</max>", 0, 0 },
+ { "bounce_number", "int", 0, 0, 0 },
+ { "bounce_fade", "bool", 0, 0, 0 },
+ { "flyin_direction", "int", 0, 0, 0 },
+ { "flyin_direction_x", "float", 0, 0, 0 },
+ { "flyin_direction_y", "float", 0, 0, 0 },
+ { "flyin_fade", "bool", 0, 0, 0 },
+ { "flyin_distance", "float", 0, 0, 0 },
+ { "rotatein_angle", "float", 0, 0, 0 },
+ { "rotatein_direction", "int", 0, 0, 0 },
+ { "sheet_start_percent", "float", 0, 0, 0 },
+ { "expandpw_horiz_first", "bool", 0, 0, 0 },
+ { "expandpw_initial_horiz", "int", 0, 0, 0 },
+ { "expandpw_initial_vert", "int", 0, 0, 0 },
+ { "expandpw_delay", "float", 0, 0, 0 }
+};
+
+static CompOption *
+animGetScreenOptions (CompPlugin *plugin, CompScreen * screen, int *count)
+{
+ ANIMSIM_SCREEN (screen);
+
+ *count = NUM_OPTIONS (as);
+ return as->opt;
+}
+
+/*
+// For effects with custom polygon step functions:
+AnimExtEffectProperties fxAirplaneExtraProp = {
+ .animStepPolygonFunc = fxAirplaneLinearAnimStepPolygon};
+*/
+
+AnimEffect AnimEffectFlyIn = &(AnimEffectInfo) {};
+AnimEffect AnimEffectBounce = &(AnimEffectInfo) {};
+AnimEffect AnimEffectRotateIn = &(AnimEffectInfo) {};
+AnimEffect AnimEffectSheets = &(AnimEffectInfo) {};
+AnimEffect AnimEffectExpand = &(AnimEffectInfo) {};
+AnimEffect AnimEffectExpandPW = &(AnimEffectInfo) {};
+
+static void
+initEffectProperties (AnimSimDisplay *ad)
+{
+ AnimBaseFunctions *baseFunc = ad->animBaseFunc;
+
+ memcpy ((AnimEffectInfo *)AnimEffectFlyIn, (&(AnimEffectInfo)
+ {"animationsim:Fly In",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.updateWindowAttribFunc = fxFlyinUpdateWindowAttrib,
+ .animStepFunc = fxFlyinAnimStep,
+ .initFunc = fxFlyinInit,
+ .letOthersDrawGeomsFunc = baseFunc->returnTrue,
+ .updateWinTransformFunc = fxFlyinUpdateWindowTransform,
+ .updateBBFunc = baseFunc->compTransformUpdateBB}}),
+ sizeof (AnimEffectInfo));
+
+ memcpy ((AnimEffectInfo *)AnimEffectBounce, (&(AnimEffectInfo)
+ {"animationsim:Bounce",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.updateWindowAttribFunc = fxBounceUpdateWindowAttrib,
+ .animStepFunc = fxBounceAnimStep,
+ .initFunc = fxBounceInit,
+ .letOthersDrawGeomsFunc = baseFunc->returnTrue,
+ .updateWinTransformFunc = fxBounceUpdateWindowTransform,
+ .updateBBFunc = baseFunc->compTransformUpdateBB}}),
+ sizeof (AnimEffectInfo));
+ memcpy ((AnimEffectInfo *)AnimEffectRotateIn, (&(AnimEffectInfo)
+ {"animationsim:Rotate In",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.updateWindowAttribFunc = fxRotateinUpdateWindowAttrib,
+ .prePaintWindowFunc = fxRotateinPrePaintWindow,
+ .postPaintWindowFunc = fxRotateinPostPaintWindow,
+ .animStepFunc = fxRotateinAnimStep,
+ .initFunc = fxRotateinInit,
+ .letOthersDrawGeomsFunc = baseFunc->returnTrue,
+ .updateWinTransformFunc = fxRotateinUpdateWindowTransform,
+ .updateBBFunc = baseFunc->compTransformUpdateBB,
+ .zoomToIconFunc = fxRotateinZoomToIcon}}),
+ sizeof (AnimEffectInfo));
+ memcpy ((AnimEffectInfo *)AnimEffectSheets, (&(AnimEffectInfo)
+ {"animationsim:Sheet",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.animStepFunc = fxSheetsModelStep,
+ .initFunc = fxSheetsInit,
+ .initGridFunc = fxSheetsInitGrid,
+ .updateBBFunc = baseFunc->modelUpdateBB,
+ .useQTexCoord = TRUE}}),
+ sizeof (AnimEffectInfo));
+ memcpy ((AnimEffectInfo *)AnimEffectExpand, (&(AnimEffectInfo)
+ {"animationsim:Expand",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.updateWindowAttribFunc = fxExpandUpdateWindowAttrib,
+ .animStepFunc = fxExpandAnimStep,
+ .initFunc = fxExpandInit,
+ .letOthersDrawGeomsFunc = baseFunc->returnTrue,
+ .updateWinTransformFunc = fxExpandUpdateWindowTransform,
+ .updateBBFunc = baseFunc->compTransformUpdateBB}}),
+ sizeof (AnimEffectInfo));
+ memcpy ((AnimEffectInfo *)AnimEffectExpandPW, (&(AnimEffectInfo)
+ {"animationsim:Expand Piecewise",
+ {TRUE, TRUE, TRUE, FALSE, FALSE},
+ {.updateWindowAttribFunc = fxExpandPWUpdateWindowAttrib,
+ .animStepFunc = fxExpandPWAnimStep,
+ .initFunc = fxExpandPWInit,
+ .letOthersDrawGeomsFunc = baseFunc->returnTrue,
+ .updateWinTransformFunc = fxExpandPWUpdateWindowTransform,
+ .updateBBFunc = baseFunc->compTransformUpdateBB}}),
+ sizeof (AnimEffectInfo));
+
+ AnimEffect animEffectsTmp[NUM_EFFECTS] =
+ {
+ AnimEffectFlyIn,
+ AnimEffectBounce,
+ AnimEffectRotateIn,
+ AnimEffectSheets,
+ AnimEffectExpand,
+ AnimEffectExpandPW
+ };
+ memcpy (animEffects,
+ animEffectsTmp,
+ NUM_EFFECTS * sizeof (AnimEffect));
+}
+
+static Bool animInitDisplay (CompPlugin * p, CompDisplay * d)
+{
+ AnimSimDisplay *ad;
+ int animBaseFunctionsIndex;
+
+ if (!checkPluginABI ("core", CORE_ABIVERSION) ||
+ !checkPluginABI ("animation", ANIMATION_ABIVERSION))
+ {
+ compLogMessage ("animationsim", CompLogLevelError, "ABI Versions between CORE, ANIMATION and ANIMATIONSIM are not in sync. Please recompile animationsim\n");
+ return FALSE;
+ }
+
+ if (!getPluginDisplayIndex (d, "animation", &animBaseFunctionsIndex))
+ {
+ return FALSE;
+ }
+
+ ad = calloc (1, sizeof (AnimSimDisplay));
+ if (!ad)
+ return FALSE;
+
+ ad->screenPrivateIndex = allocateScreenPrivateIndex (d);
+ if (ad->screenPrivateIndex < 0)
+ {
+ free (ad);
+ return FALSE;
+ }
+
+ ad->animBaseFunc = d->base.privates[animBaseFunctionsIndex].ptr;
+
+ initEffectProperties (ad);
+
+ d->base.privates[animDisplayPrivateIndex].ptr = ad;
+
+ return TRUE;
+}
+
+static void animFiniDisplay (CompPlugin * p, CompDisplay * d)
+{
+ ANIMSIM_DISPLAY (d);
+
+ freeScreenPrivateIndex (d, ad->screenPrivateIndex);
+
+ free (ad);
+}
+
+static Bool animInitScreen (CompPlugin * p, CompScreen * s)
+{
+ AnimSimScreen *as;
+
+ ANIMSIM_DISPLAY (s->display);
+
+ as = calloc (1, sizeof (AnimSimScreen));
+ if (!as)
+ return FALSE;
+
+ if (!compInitScreenOptionsFromMetadata (s,
+ &animMetadata,
+ animEgScreenOptionInfo,
+ as->opt,
+ ANIMSIM_SCREEN_OPTION_NUM))
+ {
+ free (as);
+ fprintf(stderr, "unable metadata\n");
+ return FALSE;
+ }
+
+ as->windowPrivateIndex = allocateWindowPrivateIndex (s);
+ if (as->windowPrivateIndex < 0)
+ {
+ compFiniScreenOptions (s, as->opt, ANIMSIM_SCREEN_OPTION_NUM);
+ free (as);
+ return FALSE;
+ }
+
+ as->output = &s->fullscreenOutput;
+
+ animExtensionPluginInfo.effectOptions = &as->opt[NUM_NONEFFECT_OPTIONS];
+
+ ad->animBaseFunc->addExtension (s, &animExtensionPluginInfo);
+
+ s->base.privates[ad->screenPrivateIndex].ptr = as;
+
+ return TRUE;
+}
+
+static void animFiniScreen (CompPlugin * p, CompScreen * s)
+{
+ ANIMSIM_SCREEN (s);
+ ANIMSIM_DISPLAY (s->display);
+
+ ad->animBaseFunc->removeExtension (s, &animExtensionPluginInfo);
+
+ freeWindowPrivateIndex (s, as->windowPrivateIndex);
+
+ compFiniScreenOptions (s, as->opt, ANIMSIM_SCREEN_OPTION_NUM);
+
+ free (as);
+}
+
+static Bool animInitWindow (CompPlugin * p, CompWindow * w)
+{
+ CompScreen *s = w->screen;
+ AnimSimWindow *aw;
+
+ ANIMSIM_DISPLAY (s->display);
+ ANIMSIM_SCREEN (s);
+
+ aw = calloc (1, sizeof (AnimSimWindow));
+ if (!aw)
+ return FALSE;
+
+ w->base.privates[as->windowPrivateIndex].ptr = aw;
+
+ aw->com = ad->animBaseFunc->getAnimWindowCommon (w);
+
+ return TRUE;
+}
+
+static void animFiniWindow (CompPlugin * p, CompWindow * w)
+{
+ ANIMSIM_WINDOW (w);
+
+ free (aw);
+}
+
+static CompBool
+animInitObject (CompPlugin *p,
+ CompObject *o)
+{
+ static InitPluginObjectProc dispTab[] = {
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) animInitDisplay,
+ (InitPluginObjectProc) animInitScreen,
+ (InitPluginObjectProc) animInitWindow
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+}
+
+static void
+animFiniObject (CompPlugin *p,
+ CompObject *o)
+{
+ static FiniPluginObjectProc dispTab[] = {
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) animFiniDisplay,
+ (FiniPluginObjectProc) animFiniScreen,
+ (FiniPluginObjectProc) animFiniWindow
+ };
+
+ DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+}
+
+static CompOption *
+animGetObjectOptions (CompPlugin *plugin,
+ CompObject *object,
+ int *count)
+{
+ static GetPluginObjectOptionsProc dispTab[] = {
+ (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
+ (GetPluginObjectOptionsProc) 0, /* GetDisplayOptions */
+ (GetPluginObjectOptionsProc) animGetScreenOptions
+ };
+
+ RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
+ (void *) (*count = 0), (plugin, object, count));
+}
+
+static CompBool
+animSetObjectOption (CompPlugin *plugin,
+ CompObject *object,
+ const char *name,
+ CompOptionValue *value)
+{
+ static SetPluginObjectOptionProc dispTab[] = {
+ (SetPluginObjectOptionProc) 0, /* SetCoreOption */
+ (SetPluginObjectOptionProc) 0, /* SetDisplayOption */
+ (SetPluginObjectOptionProc) animSetScreenOptions
+ };
+
+ RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), FALSE,
+ (plugin, object, name, value));
+}
+
+static Bool animInit (CompPlugin * p)
+{
+ if (!compInitPluginMetadataFromInfo (&animMetadata,
+ p->vTable->name,
+ 0, 0,
+ animEgScreenOptionInfo,
+ ANIMSIM_SCREEN_OPTION_NUM))
+ {
+ fprintf(stderr, "init no metadata\n");
+ return FALSE;
+ }
+
+ animDisplayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (animDisplayPrivateIndex < 0)
+ {
+ compFiniMetadata (&animMetadata);
+ return FALSE;
+ }
+
+ compAddMetadataFromFile (&animMetadata, p->vTable->name);
+
+ return TRUE;
+}
+
+static void animFini (CompPlugin * p)
+{
+ freeDisplayPrivateIndex (animDisplayPrivateIndex);
+ compFiniMetadata (&animMetadata);
+}
+
+static CompMetadata *
+animGetMetadata (CompPlugin *plugin)
+{
+ return &animMetadata;
+}
+
+CompPluginVTable animVTable = {
+ "animationsim",
+ animGetMetadata,
+ animInit,
+ animFini,
+ animInitObject,
+ animFiniObject,
+ animGetObjectOptions,
+ animSetObjectOption,
+};
+
+CompPluginVTable*
+getCompPluginInfo20070830 (void)
+{
+ return &animVTable;
+}
+
+#endif
diff --git a/src/animationsim.h b/src/animationsim.h
new file mode 100644
index 0000000..b4f57cf
--- /dev/null
+++ b/src/animationsim.h
@@ -0,0 +1,315 @@
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <core/core.h>
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+#include <animation/animation.h>
+
+#include "animationsim_options.h"
+
+extern AnimEffect AnimEffectFlyIn;
+extern AnimEffect AnimEffectBounce;
+extern AnimEffect AnimEffectRotateIn;
+extern AnimEffect AnimEffectSheet;
+extern AnimEffect AnimEffectExpand;
+extern AnimEffect AnimEffectExpandPW;
+
+// TODO Update this for each added animation effect! (total: 10)
+#define NUM_EFFECTS 6
+
+// This must have the value of the first "effect setting" above
+// in AnimAddonScreenOptions
+#define NUM_NONEFFECT_OPTIONS AnimationsimOptions::FlyinDirection
+
+#define WIN_X(w) ((w)->x () - (w)->input ().left)
+#define WIN_Y(w) ((w)->y () - (w)->input ().top)
+#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
+#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
+
+class ExtensionPluginAnimSim : public ExtensionPluginInfo
+{
+public:
+ ExtensionPluginAnimSim (const CompString &name,
+ unsigned int nEffects,
+ AnimEffect *effects,
+ CompOption::Vector *effectOptions,
+ unsigned int firstEffectOptionIndex) :
+ ExtensionPluginInfo (name, nEffects, effects, effectOptions,
+ firstEffectOptionIndex) {}
+ ~ExtensionPluginAnimSim () {}
+
+ const CompOutput *output () { return mOutput; }
+
+private:
+ const CompOutput *mOutput;
+};
+
+/// Base class for all polygon- and particle-based animations
+class BaseSimAnim :
+virtual public Animation
+{
+public:
+ BaseSimAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon);
+ ~BaseSimAnim () {}
+
+protected:
+ /// Gets info about the extension plugin that implements this animation.
+ ExtensionPluginInfo *getExtensionPluginInfo ();
+
+ CompositeScreen *mCScreen;
+ GLScreen *mGScreen;
+
+};
+
+
+class AnimSimScreen :
+ public PluginClassHandler <AnimSimScreen, CompScreen>,
+ public AnimationsimOptions
+{
+
+public:
+ AnimSimScreen (CompScreen *);
+ ~AnimSimScreen ();
+
+protected:
+ void initAnimationList ();
+
+ CompOutput &mOutput;
+};
+
+class AnimSimWindow :
+ public PluginClassHandler<AnimSimWindow, CompWindow>
+{
+public:
+ AnimSimWindow (CompWindow *);
+ ~AnimSimWindow ();
+
+protected:
+ CompWindow *mWindow; ///< Window being animated.
+ AnimWindow *aWindow;
+};
+
+/*
+typedef struct _WaveParam
+{
+ float halfWidth;
+ float amp;
+ float pos;
+} WaveParam;
+*/
+
+#define ANIMSIM_SCREEN(s) \
+ AnimSimScreen *ass = AnimSimScreen::get (s);
+
+#define ANIMSIM_WINDOW(w) \
+ AnimSimWindow *asw = AnimSimWindow::get (w);
+
+class FlyInAnim : public FadeAnim,
+ virtual public BaseSimAnim,
+ virtual public TransformAnim
+{
+ public:
+
+ FlyInAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon) {}
+
+ protected:
+ void step () { TransformAnim::step (); }
+ bool updateBBUsed () { return true; }
+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
+ void applyTransform ();
+
+ float getFadeProgress ()
+ {
+ return progressDecelerate (progressLinear ());
+ }
+};
+
+class RotateInAnim: public TransformAnim,
+ virtual public BaseSimAnim
+{
+ public:
+
+ RotateInAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
+
+ protected:
+
+ void step () { TransformAnim::step (); }
+ bool updateBBUsed () { return true; }
+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
+ void applyTransform ();
+ void prePaintWindow ();
+ void postPaintWindow ();
+
+ inline float getProgress ()
+ {
+ return progressDecelerate (progressLinear ());
+ }
+};
+
+class ExpandAnim: public TransformAnim,
+ virtual public BaseSimAnim
+{
+ public:
+
+ ExpandAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon) {}
+
+ protected:
+
+ inline float getProgress ()
+ {
+ return progressDecelerate (progressLinear ());
+ }
+
+ void applyTransform ();
+ bool updateBBUsed () { return true; }
+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
+};
+
+class ExpandPWAnim: public TransformAnim,
+ virtual public BaseSimAnim
+{
+ public:
+
+ ExpandPWAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon)
+ {
+ }
+
+ protected:
+
+ inline float getProgress ()
+ {
+ return progressDecelerate (progressLinear ());
+ }
+
+ void applyTransform ();
+ bool updateBBUsed () { return true; }
+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
+};
+
+class BounceAnim: public FadeAnim,
+ virtual public TransformAnim,
+ virtual public BaseSimAnim
+{
+ public:
+
+ BounceAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon) :
+ Animation::Animation (w, curWindowEvent, duration, info, icon),
+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, icon),
+ FadeAnim::FadeAnim (w, curWindowEvent, duration, info, icon)
+ {
+ ANIMSIM_SCREEN (screen);
+
+ bounceCount = ass->optionGetBounceNumber ();
+ nBounce = 1;
+ targetScale = ass->optionGetBounceMinSize ();
+ currentScale = ass->optionGetBounceMaxSize ();
+ bounceNeg = false;
+ currBounceProgress = 0.0f;
+ lastProgressMax = 0.0f;
+ }
+
+ protected:
+
+ void step () { TransformAnim::step (); }
+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
+ bool updateBBUsed () { return true; }
+
+ void applyTransform ();
+
+ float getProgress ();
+ float getFadeProgress ()
+ {
+ return progressDecelerate (progressLinear ());
+ }
+
+ int bounceCount;
+ int nBounce;
+ float targetScale;
+ float currentScale;
+ bool bounceNeg;
+ float currBounceProgress;
+ float lastProgressMax;
+};
+
+class SheetAnim : public GridAnim,
+ virtual public BaseSimAnim
+{
+ public:
+
+ SheetAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &icon);
+
+ class WaveParam
+ {
+ public:
+ float halfWidth;
+ float amp;
+ float pos;
+ };
+
+ protected:
+
+ void initGrid ()
+ {
+ mGridWidth = 30;
+ mGridHeight = 30;
+ }
+
+ void step ();
+ void updateBB (CompOutput &output);
+ bool updateBBUsed () { return true; }
+ bool stepRegionUsed () { return true; }
+
+ int sheetsWaveCount;
+ std::vector <WaveParam> sheetsWaves;
+};
+
+class AnimSimPluginVTable:
+ public CompPlugin::VTableForScreenAndWindow <AnimSimScreen, AnimSimWindow>
+{
+ public:
+ bool init ();
+};
diff --git a/src/bounce.cpp b/src/bounce.cpp
new file mode 100644
index 0000000..7fc8853
--- /dev/null
+++ b/src/bounce.cpp
@@ -0,0 +1,76 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+
+// ===================== Effect: Bounce =========================
+
+float
+BounceAnim::getProgress ()
+{
+ return progressLinear ();
+}
+
+void
+BounceAnim::applyTransform ()
+{
+ float scale = 1.0f - (targetScale * (currBounceProgress) + currentScale * (1.0f - currBounceProgress));
+ float forwardProgress = getProgress ();;
+ float forwardProgressInc = 1.0f / bounceCount;
+
+ /* last bounce, enure we are going for 0.0 */
+ currBounceProgress = (((1 - forwardProgress) - lastProgressMax) / forwardProgressInc);
+
+ if (currBounceProgress > 1.0f)
+ {
+ currentScale = targetScale;
+ targetScale = -targetScale + targetScale / 2.0f;
+ lastProgressMax = 1.0f - forwardProgress;
+ currBounceProgress = 0.0f;
+ nBounce++;
+ }
+
+ GLMatrix *transform = &mTransform;
+
+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f, 0.0f);
+
+ transform->scale (scale, scale, 1.0f);
+
+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f), 0.0f);
+
+}
diff --git a/src/expand-piecewise.cpp b/src/expand-piecewise.cpp
new file mode 100644
index 0000000..5c427f5
--- /dev/null
+++ b/src/expand-piecewise.cpp
@@ -0,0 +1,90 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+#define DELTA 0.0001f
+
+// ===================== Effect: ExpandPW =========================
+
+void
+ExpandPWAnim::applyTransform ()
+{
+ ANIMSIM_SCREEN (screen);
+
+ GLMatrix *transform = &mTransform;
+
+ float forwardProgress = 1.0f - getProgress ();
+
+ float initialXScale = ass->optionGetExpandpwInitialHoriz () / (float) mWindow->width ();
+ float initialYScale = ass->optionGetExpandpwInitialVert () / (float) mWindow->height ();
+
+ // animation movement
+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
+ 0.0f);
+
+ float xScale;
+ float yScale;
+ float switchPointP;
+ float switchPointN;
+ float delay = ass->optionGetExpandpwDelay ();
+
+ if (ass->optionGetExpandpwHorizFirst ())
+ {
+ switchPointP = mWindow->width () / (float) (mWindow->width () + mWindow->height ()) + mWindow->height () / (float) (mWindow->width () + mWindow->height ()) * delay;
+ switchPointN = mWindow->width () / (float) (mWindow->width () + mWindow->height ()) - mWindow->width () / (float) (mWindow->width () + mWindow->height ()) * delay;
+ if(switchPointP >= 1.0f) switchPointP = 1.0f - DELTA;
+ if(switchPointN <= 0.0f) switchPointN = 0.0f + DELTA;
+ xScale = initialXScale + (1.0f - initialXScale) * (forwardProgress < switchPointN ? 1.0f - (switchPointN - forwardProgress)/switchPointN : 1.0f);
+ yScale = initialYScale + (1.0f - initialYScale) * (forwardProgress > switchPointP ? (forwardProgress - switchPointP)/(1.0f-switchPointP) : 0.0f);
+ }
+ else
+ {
+ switchPointP = mWindow->height () / (float) (mWindow->width () + mWindow->height ()) + mWindow->width () / (float) (mWindow->width () + mWindow->height ()) * delay;
+ switchPointN = mWindow->height () / (float) (mWindow->width () + mWindow->height ()) - mWindow->height () / (float) (mWindow->width () + mWindow->height ()) * delay;
+ if(switchPointP >= 1.0f) switchPointP = 1.0f - DELTA;
+ if(switchPointN <= 0.0f) switchPointN = 0.0f + DELTA;
+ xScale = initialXScale + (1.0f - initialXScale) * (forwardProgress > switchPointP ? (forwardProgress - switchPointP)/(1.0f-switchPointP) : 0.0f);
+ yScale = initialYScale + (1.0f - initialYScale) * (forwardProgress < switchPointN ? 1.0f - (switchPointN - forwardProgress)/switchPointN : 1.0f);
+ }
+
+ transform->scale (xScale, yScale, 0.0f);
+
+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
+ 0.0f);
+
+}
diff --git a/src/expand.cpp b/src/expand.cpp
new file mode 100644
index 0000000..3c4e00a
--- /dev/null
+++ b/src/expand.cpp
@@ -0,0 +1,71 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+
+// ===================== Effect: Expand =========================
+
+void
+ExpandAnim::applyTransform ()
+{
+ GLMatrix *transform = &mTransform;
+ float defaultXScale = 0.3f;
+ float forwardProgress;
+ float expandProgress;
+ const float expandPhaseEnd = 0.5f;
+
+ forwardProgress = getProgress ();
+
+ if ((1 - forwardProgress) < expandPhaseEnd)
+ expandProgress = (1 - forwardProgress) / expandPhaseEnd;
+ else
+ expandProgress = 1.0f;
+
+ // animation movement
+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
+ 0.0f);
+
+ transform->scale (defaultXScale + (1.0f - defaultXScale) *
+ expandProgress,
+ (1 - forwardProgress), 0.0f);
+
+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
+ 0.0f);
+
+}
+
diff --git a/src/flyin.cpp b/src/flyin.cpp
new file mode 100644
index 0000000..aa57110
--- /dev/null
+++ b/src/flyin.cpp
@@ -0,0 +1,87 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+
+// ===================== Effect: Flyin =========================
+
+void
+FlyInAnim::applyTransform ()
+{
+ GLMatrix *transform = &mTransform;
+ float offsetX, offsetY;
+ float xTrans, yTrans;
+ float forwardProgress;
+
+ ANIMSIM_SCREEN (screen);
+
+
+ int direction = ass->optionGetFlyinDirection ();
+ float distance = ass->optionGetFlyinDistance ();
+
+ switch (direction)
+ {
+ case 0:
+ offsetX = 0;
+ offsetY = distance;
+ break;
+ case 1:
+ offsetX = distance;
+ offsetY = 0;
+ break;
+ case 2:
+ offsetX = 0;
+ offsetY = -distance;
+ break;
+ case 3:
+ offsetX = -distance;
+ offsetY = 0;
+ break;
+ case 4:
+ offsetX = ass->optionGetFlyinDirectionX ();
+ offsetY = ass->optionGetFlyinDirectionY ();
+ break;
+ }
+
+ forwardProgress = progressLinear ();
+ xTrans = -(forwardProgress * offsetX);
+ yTrans = -(forwardProgress * offsetY);
+ Point3d translation = Point3d (xTrans, yTrans, 0);
+
+ // animation movement
+ transform->translate (translation.x (), translation.y (), translation.z ());
+
+}
diff --git a/src/rotatein.cpp b/src/rotatein.cpp
new file mode 100644
index 0000000..1fb40a0
--- /dev/null
+++ b/src/rotatein.cpp
@@ -0,0 +1,228 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+
+// ===================== Effect: RotateIn =========================
+
+void
+RotateInAnim::applyTransform ()
+{
+ ANIMSIM_SCREEN (screen);
+
+ GLMatrix *transform = &mTransform;
+ float xRot, yRot;
+ float angleX, angleY;
+ float originX, originY;
+ float forwardProgress;
+
+ int direction = ass->optionGetRotateinDirection ();
+
+ switch (direction)
+ {
+ case 1:
+ angleX = 0;
+ angleY = -ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow) + WIN_H (mWindow);
+ break;
+ case 2:
+ angleX = ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 3:
+ angleX = 0;
+ angleY = ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 4:
+ angleX = -ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow) + WIN_W (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ }
+
+ forwardProgress = getProgress ();
+ xRot = (forwardProgress * angleX);
+ yRot = (forwardProgress * angleY);
+
+ transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
+ WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
+ 0.0f);
+
+ perspectiveDistortAndResetZ (*transform);
+
+ transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
+ -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
+ 0.0f);
+
+ // animation movement
+ transform->translate (originX, originY, 0.0f);
+
+ transform->rotate (yRot, 1.0f, 0.0f, 0.0f);
+ transform->rotate (xRot, 0.0f, 1.0f, 0.0f);
+
+ transform->translate (-originX, -originY, 0.0f);
+
+}
+
+void
+RotateInAnim::prePaintWindow ()
+{
+ float forwardProgress = getProgress ();
+ float xRot, yRot;
+ float angleX, angleY;
+ float originX, originY;
+ Bool xInvert = FALSE, yInvert = FALSE;
+ int currentCull, invertCull;
+
+ glGetIntegerv (GL_CULL_FACE_MODE, &currentCull);
+ invertCull = (currentCull == GL_BACK) ? GL_FRONT : GL_BACK;
+
+ ANIMSIM_SCREEN (screen);
+
+ int direction = ass->optionGetRotateinDirection ();
+
+ switch (direction)
+ {
+ case 1:
+ angleX = 0;
+ angleY = -ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow) + WIN_H (mWindow);
+ break;
+ case 2:
+ angleX = ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 3:
+ angleX = 0;
+ angleY = ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 4:
+ angleX = -ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow) + WIN_W (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ }
+
+ /* FIXME: This could be fancy vectorial normal direction calculation */
+
+ xRot = fabs(fmodf(forwardProgress * angleX, 360.0f));
+ yRot = fabs(fmodf(forwardProgress * angleY, 360.0f));
+
+ if (xRot > 90.0f && xRot > 270.0f)
+ xInvert = TRUE;
+
+ if (yRot > 90.0f && yRot > 270.0f)
+ yInvert = TRUE;
+
+ if ((xInvert || yInvert) && !(xInvert && yInvert))
+ glCullFace (invertCull);
+}
+
+void
+RotateInAnim::postPaintWindow ()
+{
+ float forwardProgress = getProgress ();
+ float xRot, yRot;
+ float angleX, angleY;
+ float originX, originY;
+ Bool xInvert = FALSE, yInvert = FALSE;
+ int currentCull, invertCull;
+
+ glGetIntegerv (GL_CULL_FACE_MODE, &currentCull);
+ invertCull = (currentCull == GL_BACK) ? GL_FRONT : GL_BACK;
+
+ ANIMSIM_SCREEN (screen);
+
+ int direction = ass->optionGetRotateinDirection ();
+
+ switch (direction)
+ {
+ case 1:
+ angleX = 0;
+ angleY = -ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow) + WIN_H (mWindow);
+ break;
+ case 2:
+ angleX = ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 3:
+ angleX = 0;
+ angleY = ass->optionGetRotateinAngle ();
+ originX = WIN_X (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ case 4:
+ angleX = -ass->optionGetRotateinAngle ();
+ angleY = 0;
+ originX = WIN_X (mWindow) + WIN_W (mWindow);
+ originY = WIN_Y (mWindow);
+ break;
+ }
+
+ /* FIXME: This could be fancy vectorial normal direction calculation */
+
+ xRot = fabs(fmodf(forwardProgress * angleX, 360.0f));
+ yRot = fabs(fmodf(forwardProgress * angleY, 360.0f));
+
+ if (xRot > 90.0f && xRot > 270.0f)
+ xInvert = TRUE;
+
+ if (yRot > 90.0f && yRot > 270.0f)
+ yInvert = TRUE;
+
+ /* We have to assume that invertCull will be
+ * the actual inversion of our previous cull
+ */
+
+ if ((xInvert || yInvert) && !(xInvert && yInvert))
+ glCullFace (invertCull);
+}
diff --git a/src/sheet.cpp b/src/sheet.cpp
new file mode 100644
index 0000000..2554f0f
--- /dev/null
+++ b/src/sheet.cpp
@@ -0,0 +1,277 @@
+/*
+ * Animation plugin for compiz/beryl
+ *
+ * animation.c
+ *
+ * Copyright : (C) 2006 Erkin Bahceci
+ * E-mail : erkinbah@gmail.com
+ *
+ * Based on Wobbly and Minimize plugins by
+ * : David Reveman
+ * E-mail : davidr@novell.com>
+ *
+ * Particle system added by : (C) 2006 Dennis Kasprzyk
+ * E-mail : onestone@beryl-project.org
+ *
+ * Beam-Up added by : Florencio Guimaraes
+ * E-mail : florencio@nexcorp.com.br
+ *
+ * Hexagon tessellator added by : Mike Slegeir
+ * E-mail : mikeslegeir@mail.utexas.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "animationsim.h"
+
+SheetAnim::SheetAnim (CompWindow *w,
+ WindowEvent curWindowEvent,
+ float duration,
+ const AnimEffect info,
+ const CompRect &minIcon) :
+ Animation::Animation (w, curWindowEvent, duration, info, minIcon),
+ BaseSimAnim::BaseSimAnim (w, curWindowEvent, duration, info, minIcon),
+ GridAnim::GridAnim (w, curWindowEvent, duration, info, minIcon)
+{
+ int maxWaves;
+ float waveAmpMin, waveAmpMax;
+ float distance;
+ CompWindow *parent;
+ CompRect icon = minIcon;
+
+ foreach (parent, screen->windows ())
+ {
+ if (parent->transientFor () == w->id () && parent->id () != w->id ())
+ break;
+ }
+
+ if (parent)
+ {
+ icon.setX (WIN_X (parent) + WIN_W (parent) / 2.0f);
+ icon.setY (WIN_Y (parent));
+ icon.setWidth (WIN_W (w));
+ }
+ else
+ {
+ icon.setX (screen->width () / 2.0f);
+ icon.setY (0.0f);;
+ icon.setWidth (WIN_W (w));
+ }
+
+ maxWaves = 0;
+ waveAmpMin = 0.0f;
+ waveAmpMax = 0.0f;
+
+ if (maxWaves == 0)
+ {
+ sheetsWaveCount = 0;
+ }
+ else
+ {
+ // Initialize waves
+
+ distance = WIN_Y(w) + WIN_H(w) - icon.y ();
+
+ sheetsWaveCount =
+ 1 + (float)maxWaves *distance;
+
+ if (sheetsWaves.empty ())
+ {
+ sheetsWaves.resize (sheetsWaveCount);
+ }
+ // Compute wave parameters
+
+ int ampDirection = (RAND_FLOAT() < 0.5 ? 1 : -1);
+ float minHalfWidth = 0.22f;
+ float maxHalfWidth = 0.38f;
+
+ for (unsigned int i = 0; i < sheetsWaves.size (); i++)
+ {
+ sheetsWaves[i].amp =
+ ampDirection * (waveAmpMax - waveAmpMin) *
+ rand() / RAND_MAX + ampDirection * waveAmpMin;
+ sheetsWaves[i].halfWidth =
+ RAND_FLOAT() * (maxHalfWidth -
+ minHalfWidth) + minHalfWidth;
+
+ // avoid offset at top and bottom part by added waves
+ float availPos = 1 - 2 * sheetsWaves[i].halfWidth;
+ float posInAvailSegment = 0;
+
+ if (i > 0)
+ posInAvailSegment =
+ (availPos / sheetsWaveCount) * rand() / RAND_MAX;
+
+ sheetsWaves[i].pos =
+ (posInAvailSegment +
+ i * availPos / sheetsWaveCount +
+ sheetsWaves[i].halfWidth);
+
+ // switch wave direction
+ ampDirection *= -1;
+ }
+ }
+}
+
+void
+SheetAnim::updateBB (CompOutput &output)
+{
+ // TODO: Just consider the corner objects
+
+ CompositeScreen::get (screen)->damageScreen (); // XXX: *COUGH!!!!*
+}
+
+void
+SheetAnim::step ()
+{
+ GridModel *model = mModel;
+ CompRect &icon = mIcon;
+ CompWindow *parent;
+
+ foreach (parent, screen->windows ())
+ {
+ if (parent->transientFor () == mWindow->id () && parent->id () != mWindow->id ())
+ break;
+ }
+
+ if (parent)
+ {
+ icon.setX (WIN_X (parent) + WIN_W (parent) / 2.0f);
+ icon.setY (WIN_Y (parent));
+ icon.setWidth (WIN_W (mWindow));
+ }
+ else
+ {
+ icon.setX (screen->width () / 2.0f);
+ icon.setY (0.0f);;
+ icon.setWidth (WIN_W (mWindow));
+ }
+
+ float forwardProgress = progressLinear ();
+
+ if (sheetsWaveCount > 0 && sheetsWaves.empty ())
+ return;
+
+ float iconCloseEndY;
+ float iconFarEndY;
+ float winFarEndY;
+ float winVisibleCloseEndY;
+ float winw = WIN_W(mWindow);
+ float winh = WIN_H(mWindow);
+
+
+ iconFarEndY = icon.y ();
+ iconCloseEndY = icon.y () + icon.height ();
+ winFarEndY = WIN_Y(mWindow) + winh;
+ winVisibleCloseEndY = WIN_Y(mWindow);
+ if (winVisibleCloseEndY < iconCloseEndY)
+ winVisibleCloseEndY = iconCloseEndY;
+
+
+ float preShapePhaseEnd = 0.22f;
+ float preShapeProgress = 0;
+ float postStretchProgress = 0;
+ float stretchProgress = 0;
+ float stretchPhaseEnd =
+ preShapePhaseEnd + (1 - preShapePhaseEnd) *
+ (iconCloseEndY -
+ winVisibleCloseEndY) / ((iconCloseEndY - winFarEndY) +
+ (iconCloseEndY - winVisibleCloseEndY));
+ if (stretchPhaseEnd < preShapePhaseEnd + 0.1)
+ stretchPhaseEnd = preShapePhaseEnd + 0.1;
+
+ if (forwardProgress < preShapePhaseEnd)
+ {
+ preShapeProgress = forwardProgress / preShapePhaseEnd;
+
+ // Slow down "shaping" toward the end
+ preShapeProgress = 1 - progressDecelerate (1 - preShapeProgress);
+ }
+
+ if (forwardProgress < preShapePhaseEnd)
+ {
+ stretchProgress = forwardProgress / stretchPhaseEnd;
+ }
+ else
+ {
+ if (forwardProgress < stretchPhaseEnd)
+ {
+ stretchProgress = forwardProgress / stretchPhaseEnd;
+ }
+ else
+ {
+ postStretchProgress =
+ (forwardProgress - stretchPhaseEnd) / (1 - stretchPhaseEnd);
+ }
+ }
+
+ GridModel::GridObject *object = mModel->objects ();
+ unsigned int i;
+ for (i = 0; i < mModel->numObjects (); i++, object++)
+ {
+ float origx = mWindow->x () + (winw * object->gridPosition ().x () -
+ mWindow->output ().left) * model->scale ().x ();
+ float origy = mWindow->y () + (winh * object->gridPosition ().y () -
+ mWindow->output ().top) * model->scale ().y ();
+ float icony = icon.y () + icon.height ();
+
+ float stretchedPos;
+ Point3d &objPos = object->position ();
+ stretchedPos =
+ object->gridPosition ().y () * origy +
+ (1 - object->gridPosition ().y ()) * icony;
+
+ // Compute current y position
+ if (forwardProgress < preShapePhaseEnd)
+ {
+ objPos.setY ((1 - stretchProgress) * origy +
+ stretchProgress * stretchedPos);
+ }
+ else
+ {
+ if (forwardProgress < stretchPhaseEnd)
+ {
+ objPos.setY ((1 - stretchProgress) * origy +
+ stretchProgress * stretchedPos);
+ }
+ else
+ {
+ objPos.setY ((1 - postStretchProgress) *
+ stretchedPos +
+ postStretchProgress *
+ (stretchedPos + (iconCloseEndY - winFarEndY)));
+ }
+ }
+
+ // Compute "target shape" x position
+ float yProgress = (iconCloseEndY - object->position ().y () ) / (iconCloseEndY - winFarEndY);
+
+ float targetx = yProgress * (origx - icon.x ())
+ + icon.x () + icon.width () * (object->gridPosition ().x () - 0.5);
+
+ // Compute current x position
+ if (forwardProgress < preShapePhaseEnd)
+ objPos.setX ((1 - preShapeProgress) * origx + preShapeProgress * targetx);
+ else
+ objPos.setX (targetx);
+
+ if (object->position ().y () < iconFarEndY)
+ objPos.setY (iconFarEndY);
+
+ // No need to set object->position.z to 0, since they won't be used
+ // due to modelAnimIs3D being FALSE for magic lamp.
+ }
+}
+