~vanvugt/compiz-animation-plugin/fix-915236

« back to all changes in this revision

Viewing changes to src/rollup.cpp

  • Committer: Erkin Bahceci
  • Date: 2009-07-15 16:05:10 UTC
  • Revision ID: git-v1:6eeaa209932c6039edd4c362c352f242468a118a
Initial C++ port. Dodge and magic lamp changes.

- New dodge mode: all windows moving (made the default).
- Fixed dodge artifacts/weirdness showing up in certain situations.
- Magic Lamp renamed to Magic Lamp Wavy.
- Vacuum renamed to Magic Lamp, allowed for minimize (made the default).
- Separated restack stuff (dodge and focus-fade) from animation core.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
35
35
 */
36
36
 
37
 
#include "animation-internal.h"
 
37
#include "private.h"
38
38
 
39
39
// =====================  Effect: Roll Up  =========================
40
40
 
 
41
const float RollUpAnim::kDurationFactor = 1.67;
 
42
 
 
43
RollUpAnim::RollUpAnim (CompWindow *w,
 
44
                        WindowEvent curWindowEvent,
 
45
                        float duration,
 
46
                        const AnimEffect info,
 
47
                        const CompRect &icon) :
 
48
    Animation::Animation (w, curWindowEvent, kDurationFactor * duration, info,
 
49
                          icon),
 
50
    GridAnim::GridAnim (w, curWindowEvent, kDurationFactor * duration, info,
 
51
                        icon)
 
52
{
 
53
}
 
54
 
41
55
void
42
 
fxRollUpInitGrid(CompWindow *w,
43
 
                 int *gridWidth, int *gridHeight)
 
56
RollUpAnim::initGrid ()
44
57
{
45
 
    ANIM_WINDOW(w);
46
 
 
47
 
    *gridWidth = 2;
48
 
    if (aw->com.curWindowEvent == WindowEventShade ||
49
 
        aw->com.curWindowEvent == WindowEventUnshade)
50
 
        *gridHeight = 4;
 
58
    mGridWidth = 2;
 
59
    if (mCurWindowEvent == WindowEventShade ||
 
60
        mCurWindowEvent == WindowEventUnshade)
 
61
        mGridHeight = 4;
51
62
    else
52
 
        *gridHeight = 2;
 
63
        mGridHeight = 2;
53
64
}
54
65
 
55
 
static void inline
56
 
fxRollUpModelStepObject(CompWindow * w,
57
 
                        Model * model,
58
 
                        Object * object,
59
 
                        float forwardProgress, Bool fixedInterior)
 
66
void
 
