~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy-proposed

« back to all changes in this revision

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

  • Committer: Matthieu Baerts
  • Date: 2012-10-09 13:51:52 UTC
  • mfrom: (1.1.25)
  • Revision ID: matttbe@gmail.com-20121009135152-0nu6caskzsh8al66
Tags: 3.1.0-0ubuntu1
* New upstream release. (LP: #1064130)
 - Even if there are a lot of changes, this is a 'bug-fix' version.
   Changes are big mainly because the translations have been updated and
   a lot of GCC warnings (from -Wall and -Wextra) have been fixed.
 - Note that due to the recent rewrite of indicator-messages,
    Messaging-Menu has been rewritten too to directly load the .so file
    Now it's just easy to add a new indicator applet and this is why
    Printers-Menu (indicator-printers) and Sync-Menu (indicator-sync)
    applets have been added just by modifying the name of the .so file.
* Upstream ChangeLog (detailed changes since the last version):
 - All:
  + Graph: iRadius parameter is no longer needed
  + Notifications: removed unused registrations to a few signals
    (on click, on middle click, on build menu, etc.)
  + Code cleaning: removed a few useless g_print (or used cd_debug instead)
  + Code cleaning: fixed a lot of GCC's warnings when using -Wall
  + po: updated the translations
  + po: Added Lithuanian and Hebrew languages
 - Cairo-Penguin: its menu wasn't displayed when clicking on the character
 - Dock-Rendering:
  + Slide view: fixed the arrow color when the sub-dock is on a side of
    the screen
  + Slide view: renamed the files + fixed the position of the sub-dock when
    the parent dock's alignment is not centered
 - Doncky: fixed a lot (and a lot) memory leaks and warnings during the
    compilation
 - GMenu: for those having a big lag when opening the menu for the first
   time: it's now possible to load all icons at startup (hidden option)
 - GVFS:
  + No longer added the home directory when listing vfs-root
  + Fixed a few memory leaks
  + Renamed '/' by 'File System' (name used by other DE)
  + Removed an useless strcmp
 - Indicators:
  + Added support of the new Indicator (3-0.4)
    (needed for the new version of indicator-messaging)
  + Added Printers-Menu and Sync-Menu (they just load the right .so file)
 - Mail:
  + Fixed a few memory leaks and removed useless variables' initialisations
  + Set '/' as a default path if none is defined in conf
 - Messaging-Menu:
  + This applet was broken on Ubuntu Quantal due to the recent changes in
    the messagin-menu deamon. Now we use Indicator-applet3 to manage the
    applet. The code is now shorter, it should be safer and it's no longer
    needed to sync the code between indicator-messages and this
    Messaging-Menu applet
  + Removed the link to ido (it's not needed)
 - musicPlayer:
  + Prevent displaying quicklist, since the applet already provides all the
    common actions for any player
  + mpris2: some players doesn't support (well) the 'trackid'
    (e.g. Audacious or Pithos)
  + cover: used a loop instead of checking all names one by one
 - Powermanager:
  + UPower: displayed the details of all batteries
    (and not only the first one)
    + Connected to 'device-added' and 'device-removed' signals if the user
      adds or removes a battery (and avoid wrong informations)
 - Recent-Events:
  + Dialog: no longer added removed files
  + Dialog: Applications: Used the translated name
  + Recent files: added deleted files to the hashtable to prevent useless
    g_file_test
 - Shortcuts:
  + Bookmarks: moved Home to the bookmarks list (like most files managers)
  + Added the disk space progress bar on the Home folder, since /home is
    not listed by gvfs except if /home is on another partition
 - showDesktop:
  + Checked the XRandr version with the core function to avoid crash
    if XRandr 1.2 is not available
 - Stack:
  + Used 'g_uri_unescape_string' instead of 'g_filename_from_uri' to
    support all uri an not only 'file://'
 - Status-Notifier: if the item doesn't have info for the title, the ID is
   shown but this string is cut (12 chars)
 - Switcher: changed the 'render' notification order to draw the desklet
   after the desklet manager
* debian/rules:
 - Removed all unstable applets
* debian/cairo-dock-plug-ins.install:
 - Removed appmenu-registrar which was needed for the unstable'Global-Menu'
   applet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
#define XCurve(W, a, t) (W * xCurve (a, t))
54
54
#define YCurve(h, t) (h * yCurve (t))
55
55
 
56
 
#define _define_parameters(h, hi, ti, xi, w, dw)\
 
56
#define _define_parameters(h, hi, ti, xi, dw)\
57
57
        double h = 4./3 * (pDock->iDecorationsHeight + myDocksParam.iDockLineWidth);  /* hauteur de controle de la courbe de Bezier, de telle facon qu'elle atteigne 'iDecorationsHeight'.*/\
58
58
        double hi = .5 * pDock->iMaxIconHeight * pDock->container.fRatio + myDocksParam.iFrameMargin - 1;  /* hauteur de la courbe a la 1ere icone.*/\
59
59
        double ti = .5 * (1. - sqrt (MAX (1. - 4./3 * hi / h, 0.01)));\
60
60
        double xi = xCurve (my_fCurveCurvature, ti);\
61
 
        double w, dw = 0
 
61
        double dw = 0
62
62
 
63
63
static void cd_rendering_calculate_reference_curve (double alpha)
64
64
{
77
77
                s_pReferenceCurveY = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
78
78
        }
79
79
        
80
 
        double s, x, y;
 
80
        double s;
81
81
        int i;
82
82
        for (i = 0; i < RENDERING_INTERPOLATION_NB_PTS+1; i ++)
83
83
        {
94
94
        return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveS);
95
95
}
96
96
 
 
97
/* Not used
97
98
static double cd_rendering_interpol_curve_height (double x)
98
99
{
99
100
        return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveY);
100
101
}
 
102
*/
101
103
 
102
104
static void cd_rendering_calculate_max_dock_size_curve (CairoDock *pDock)
103
105
{
118
120
        double fRatio = (pDock->iRefCount == 0 && pDock->iVisibility == CAIRO_DOCK_VISI_RESERVE ? 1. : pDock->container.fRatio);  // prevent the dock from resizing itself and all the maximized windows each time an icon is removed/inserted.
119
121
        pDock->iMinDockHeight = myDocksParam.iDockLineWidth + myDocksParam.iFrameMargin + my_iCurveAmplitude + pDock->iMaxIconHeight * fRatio;  // de bas en haut.
120
122
        
121
 
        _define_parameters (h, hi, ti, xi, w, dw);
 
123
        _define_parameters (h, hi, ti, xi, dw);
122
124
        
123
125
        // taille max
124
126
        //w
125
 
        w = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->fFlatDockWidth, 1., 0.));  // etendue max des icones, sans le cadre.
 
