static void inline fxHorizontalFoldsModelStepObject(CompWindow * w, Model * model, Object * object, float forwardProgress, float sinForProg, float foldMaxAmp, int rowNo) { ANIM_WINDOW(w); float origx = w->attrib.x + (WIN_W(w) * object->gridPosition.x - w->output.left) * model->scale.x; float origy = w->attrib.y + (WIN_H(w) * object->gridPosition.y - w->output.top) * model->scale.y; object->position.x = origx; if (aw->com.curWindowEvent == WindowEventShade || aw->com.curWindowEvent == WindowEventUnshade) { // Execute shade mode float relDistToFoldCenter = (rowNo % 2 == 1 ? 0.5 : 0); if (object->gridPosition.y == 0) { object->position.y = WIN_Y(w); object->position.z = 0; } else if (object->gridPosition.y == 1) { object->position.y = (1 - forwardProgress) * origy + forwardProgress * (WIN_Y(w) + model->topHeight + model->bottomHeight); object->position.z = 0; } else { object->position.y = (1 - forwardProgress) * origy + forwardProgress * (WIN_Y(w) + model->topHeight); object->position.z = getObjectZ(model, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp); } } else { // Execute normal mode float relDistToFoldCenter; relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0); object->position.y = (1 - forwardProgress) * origy + forwardProgress * (BORDER_Y(w) + BORDER_H(w) / 2.0); object->position.z = getObjectZ(model, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp); } }
void HorizontalFoldsAnim::step () { GridZoomAnim::step (); CompRect winRect (mAWindow->savedRectsValid () ? mAWindow->saveWinRect () : mWindow->geometry ()); CompRect inRect (mAWindow->savedRectsValid () ? mAWindow->savedInRect () : mWindow->inputRect ()); CompRect outRect (mAWindow->savedRectsValid () ? mAWindow->savedOutRect () : mWindow->outputRect ()); CompWindowExtents outExtents (mAWindow->savedRectsValid () ? mAWindow->savedOutExtents () : mWindow->output ()); int wx = winRect.x (); int wy = winRect.y (); int oy = outRect.y (); int owidth = outRect.width (); int oheight = outRect.height (); float winHeight = 0; if (mCurWindowEvent == WindowEventShade || mCurWindowEvent == WindowEventUnshade) { winHeight = winRect.height (); } else { winHeight = inRect.height (); } int nHalfFolds = 2.0 * optValI (AnimationOptions::HorizontalFoldsNumFolds); float foldMaxAmp = 0.3 * pow ((winHeight / nHalfFolds) / ::screen->height (), 0.3) * optValF (AnimationOptions::HorizontalFoldsAmpMult); float forwardProgress = getActualProgress (); float sinForProg = sin (forwardProgress * M_PI / 2); GridModel::GridObject *object = mModel->objects (); unsigned int n = mModel->numObjects (); for (unsigned int i = 0; i < n; ++i, ++object) { Point3d &objPos = object->position (); if (i % 2 == 0) // object is at the left side { float objGridY = object->gridPosition ().y (); int rowNo = (int)i / mGridWidth; float origy = (wy + (oheight * objGridY - outExtents.top) * mModel->scale ().y ()); if (mCurWindowEvent == WindowEventShade || mCurWindowEvent == WindowEventUnshade) { // Execute shade mode if (objGridY == 0) { objPos.setY (oy); objPos.setZ (0); } else if (objGridY == 1) { objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (oy + mDecorTopHeight + mDecorBottomHeight)); objPos.setZ (0); } else { float relDistToFoldCenter = (rowNo % 2 == 1 ? 0.5 : 0); objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (oy + mDecorTopHeight)); objPos.setZ ( getObjectZ (mModel, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp)); } } else { // Execute normal mode float relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0); objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (inRect.y () + inRect.height () / 2.0)); objPos.setZ ( getObjectZ (mModel, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp)); } } else // object is at the right side { // Set y/z position to the y/z position of the object at the left // on the same row (previous object) Point3d &leftObjPos = (object - 1)->position (); objPos.setY (leftObjPos.y ()); objPos.setZ (leftObjPos.z ()); } float origx = (wx + (owidth * object->gridPosition ().x () - outExtents.left) * mModel->scale ().x ()); objPos.setX (origx); } }