~ubuntu-branches/ubuntu/vivid/cairo-dock-plug-ins/vivid

« back to all changes in this revision

Viewing changes to Animated-icons/src/applet-bounce.c

Tags: upstream-2.0.9
ImportĀ upstreamĀ versionĀ 2.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
 
/******************************************************************************
21
 
 
22
 
This file is a part of the cairo-dock program, 
23
 
released under the terms of the GNU General Public License.
24
 
 
25
 
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
26
 
 
27
 
******************************************************************************/
28
 
 
29
20
#include <stdlib.h>
30
21
#include <string.h>
31
22
#include <math.h>
65
56
                        pData->fResizeFactor -= (1 - myConfig.fBounceResize) / (n/2);
66
57
                }
67
58
                
68
 
                double fPossibleDeltaY = MIN (50, (pDock->bDirectionUp ? pIcon->fDrawY : pDock->iCurrentHeight - (pIcon->fDrawY + pIcon->fHeight * pIcon->fScale)) + (1-pData->fResizeFactor)*pIcon->fHeight*pIcon->fScale);  // on borne a 50 pixels pour les rendus qui ont des fenetres grandes..
 
59
                double fPossibleDeltaY = MIN (50, (pDock->container.bDirectionUp ? pIcon->fDrawY : pDock->container.iHeight - (pIcon->fDrawY + pIcon->fHeight * pIcon->fScale)) + (1-pData->fResizeFactor)*pIcon->fHeight*pIcon->fScale);  // on borne a 50 pixels pour les rendus qui ont des fenetres grandes..
69
60
                if (pData->iBounceCount == 1 && ! bWillContinue)
70
61
                {
71
62
                        pData->fElevation = 0.;
73
64
                }
74
65
                else
75
66
                {
76
 
                        pData->fElevation = 1.*k / (n/2) * fPossibleDeltaY * (2 - 1.*k/(n/2)) - (pDock->bDirectionUp ? (1 - pData->fResizeFactor) * pIcon->fHeight*pIcon->fScale/2 : 0);
 
67
                        pData->fElevation = 1.*k / (n/2) * fPossibleDeltaY * (2 - 1.*k/(n/2)) - (pDock->container.bDirectionUp ? (1 - pData->fResizeFactor) * pIcon->fHeight*pIcon->fScale/2 : 0);
77
68
                        pIcon->fDeltaYReflection = 1.40 * pData->fElevation;  // le reflet "rebondira" de 40% de la hauteur au sol.
78
69
                        if (! bUseOpenGL)  // on prend en compte la translation du au fHeightFactor.
79
 
                                pIcon->fDeltaYReflection -= (pDock->bHorizontalDock ? pIcon->fHeight * pIcon->fScale * pIcon->fHeightFactor * (1 - pData->fResizeFactor) / (pDock->bDirectionUp ? 2:1) : pIcon->fWidth * pIcon->fScale * (1 - pData->fResizeFactor) / 2);
80
 
                        else if (! pDock->bDirectionUp)
 
70
                                pIcon->fDeltaYReflection -= (pDock->container.bIsHorizontal ? pIcon->fHeight * pIcon->fScale * pIcon->fHeightFactor * (1 - pData->fResizeFactor) / (pDock->container.bDirectionUp ? 2:1) : pIcon->fWidth * pIcon->fScale * (1 - pData->fResizeFactor) / 2);
 
71
                        else if (! pDock->container.bDirectionUp)
81
72
                        {
82
73
                                pData->fElevation -= (1 - pData->fResizeFactor) * pIcon->fHeight*pIcon->fScale/2;
83
74
                        }
88
79
        else  // on commence par s'aplatir.
89
80
        {
90
81
                pData->fFlattenFactor = - (1. - myConfig.fBounceFlatten) / m * k + myConfig.fBounceFlatten;  // varie de 1. exclus a f inclus.
91
 
                if (pDock->bDirectionUp)
 
82
                if (pDock->container.bDirectionUp)
92
83
                        pData->fElevation = - (1. - pData->fFlattenFactor * pData->fResizeFactor) / 2 * pIcon->fHeight * pIcon->fScale;
93
84
                
94
85
                pIcon->fDeltaYReflection = pData->fElevation;
95
86
                if (! bUseOpenGL)
96
 
                        pIcon->fDeltaYReflection -= (pDock->bHorizontalDock ? pIcon->fHeight * pIcon->fScale * (1 - pData->fResizeFactor * pData->fFlattenFactor) / (pDock->bDirectionUp ? 2:1) : pIcon->fWidth * pIcon->fScale * (1 - pData->fResizeFactor * pData->fFlattenFactor) / 2);
97
 
                else if (! pDock->bDirectionUp)
 
87
                        pIcon->fDeltaYReflection -= (pDock->container.bIsHorizontal ? pIcon->fHeight * pIcon->fScale * (1 - pData->fResizeFactor * pData->fFlattenFactor) / (pDock->container.bDirectionUp ? 2:1) : pIcon->fWidth * pIcon->fScale * (1 - pData->fResizeFactor * pData->fFlattenFactor) / 2);
 
88
                else if (! pDock->container.bDirectionUp)
98
89
                {
99
90
                        pData->fElevation = - (1 - pData->fResizeFactor * pData->fFlattenFactor) * pIcon->fHeight*pIcon->fScale/2;
100
91
                }
103
94
        
104
95
        pData->iBounceCount --;  // c'est une loi de type acceleration dans le champ de pesanteur. 'g' et 'v0' n'interviennent pas directement, car s'expriment en fonction de 'fPossibleDeltaY' et 'n'.
105
96
        
106
 
        if (! bUseOpenGL && ! pDock->bIsShrinkingDown && ! pDock->bIsGrowingUp)
 
97
        if (! bUseOpenGL)
107
98
        {
108
99
                double fDamageWidthFactor = pIcon->fWidthFactor;
109
100
                double fDamageHeightFactor = pIcon->fHeightFactor;
114
105
                fPrevElevation = MAX (fPrevElevation, pData->fElevation);
115
106
                pIcon->fWidthFactor = 1.;
116
107
                pIcon->fHeightFactor = 1.;
117
 
                pIcon->fDrawY -= (pDock->bDirectionUp ? 1 : 0) * fPrevElevation;
 
108
                pIcon->fDrawY -= (pDock->container.bDirectionUp ? 1 : 0) * fPrevElevation;
118
109
                pIcon->fHeight += fPrevElevation;
119
110
                
120
 
                cairo_dock_redraw_my_icon (pIcon, CAIRO_CONTAINER (pDock));
121
 
                //cairo_dock_redraw_container (pDock);
122
 
                pIcon->fDrawY += (pDock->bDirectionUp ? 1 : 0) * fPrevElevation;
 
111
                cairo_dock_redraw_icon (pIcon, CAIRO_CONTAINER (pDock));
 
112
                pIcon->fDrawY += (pDock->container.bDirectionUp ? 1 : 0) * fPrevElevation;
123
113
                pIcon->fWidthFactor = fDamageWidthFactor;
124
114
                pIcon->fHeightFactor = fDamageHeightFactor;
125
115
                pIcon->fDeltaYReflection = fDeltaYReflection;
126
116
                pIcon->fHeight -= fPrevElevation;
127
117
        }
 
118
        else
 
119
                cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
128
120
        
129
121
        return (pData->iBounceCount > 0);
130
122
}
148
140
                pIcon->fWidthFactor /= pData->fResizeFactor;
149
141
        }