127
        double w = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->fFlatDockWidth, 1., 0.));  // etendue max des icones, sans le cadre.
126
128
        // -> dw
127
129
        dw = w * xi / (1 - 2 * xi);  // abscisse de la 1ere icone pour satisfaire a la contrainte y=hi.
128
130
        // -> pointe
166
168
static void cd_rendering_make_3D_curve_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bIncludeEdges, gboolean bBackGround)
167
169
{
168
170
        double fLineWidth = myDocksParam.iDockLineWidth;
169
 
        double fMargin = myDocksParam.iFrameMargin;
170
171
        double hi;
171
172
        
172
173
        Icon *pPrevIcon = cairo_dock_get_previous_icon (pDock->icons, icon);
177
178
                pNextIcon = icon;
178
179
        
179
180
        double fVanishingDistanceLeft, fVanishingDistanceRight;
180
 
        double fDeltaInterIconLeft, fDeltaInterIconRight;
 
181
        double fDeltaInterIconLeft;
181
182
        if (pDock->container.bDirectionUp)
182
183
        {
183
184
                hi = pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale);
185
186
                fVanishingDistanceRight = iVanishingPointY + pNextIcon->fDrawY + pNextIcon->fHeight * pNextIcon->fScale;
186
187
                
187
188
                fDeltaInterIconLeft = (pPrevIcon->fDrawY + pPrevIcon->fHeight * pPrevIcon->fScale) - (icon->fDrawY + icon->fHeight * icon->fScale);
188
 
                fDeltaInterIconRight = (icon->fDrawY + icon->fHeight * icon->fScale) - (pNextIcon->fDrawY + pNextIcon->fHeight * pNextIcon->fScale);
 
189
                //fDeltaInterIconRight = (icon->fDrawY + icon->fHeight * icon->fScale) - (pNextIcon->fDrawY + pNextIcon->fHeight * pNextIcon->fScale);
189
190
        }
