~azzar1/compiz/fix-1234624

« back to all changes in this revision

Viewing changes to plugins/animation/src/horizontalfold.cpp

Animation code cleanup:

Return ASAP, do not calculate stuff you might not need.
Declare CompWindow *w, AnimWindow *animWin, PrivateAnimWindow *aw
and Animation *curAnim outside the for loop.
grid.cpp: Declare float x, y, topiyFloat outside the for loop.
options.cpp: Declare unsigned int nOptions outside the foreach loop.
Use pre- instead of postfix de- and increments.
Declaration and assignment of variables in one line.
Merged if condition checks.
Added and removed brackets.
Added and removed newlines.
Fixed indentation.
Also initialize the non-static class members "mGridWidth" and
"mGridHeight" in the GridAnim::GridAnim ctor. (LP: #1101618). Fixes: https://bugs.launchpad.net/bugs/1101618.

Approved by Sami Jaktholm, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
// =====================  Effect: Horizontal Folds  =========================
40
40
 
41
 
HorizontalFoldsAnim::HorizontalFoldsAnim (CompWindow *w,
42
 
                                          WindowEvent curWindowEvent,
43
 
                                          float duration,
 
41
HorizontalFoldsAnim::HorizontalFoldsAnim (CompWindow       *w,
 
42
                                          WindowEvent      curWindowEvent,
 
43
                                          float            duration,
44
44
                                          const AnimEffect info,
45
 
                                          const CompRect &icon) :
 
45
                                          const CompRect   &icon) :
46
46
    Animation::Animation (w, curWindowEvent, duration, info, icon),
47
47
    TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
48
48
    FoldAnim::FoldAnim (w, curWindowEvent, duration, info, icon)
53
53
HorizontalFoldsAnim::initGrid ()
54
54
{
55
55
    mGridWidth = 2;
 
56
 
56
57
    if (mCurWindowEvent == WindowEventShade ||
57
58
        mCurWindowEvent == WindowEventUnshade)
58
59
        mGridHeight = 3 + 2 *
64
65
 
65
66
float
66
67
HorizontalFoldsAnim::getObjectZ (GridAnim::GridModel *mModel,
67
 
                                 float forwardProgress,
68
 
                                 float sinForProg,
69
 
                                 float relDistToFoldCenter,
70
 
                                 float foldMaxAmp)
 
68
                                 float               forwardProgress,
 
69
                                 float               sinForProg,
 
70
                                 float               relDistToFoldCenter,
 
71
                                 float               foldMaxAmp)
71
72
{
72
73
    return -(sinForProg *
73
74
             foldMaxAmp *
101
102
    int oheight = outRect.height ();
102
103
 
103
104
    float winHeight = 0;
 
105
 
104
106
    if (mCurWindowEvent == WindowEventShade ||
105
107
        mCurWindowEvent == WindowEventUnshade)
106
 
    {
107
108
        winHeight = winRect.height ();
108
 
    }
109
109
    else
110
 
    {
111
110
        winHeight = inRect.height ();
112
 
    }
113
 
    int nHalfFolds =
114
 
        2.0 * optValI (AnimationOptions::HorizontalFoldsNumFolds);
 
111
 
 
112
    int nHalfFolds = 2.0 * optValI (AnimationOptions::HorizontalFoldsNumFolds);
 
113
 
115
114
    float foldMaxAmp =
116
115
        0.3 * pow ((winHeight / nHalfFolds) / ::screen->height (), 0.3) *
117
116
        optValF (AnimationOptions::HorizontalFoldsAmpMult);
122
121
 
123
122
    GridModel::GridObject *object = mModel->objects ();
124
123
    unsigned int n = mModel->numObjects ();
 
124
 
125
125
    for (unsigned int i = 0; i < n; ++i, ++object)
126
126
    {
127
127
        Point3d &objPos = object->position ();
134
134
            float origy = (wy +
135
135
                           (oheight * objGridY -
136
136
                            outExtents.top) * mModel->scale ().y ());
 
137
 
137
138
            if (mCurWindowEvent == WindowEventShade ||
138
139
                mCurWindowEvent == WindowEventUnshade)
139
 
            {
140
 
                // Execute shade mode
141
 
 
 
140
            {    // Execute shade mode
142
141
                if (objGridY == 0)
143
142
                {
144
143
                    objPos.setY (oy);
164
163
                                    relDistToFoldCenter, foldMaxAmp));
165
164
                }
166
165
            }
167
 
            else
 
166
            else // Execute normal mode
168
167
            {
169
 
                // Execute normal mode
170
 
 
171
168
                float relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0);
172
169
 
173
170
                objPos.setY (
201
198
             mCurWindowEvent == WindowEventUnminimize) &&
202
199
            optValB (AnimationOptions::HorizontalFoldsZoomToTaskbar));
203
200
}
204