150
142
        
151
 
        if (pDock->bHorizontalDock)
152
 
                glTranslatef (0., (pDock->bDirectionUp ? 1 : -1) * pData->fElevation * sens, 0.);
 
143
        if (pDock->container.bIsHorizontal)
 
144
                glTranslatef (0., (pDock->container.bDirectionUp ? 1 : -1) * pData->fElevation * sens, 0.);
153
145
        else
154
 
                glTranslatef ((pDock->bDirectionUp ? -1 : 1) * pData->fElevation * sens, 0., 0.);
 
146
                glTranslatef ((pDock->container.bDirectionUp ? -1 : 1) * pData->fElevation * sens, 0., 0.);
155
147
}
156
148
 
157
149
 
173
165
                pIcon->fWidthFactor /= pData->fResizeFactor;
174
166
        }
175
167
        
176
 
        if (pDock->bHorizontalDock)
 
168
        if (pDock->container.bIsHorizontal)
177
169
                cairo_translate (pCairoContext,
178
170
                        pIcon->fWidth * pIcon->fScale * (1 - pIcon->fWidthFactor) / 2 * sens,
179
 
                        (pDock->bDirectionUp ? 1 : 0) * pIcon->fHeight * pIcon->fScale * (1 - pIcon->fHeightFactor) / 2 * sens);
 
171
                        (pDock->container.bDirectionUp ? 1 : 0) * pIcon->fHeight * pIcon->fScale * (1 - pIcon->fHeightFactor) / 2 * sens);
180
172
        else
181
173
                cairo_translate (pCairoContext,
182
 
                        (pDock->bDirectionUp ? 1 : 0) * pIcon->fHeight * pIcon->fScale * (1 - pIcon->fHeightFactor) / 2 * sens,
 
174
                        (pDock->container.bDirectionUp ? 1 : 0) * pIcon->fHeight * pIcon->fScale * (1 - pIcon->fHeightFactor) / 2 * sens,
183
175
                        pIcon->fWidth * pIcon->fScale * (1 - pIcon->fWidthFactor) / 2 * sens);
184
176
        
185
 
        if (pDock->bHorizontalDock)
 
177
        if (pDock->container.bIsHorizontal)
186
178
                cairo_translate (pCairoContext,
187
179
                        0.,
188
 
                        - (pDock->bDirectionUp ? 1 : -1) * pData->fElevation * sens);
 
180
                        - (pDock->container.bDirectionUp ? 1 : -1) * pData->fElevation * sens);
189
181
        else
190
182
                cairo_translate (pCairoContext,
191
 
                        - (pDock->bDirectionUp ? 1 : -1) * pData->fElevation * sens,
 
183
                        - (pDock->container.bDirectionUp ? 1 : -1) * pData->fElevation * sens,
192
184
                        0.);
193
185
}
194
186