190
191
        else
191
192
        {
194
195
                fVanishingDistanceRight = iVanishingPointY + pDock->container.iHeight - pNextIcon->fDrawY;
195
196
                
196
197
                fDeltaInterIconLeft = (pPrevIcon->fDrawY) - (icon->fDrawY);
197
 
                fDeltaInterIconRight = (icon->fDrawY) - (pNextIcon->fDrawY);
 
198
                //fDeltaInterIconRight = (icon->fDrawY) - (pNextIcon->fDrawY);
198
199
        }
199
200
        double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / fVanishingDistanceLeft;
200
201
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / fVanishingDistanceRight;
202
203
        if (bBackGround || ! bIncludeEdges)  // pour s'arreter sur la courbe, on realise un clippage.
203
204
        {
204
205
                //\________________ On se ramene au cas du dessin optimise.
205
 
                double x0, y0, xf, yf, w0, h0;
 
206
                double x0, xf, w0;
206
207
                if (pDock->container.bDirectionUp)
207
208
                {
208
209
                        x0 = icon->fDrawX - MAX (0, fLeftInclination * (pPrevIcon->fDrawY + pPrevIcon->fHeight * pPrevIcon->fScale));
227
228
                        }
228
229
                }
229
230
                //g_print ("x0:%.2f -> xf:%.2f\n", x0, xf);
230
 
                y0 = 0;
231
 
                yf = icon->fDrawY;
232
231
                w0 = xf - x0;
233
 
                h0 = yf - y0;
234
232
                
235
233
                int sens;
236
234
                double fDockOffsetY;  // Offset du coin haut gauche du cadre.
424
422
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / fVanishingDistanceRight;
425
423
        
426
424
        
427
 
        double fHeight, fBigWidth, fLittleWidth;
 
425
        double fHeight, fLittleWidth;
428
426
        fHeight = (bBackGround ? pDock->iDecorationsHeight - hi - 0.5*myDocksParam.iDockLineWidth : hi + 1.5*myDocksParam.iDockLineWidth);
429
 
        fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
 
427
        //fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
430
428
        fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
431
429
        
432
430
        double fDeltaXLeft = fHeight * fLeftInclination;
