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

« back to all changes in this revision

Viewing changes to icon-effect/src/applet-fire.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Didier Roche
  • Date: 2010-02-14 00:51:22 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100214005122-u7ld66ax6m7tl0dk
Tags: 2.1.3-6-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream release (LP: #521536)
* debian/control:
 - Remove some duplicated build-depends
 - Update the website (cairo-dock.org -> glx-dock.org)
 - Added libetpan-dev as depends for cairo-dock-plug-ins (mail applet).
 - Updated cairo-dock-core and cairo-dock-dev minimal version.
* Updated debian/watch and debian/copyright with LP account.
* debian/rules:
 - Added --enable-mail and --enable-rssreader to enable new stable applets.

[ Didier Roche ]
* Fix debian/watch
* Fix some issue in versionning
* cleaning the package in debian/control to have good build-dep and deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "applet-fire.h"
26
26
 
27
27
 
28
 
CairoParticleSystem *cd_icon_effect_init_fire (Icon *pIcon, CairoDock *pDock, double dt)
 
28
static gboolean init (Icon *pIcon, CairoDock *pDock, double dt, CDIconEffectData *pData)
29
29
{
 
30
        if (pData->pFireSystem != NULL)
 
31
                return TRUE;
 
32
        
30
33
        if (myData.iFireTexture == 0)
31
34
                myData.iFireTexture = cd_icon_effect_load_fire_texture ();
32
 
        double fMaxScale = (pDock->bAtBottom ? 1. : 1. + g_fAmplitude * pDock->fMagnitudeMax);
33
 
        CairoParticleSystem *pFireParticleSystem = cairo_dock_create_particle_system (myConfig.iNbFireParticles, myData.iFireTexture, pIcon->fWidth * pIcon->fScale, pIcon->fHeight * fMaxScale);
34
 
        g_return_val_if_fail (pFireParticleSystem != NULL, NULL);
35
 
        pFireParticleSystem->dt = dt;
 
35
        
 
36
        double fMaxScale = 1. + g_fAmplitude * pDock->fMagnitudeMax;
 
37
        CairoParticleSystem *pParticleSystem = cairo_dock_create_particle_system (myConfig.iNbFireParticles, myData.iFireTexture, pIcon->fWidth * pIcon->fScale, pIcon->fHeight * fMaxScale);
 
38
        g_return_val_if_fail (pParticleSystem != NULL, FALSE);
 
39
        pParticleSystem->dt = dt;
36
40
        if (myConfig.bRotateEffects && ! pDock->container.bDirectionUp && pDock->container.bIsHorizontal)
37
 
                pFireParticleSystem->bDirectionUp = FALSE;
38
 
        pFireParticleSystem->bAddLuminance = myConfig.bFireLuminance;
 
41
                pParticleSystem->bDirectionUp = FALSE;
 
42
        pParticleSystem->bAddLuminance = myConfig.bFireLuminance;
39
43
        
40
44
        double a = myConfig.fFireParticleSpeed;
41
45
        static double epsilon = 0.1;
46
50
        int i;
47
51
        for (i = 0; i < myConfig.iNbFireParticles; i ++)
48
52
        {
49
 
                p = &(pFireParticleSystem->pParticles[i]);
 
53
                p = &(pParticleSystem->pParticles[i]);
50
54
                
51
55
                p->x = 2 * g_random_double () - 1;
52
56
                p->x = p->x * p->x * (p->x > 0 ? 1 : -1);
82
86
                p->fResizeSpeed = -.5 / myConfig.iFireDuration * dt;  // zoom 0.5 a la fin.
83
87
        }
84
88
        
85
 
        return pFireParticleSystem;
 
89
        pData->pFireSystem = pParticleSystem;
 
90
        return TRUE;
86
91
}
87
92
 
88
93
 
89
 
gboolean cd_icon_effect_update_fire_system (CairoParticleSystem *pParticleSystem, CairoDockRewindParticleFunc pRewindParticle)
 
94
gboolean _update_fire_system (CairoParticleSystem *pParticleSystem, CairoDockRewindParticleFunc pRewindParticle)
90
95
{
91
96
        gboolean bAllParticlesEnded = TRUE;
92
97
        CairoParticle *p;
96
101
                p = &(pParticleSystem->pParticles[i]);
97
102
                
98
103
                p->fOscillation += p->fOmega;
99
 
                p->x += p->vx + (p->z + 2)/3. * .02 * sin (p->fOscillation);  // 3%
 
104
                p->x += p->vx + (p->z + 2)/3. * .02 * sin (p->fOscillation);  // 2%
100
105
                p->y += p->vy;
101
106
                p->color[3] = .8*p->iLife / p->iInitialLife;
102
107
                p->fSizeFactor += p->fResizeSpeed;
116
121
        return ! bAllParticlesEnded;
117
122
}
118
123
 
119
 
void cd_icon_effect_rewind_fire_particle (CairoParticle *p, double dt)
 
124
static void _rewind_fire_particle (CairoParticle *p, double dt)
120
125
{
121
126
        static double epsilon = 0.1;
122
127
        double a = myConfig.fFireParticleSpeed/myConfig.fFireParticleSpeed;
137
142
        p->color[3] = 1.;
138
143
}
139
144
 
 
145
static gboolean update (Icon *pIcon, CairoDock *pDock, gboolean bRepeat, CDIconEffectData *pData)
 
146
{
 
147
        if (pData->pFireSystem == NULL)
 
148
                return FALSE;
 
149
                
 
150
        gboolean bContinue = _update_fire_system (pData->pFireSystem,
 
151
                (bRepeat ? _rewind_fire_particle : NULL));
 
152
        
 
153
        pData->pFireSystem->fWidth = pIcon->fWidth * pIcon->fScale;
 
154
        
 
155
        double fMaxScale = 1. + g_fAmplitude * pDock->fMagnitudeMax;
 
156
        pData->fAreaWidth = (1. + .02) * pData->pFireSystem->fWidth + myConfig.iFireParticleSize * pDock->container.fRatio;  // 2% d'oscillation + demi-largeur des particules a droite et a gauche.
 
157
        pData->fAreaHeight = pIcon->fHeight * fMaxScale + myConfig.iFireParticleSize * pDock->container.fRatio;
 
158
        pData->fBottomGap = myConfig.iFireParticleSize * pDock->container.fRatio / 2;
 
159
        return bContinue;
 
160
}
 
161
 
 
162
 
 
163
static void render (CDIconEffectData *pData)
 
164
{
 
165
        if (pData->pFireSystem == NULL)
 
166
                return ;
 
167
        
 
168
        cairo_dock_render_particles (pData->pFireSystem);
 
169
}
 
170
 
 
171
 
 
172
static void free_effect (CDIconEffectData *pData)
 
173
{
 
174
        if (pData->pFireSystem != NULL)
 
175
        {
 
176
                cairo_dock_free_particle_system (pData->pFireSystem);
 
177
                pData->pFireSystem = NULL;
 
178
        }
 
179
}
 
180
 
 
181
 
 
182
void cd_icon_effect_register_fire (CDIconEffect *pEffect)
 
183
{
 
184
        pEffect->init = init;
 
185
        pEffect->update = update;
 
186
        pEffect->render = render;
 
187
        pEffect->free = free_effect;
 
188
}