67
RollUpAnim::step ()
60
68
{
61
 
    ANIM_WINDOW(w);
62
 
 
63
 
    float origx = WIN_X(w) + WIN_W(w) * object->gridPosition.x;
64
 
 
65
 
    if (aw->com.curWindowEvent == WindowEventShade ||
66
 
        aw->com.curWindowEvent == WindowEventUnshade)
 
69
    float forwardProgress = progressEaseInEaseOut ();
 
70
    bool fixedInterior = optValB (AnimationOptions::RollupFixedInterior);
 
71
 
 
72
    CompRect outRect (mAWindow->savedRectsValid () ?
 
73
                      mAWindow->savedOutRect () :
 
74
                      mWindow->outputRect ());
 
75
 
 
76
    GridModel::GridObject *object = mModel->objects ();
 
77
    for (int i = 0; i < mModel->numObjects (); i++, object++)
67
78
    {
68
 
        // Execute shade mode
 
79
        float origx = outRect.x () + outRect.width () * object->gridPosition ().x ();
 
80
 
 
81
        // Executing shade mode
69
82
 
70
83
        // find position in window contents
71
84
        // (window contents correspond to 0.0-1.0 range)
72
85
        float relPosInWinContents =
73
 
            (object->gridPosition.y * WIN_H(w) -
74
 
             model->topHeight) / w->height;
75
 
 
76
 
        if (object->gridPosition.y == 0)
 
86
            (object->gridPosition ().y () * outRect.height () -
 
87
             mDecorTopHeight) / mWindow->height ();
 
88
 
 
89
        object->position ().setX (origx);
 
90
 
 
91
        if (object->gridPosition ().y () == 0)
77
92
        {
78
 
            object->position.x = origx;
79
 
            object->position.y = WIN_Y(w);
 
93
            object->position ().setY (outRect.y ());
80
94
        }
81
 
        else if (object->gridPosition.y == 1)
 
95
        else if (object->gridPosition ().y () == 1)
82
96
        {
83
 
            object->position.x = origx;
84
 
            object->position.y =
 
97
            object->position ().setY (
85
98
                (1 - forwardProgress) *
86
 
                (WIN_Y(w) +
87
 
                 WIN_H(w) * object->gridPosition.y) +
88
 
                forwardProgress * (WIN_Y(w) +
89
 
                                   model->topHeight +
90
 
                                   model->bottomHeight);
 
99
                (outRect.y () +
 
100
                 outRect.height () * object->gridPosition ().y ()) +
 
101
                forwardProgress * (outRect.y () +
 
102
                                   mDecorTopHeight + mDecorBottomHeight));
91
103
        }
92
104
        else
93
105
        {
94
 
            object->position.x = origx;
95
 
 
96
106
            if (relPosInWinContents > forwardProgress)
97
107
            {
98
 
                object->position.y =
 
108
                object->position ().setY (
99
109
                    (1 - forwardProgress) *
100
 
                    (WIN_Y(w) +
101
 
                     WIN_H(w) * object->gridPosition.y) +
102
 
                    forwardProgress * (WIN_Y(w) + model->topHeight);
 
110
                    (outRect.y () +
 
111
                     outRect.height () * object->gridPosition ().y ()) +
 
112
                    forwardProgress * (outRect.y () + mDecorTopHeight));
103
113
 
104
114
                if (fixedInterior)
105
 
                    object->offsetTexCoordForQuadBefore.y =
106
 
                        -forwardProgress * w->height;
 
115
                    object->offsetTexCoordForQuadBefore ().
 
116
                        setY (-forwardProgress * mWindow->height ());
107
117
            }
108
118
            else
109
119
            {
110
 
                object->position.y = WIN_Y(w) + model->topHeight;
 
120
                object->position ().setY (outRect.y () + mDecorTopHeight);
111
121
                if (!fixedInterior)
112
 
                    object->offsetTexCoordForQuadAfter.
113
 
                        y =
114
 
                        (forwardProgress -
115
 
                         relPosInWinContents) * w->height;
 
122
                    object->offsetTexCoordForQuadAfter ().
 
123
                        setY ((forwardProgress - relPosInWinContents) *
 
124
                              mWindow->height ());
116
125
            }
117
126
        }
118
127
    }
119
128
}
120
129
 
121
 
void
122
 
fxRollUpModelStep (CompWindow *w, float time)
123
 
{
124
 
    defaultAnimStep (w, time);
125
 
 
126
 
    ANIM_WINDOW(w);
127
 
 
128
 
    Model *model = aw->com.model;
129
 
 
130
 
    float forwardProgress = sigmoidAnimProgress (w);
131
 
    Bool fixedInterior = animGetB (w, ANIM_SCREEN_OPTION_ROLLUP_FIXED_INTERIOR);
132
 
 
133
 
    Object *object = model->objects;
134
 
    int i;
135
 
    for (i = 0; i < model->numObjects; i++, object++)
136
 
        fxRollUpModelStepObject
137
 
            (w, 
138
 
             model,
139
 
             object,
140
 
             forwardProgress,
141
 
             fixedInterior);
142
 
}
143
 
 
144
 
Bool
145
 
fxRollUpAnimInit (CompWindow * w)
146
 
{
147
 
    ANIM_WINDOW(w);
148
 
 
149
 
    aw->com.animTotalTime /= ROLLUP_PERCEIVED_T;
150
 
    aw->com.animRemainingTime = aw->com.animTotalTime;
151
 
    
152
 
    return TRUE;
153
 
}
154