530
528
{
531
529
        //\____________________ On definit la position du cadre.
532
530
        double fLineWidth = myDocksParam.iDockLineWidth;
533
 
        double fMargin = myDocksParam.iFrameMargin;
534
531
        
535
 
        _define_parameters (h, hi, ti, xi, w, dw);
536
 
        w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myDocksParam.iFrameMargin;
 
532
        _define_parameters (h, hi, ti, xi, dw);
 
533
        double w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myDocksParam.iFrameMargin;
537
534
        
538
535
        int sens;
539
536
        double dx, dy;  // position de la pointe gauche.
664
661
        double fLeftInclination = fabs (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
665
662
        double fRightInclination = fabs (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
666
663
        
667
 
        double fHeight, fBigWidth, fLittleWidth;
 
664
        double fHeight;
668
665
        if (bIncludeEdges)
669
666
        {
670
667
                fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + (bIncludeEdges ? myDocksParam.iDockLineWidth : 0);
671
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
672
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
 
668
                //fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
 
669
                //fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
673
670
        }
674
671
        else
675
672
        {
676
673
                fHeight = pDock->iDecorationsHeight;
677
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
678
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
 
674
                //fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
 
675
                //fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
679
676
        }
680
 
        double fDeltaXLeft = fHeight * fLeftInclination;
681
 
        double fDeltaXRight = fHeight * fRightInclination;
682
 
        double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
 
677
        //double fDeltaXLeft = fHeight * fLeftInclination;
 
678
        //double fDeltaXRight = fHeight * fRightInclination;
 
679
        //double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
683
680
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
684
 
        
 
681
 
 
682
        /*
685
683
        int sens;
686
684
        double fDockOffsetX, fDockOffsetY;
687
685
        if (pDock->container.bDirectionUp)
705
703
                        fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
706
704
                else
707
705
                        fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
 
706
        */
708
707
        double fXLeft, fXRight;
709
708
        if (icon->fDrawX + icon->fWidth * icon->fScale / 2 > pDock->container.iWidth / 2)  // on est a droite.
710
709
        {
756
755
{
757
756
        //\____________________ On trace le cadre.
758
757
        double fLineWidth = myDocksParam.iDockLineWidth;
759
 
        double fMargin = myDocksParam.iFrameMargin;
760
 
        _define_parameters (h, hi, ti, xi, w, dw);
 
758
        _define_parameters (h, hi, ti, xi, dw);
761
759
        int sens;
762
 
        double dx, dy;
 
760
        double dx, dy, w;
763
761
        
764
762
        w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myDocksParam.iFrameMargin;
765
763
        if (cairo_dock_is_extended_dock (pDock))
786
784
                dy = .5 * fLineWidth;
787
785
        }
788
786
        
789
 
        int x0, y0, w0, h0;
 
787
        int x0, w0;
790
788
        if (pDock->container.bIsHorizontal)
791
789
        {
792
790
                x0 = pArea->x;
793
 
                y0 = pArea->y;
794
791
                w0 = pArea->width;
795
 
                h0 = pArea->height;
796
792
        }
797
793
        else
798
794
        {
799
795
                x0 = pArea->y;
800
 
                y0 = pArea->x;
801
796
                w0 = pArea->height;
802
 
                h0 = pArea->width;
803
797
        }
804
798
        
805
799
        //\________________ On approche le morceau de courbe de Bezier par des trapezes.
1003
997
        if(pDock->icons  == NULL)
1004
998
                return NULL;
1005
999
        gint sens = pDock->container.bDirectionUp ? 1 : -1;
1006
 
        double fReflectionOffsetY = - sens * /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio;
 
1000
        //double fReflectionOffsetY = - sens * /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio;
1007
1001
        // On va calculer une parabole pour approcher la courbe de bézier : 
1008
1002
        // Soient A: (xa,ya) B: (xb,yb) C: (xc,yc) trois points qui appartiennent à la parabole. xa, xb et xc sont distincts.
1009
1003
        // P1(x)=(x-xb)(x-xc)
1015
1009
        gdouble xa, xb, xc, ya, yb, yc, k1, k2, k3;
1016
1010
        if (cairo_dock_is_extended_dock (pDock))  // A et C correspondent aux extremites du cadre
1017
1011
        {
1018
 
                _define_parameters (h, hi, ti, xi, w, dw);
 
1012
                _define_parameters (h, hi, ti, xi, dw);
1019
1013
                double Ws = pDock->container.iWidth;  // = w + 2*dw = dw / xi * (1 - 2 * xi) + 2*dw = dw / xi
1020
1014
                dw = Ws * xi;  // on neglige la pointe.
1021
1015
                xa = dw;
1078
1072
        static CairoDockGLPath *pPath = NULL;
1079
1073
        
1080
1074
        double w = 1. / 2;
1081
 
        double h = 1. / 2;
1082
1075
        double xp = -w, xq = - my_fCurveCurvature * w, xr = - xq, xs = - xp;
1083
1076
        double yp = 0., yq = fRelativeControlHeight, yr = yq, ys = yp;
1084
1077
        int iNbPoints = 180/DELTA_ROUND_DEGREE;
1100
1093
{
1101
1094
        //\____________________ On definit la position du cadre.
1102
1095
        double fLineWidth = myDocksParam.iDockLineWidth;
1103
 
        double fMargin = myDocksParam.iFrameMargin;
1104
1096
        
1105
 
        _define_parameters (h, hi, ti, xi, w, dw);
1106
 
        w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myDocksParam.iFrameMargin;
 
1097
        _define_parameters (h, hi, ti, xi, dw);
 
1098
        double w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myDocksParam.iFrameMargin;
1107
1099
        dw = w * xi / (1 - 2 * xi);
1108
1100
        
1109
 
        double dx, dy;  // position de la pointe gauche.
 
1101
        double dx;  // position de la pointe gauche.
1110
1102
        if (cairo_dock_is_extended_dock (pDock))  // mode panel etendu.
1111
1103
        {
1112
1104
                dx = 0;
1119
1111
                dx = (pFirstIcon != NULL ? pFirstIcon->fDrawX - dw : fLineWidth / 2);
1120
1112
        }
1121
1113
        
1122
 
        dy = pDock->iDecorationsHeight + 1.5 * fLineWidth;
1123
1114
        double fFrameHeight = pDock->iDecorationsHeight + fLineWidth;
1124
1115
        
1125
1116
        //\_____________ On genere les coordonnees du contour.