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

« back to all changes in this revision

Viewing changes to dock-rendering/src/rendering-rainbow.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Didier Roche
  • Date: 2010-09-18 14:20:27 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100918142027-b0zsay70mqxv63l0
Tags: 2.2.0~2-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New Upstream Version (LP: #638529)
* Fixed a few bugs on LP:
 - Fixed a crash in rainbow view when the cone is completely opened
 - Fixed a crash in rainbow view if the subdock is empty
 - Installed in lib directory by default even in 64bits arch
 - Status-Notifier: fixed few bugs
 - Clock applet:
   - Notify of missed tasks (moved some functions to a new file)
   - Fixed a little memory leak
 - Removed some 'g_print' (LP: #500677: xsession-errors log)
* Updated translations
* debian/control
 - Updated the version of cairo-dock-dev and cairo-dock-core

[ Didier Roche ]
* debian/control: depends on latest libindicator-dev (LP: #637692)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
        //g_print ("pDock->fFoldingFactor : %.2f\n", pDock->fFoldingFactor);
71
71
        double fMaxScale =  1. + my_fRainbowMagnitude * g_fAmplitude;
72
72
        double fRadius=0;
73
 
        if (my_fRainbowColor[3] != 0)
 
73
        if (my_fRainbowColor[3] != 0 && pDock->icons != NULL)
74
74
        {
75
75
                cairo_save (pCairoContext);
76
76
                if (! pDock->container.bIsHorizontal)
84
84
                        cairo_translate (pCairoContext, 0., pDock->container.iHeight);
85
85
                        cairo_scale (pCairoContext, 1., -1.);
86
86
                }
87
 
                //\____________________ On trace le cadre.
 
87
                //\____________________ On fait un clip du cone.
88
88
                cairo_move_to (pCairoContext, 0., pDock->container.iHeight * (1 - sin (my_fRainbowConeOffset)));
89
89
                cairo_line_to (pCairoContext, pDock->container.iWidth/2, pDock->container.iHeight);
90
90
                cairo_line_to (pCairoContext, pDock->container.iWidth, pDock->container.iHeight * (1 - sin (my_fRainbowConeOffset)));
93
93
                cairo_close_path (pCairoContext);
94
94
                cairo_clip (pCairoContext);
95
95
                
96
 
                //\____________________ On dessine les decorations dedans.
 
96
                //\____________________ On dessine chaque rayure dedans.
97
97
                cairo_pattern_t *pGradationPattern = cairo_pattern_create_radial (pDock->container.iWidth/2,
98
98
                        pDock->container.iHeight,
99
99
                        0.,
505
505
}
506
506
 
507
507
 
508
 
static double *_generate_cos_sin (double fConeOffset, double fDelta, double *pTabValues)
 
508
static void _generate_cos_sin (double fConeOffset, double fDelta, double *pTabValues)
509
509
{
510
510
        int i, n = (int) ceil ((G_PI/2 - fConeOffset) / fDelta);
511
511
        pTabValues[2*n] = 0.;  // point au milieu.
521
521
                pTabValues[2*(2*n-i)] = - pTabValues[2*i];
522
522
                pTabValues[2*(2*n-i)+1] = pTabValues[2*i+1];
523
523
        }
524
 
        return pTabValues;
525
524
}
526
 
static GLfloat *_generate_sector_path (double fConeOffset, double fRadius1, double fRadius2, double fDelta, double *pCosSinTab, GLfloat *pTabValues)
 
525
static void _generate_sector_path (double fConeOffset, double fRadius1, double fRadius2, double fDelta, double *pCosSinTab, GLfloat *pTabValues)
527
526
{
528
527
        int i, n = (int) ceil ((G_PI/2 - fConeOffset) / fDelta), N = (2*n+1) * 2;
529
528
        for (i = 0; i < 2*n+1; i ++)
538
537
        pTabValues[3*N+1] = pTabValues[3*0+1];
539
538
        pTabValues[3*(N+1)] = pTabValues[3*1];
540
539
        pTabValues[3*(N+1)+1] = pTabValues[3*1+1];
541
 
        
542
 
        return pTabValues;
543
540
}
544
541
 
545
542
static void cd_rendering_render_rainbow_opengl (CairoDock *pDock)
546
543
{
547
544
        static double fDelta = 1.;
 
545
        int n = ceil (180./fDelta+1) + 1;  // nb points max, +1 for safety with rounded calculations.
548
546
        if (pCosSinTab == NULL)
549
547
        {
550
 
                pCosSinTab = g_new0 (double, (180./fDelta+1) * 2);
 
548
                pCosSinTab = g_new0 (double, n * 2);
551
549
                _generate_cos_sin (my_fRainbowConeOffset, fDelta/180.*G_PI, pCosSinTab);
552
550
        }
553
551
        if (pVertexTab == NULL)
554
 
                pVertexTab = g_new0 (GLfloat, ((180./fDelta+1) * 2) * 3);
 
552
                pVertexTab = g_new0 (GLfloat, (n * 2) * 3);
555
553
        if (pColorTab == NULL)
556
554
        {
557
 
                pColorTab = g_new0 (GLfloat, ((180./fDelta+1) * 2) * 4);
 
555
                pColorTab = g_new0 (GLfloat, (n * 2) * 4);
558
556
                int i;
559
 
                for (i = 0; i < (180./fDelta+1); i ++)
 
557
                for (i = 0; i < n; i ++)
560
558
                {
561
559
                        pColorTab[4*2*i+0] = my_fRainbowColor[0];
562
560
                        pColorTab[4*2*i+1] = my_fRainbowColor[1];
567
565
        
568
566
        double fMaxScale =  1. + my_fRainbowMagnitude * g_fAmplitude;
569
567
        double fRadius=0;
570
 
        if (my_fRainbowColor[3] != 0)
 
568
        if (my_fRainbowColor[3] != 0 && pDock->icons != NULL)
571
569
        {
572
570
                //\____________________ On trace le cadre.
573
571
                //\____________________ On dessine les decorations dedans.
582
580
                glEnableClientState(GL_COLOR_ARRAY);
583
581
                glLineWidth (1);
584
582
                
585
 
                int i, n = (int) ceil ((G_PI/2 - my_fRainbowConeOffset) / (fDelta/180.*G_PI)), N = (2*n+1) * 2;
 
583
                int n = (int) ceil ((G_PI/2 - my_fRainbowConeOffset) / (fDelta/180.*G_PI)), N = (2*n+1) * 2;
586
584
                
587
585
                glPushMatrix ();
588
586
                if (! pDock->container.bIsHorizontal)
722
720
        pColorTab = NULL;
723
721
        g_free (pCosSinTab);
724
722
        pCosSinTab = NULL;
 
723
        g_free (pVertexTab);
 
724
        pVertexTab = NULL;
725
725
}
726
726
 
727
727