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

« back to all changes in this revision

Viewing changes to Animated-icons/src/applet-wobbly.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>
186
177
 
187
178
#define _sum_rk(i) (2*pNode->rk[1][i] + 4*pNode->rk[2][i] + 2*pNode->rk[3][i] + pNode->rk[4][i]) / 6.
188
179
 
189
 
gboolean cd_animations_update_wobbly (CDAnimationData *pData, double dt, gboolean bWillContinue)
 
180
gboolean cd_animations_update_wobbly (CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bWillContinue)
190
181
{
191
182
        const int n = 10;
192
183
        double k = myConfig.fSpringConstant;
256
247
                }
257
248
        }
258
249
        
 
250
        cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
259
251
        return bContinue;
260
252
}
261
253
 
262
254
 
263
 
gboolean cd_animations_update_wobbly2 (CDAnimationData *pData, double dt, gboolean bWillContinue)
 
255
gboolean cd_animations_update_wobbly2 (CairoDock *pDock, CDAnimationData *pData, double dt, gboolean bWillContinue)
264
256
{
265
257
        const int n = 20;
266
258
        double k = myConfig.fSpringConstant;
345
337
                }
346
338
        }
347
339
        
 
340
        cairo_dock_redraw_container (CAIRO_CONTAINER (pDock));
348
341
        return bContinue;
349
342
}
350
343
 
357
350
        
358
351
        double fDamageWidthFactor = (c == iNbIterInOneRound-1 ? 1. : pData->fWobblyWidthFactor);
359
352
        double fDamageHeightFactor = (c == iNbIterInOneRound-1 ? 1. : pData->fWobblyHeightFactor);
360
 
        double fMinSize = .3, fMaxSize = MIN (1.75, pDock->iCurrentHeight / pIcon->fWidth);  // au plus 1.75, soit 3/8 de l'icone qui deborde de part et d'autre de son emplacement. c'est suffisamment faible pour ne pas trop empieter sur ses voisines.
 
353
        double fMinSize = .3, fMaxSize = MIN (1.75, pDock->container.iHeight / pIcon->fWidth);  // au plus 1.75, soit 3/8 de l'icone qui deborde de part et d'autre de son emplacement. c'est suffisamment faible pour ne pas trop empieter sur ses voisines.
361
354
        
362
355
        double fSizeFactor = ((c/n) & 1 ? 1. / (n - k) : 1. / (1 + k));
363
356
        //double fSizeFactor = ((c/n) & 1 ? 1.*(k+1)/n : 1.*(n-k)/n);
389
382
                pIcon->fWidthFactor *= fDamageWidthFactor;
390
383
                pIcon->fHeightFactor *= fDamageHeightFactor;
391
384
                
392
 
                cairo_dock_redraw_my_icon (pIcon, CAIRO_CONTAINER (pDock));
 
385
                cairo_dock_redraw_icon (pIcon, CAIRO_CONTAINER (pDock));
393
386
                
394
387
                pIcon->fWidthFactor /= fDamageWidthFactor;
395
388
                pIcon->fHeightFactor /= fDamageHeightFactor;
425
418
        glEvalMesh2(GL_FILL, 0, myConfig.iNbGridNodes, 0, myConfig.iNbGridNodes);  // Pour appliquer cette grille aux evaluateurs actives.
426
419
        glPopMatrix ();
427
420
        
428
 
        if (pDock->bUseReflect)
 
421
        if (pDock->container.bUseReflect)
429
422
        {
430
423
                glPushMatrix ();
431
424
                double x0, y0, x1, y1;
432
 
                double fReflectRatio = myIcons.fReflectSize * pDock->fRatio / pIcon->fHeight / pIcon->fScale;
433
 
                double fOffsetY = pIcon->fHeight * pIcon->fScale/2 + (myIcons.fReflectSize/2 + pIcon->fDeltaYReflection) * pDock->fRatio;
434
 
                if (pDock->bHorizontalDock)
 
425
                double fReflectRatio = myIcons.fReflectSize * pDock->container.fRatio / pIcon->fHeight / pIcon->fScale;
 
426
                double fOffsetY = pIcon->fHeight * pIcon->fScale/2 + (myIcons.fReflectSize/2 + pIcon->fDeltaYReflection) * pDock->container.fRatio;
 
427
                if (pDock->container.bIsHorizontal)
435
428
                {
436
 
                        if (pDock->bDirectionUp)
 
429
                        if (pDock->container.bDirectionUp)
437
430
                        {
438
431
                                fOffsetY = pIcon->fHeight * pIcon->fScale + pIcon->fDeltaYReflection;
439
432
                                glTranslatef (0., - fOffsetY, 0.);
446
439
                        else
447
440
                        {
448
441
                                glTranslatef (0., fOffsetY, 0.);
449
 
                                glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, myIcons.fReflectSize * pDock->fRatio, 1.);
 
442
                                glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, myIcons.fReflectSize * pDock->container.fRatio, 1.);
450
443
                                x0 = 0.;
451
444
                                y0 = fReflectRatio;
452
445
                                x1 = 1.;
455
448
                }
456
449
                else
457
450
                {
458
 
                        if (pDock->bDirectionUp)
 
451
                        if (pDock->container.bDirectionUp)
459
452
                        {
460
453
                                glTranslatef (fOffsetY, 0., 0.);
461
 
                                glScalef (- myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
 
454
                                glScalef (- myIcons.fReflectSize * pDock->container.fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
462
455
                                x0 = 1. - fReflectRatio;
463
456
                                y0 = 0.;
464
457
                                x1 = 1.;
467
460
                        else
468
461
                        {
469
462
                                glTranslatef (- fOffsetY, 0., 0.);
470
 
                                glScalef (myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
 
463
                                glScalef (myIcons.fReflectSize * pDock->container.fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
471
464
                                x0 = fReflectRatio;
472
465
                                y0 = 0.;
473
466
                                x1 = 0.;
487
480
                
488
481
                /*glActiveTextureARB(GL_TEXTURE1_ARB); // Go pour le texturing 2eme passe
489
482
                glEnable(GL_TEXTURE_2D);
490
 
                glBindTexture(GL_TEXTURE_2D, g_pGradationTexture[pDock->bHorizontalDock]);
 
483
                glBindTexture(GL_TEXTURE_2D, g_pGradationTexture[pDock->container.bIsHorizontal]);
491
484
                glColor4f(1.0f, 1.0f, 1.0f, myIcons.fAlbedo * pIcon->fAlpha);  // transparence du reflet.  // myIcons.fAlbedo * pIcon->fAlpha
492
485
                glEnable(GL_BLEND);
493
486
                glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
528
521
        pIcon->fHeightFactor *= pData->fWobblyHeightFactor;
529
522
        cairo_save (pCairoContext);
530
523
        
531
 
        if (pDock->bHorizontalDock)
 
524
        if (pDock->container.bIsHorizontal)
532
525
                cairo_translate (pCairoContext,
533
526
                        pIcon->fWidth * pIcon->fScale * (1 - pIcon->fWidthFactor) / 2,
534
527
                        pIcon->fHeight * pIcon->fScale * (1 - pIcon->fHeightFactor) / 2);