~cairo-dock-team/ubuntu/oneiric/cairo-dock-plug-ins/2.3.0-2.1

« back to all changes in this revision

Viewing changes to dialog-rendering/src/applet-decorator-comics.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
1
3
/**
2
4
* This file is a part of the Cairo-Dock project
3
5
*
25
27
#include "applet-decorator-comics.h"
26
28
 
27
29
#define CAIRO_DIALOG_MIN_GAP 20
28
 
#define CAIRO_DIALOG_TIP_ROUNDING_MARGIN 12
29
 
#define CAIRO_DIALOG_TIP_MARGIN 25
30
 
#define CAIRO_DIALOG_TIP_BASE 25
31
 
 
 
30
#define CD_TIP_INNER_MARGIN 12
 
31
#define CD_TIP_OUTER_MARGIN 25
 
32
#define CD_TIP_BASE 25
 
33
#define _CAIRO_DIALOG_COMICS_MARGIN 4
32
34
 
33
35
void cd_decorator_set_frame_size_comics (CairoDialog *pDialog)
34
36
{
35
 
        int iMargin = .5 * myConfig.iComicsLineWidth + (1. - sqrt (2) / 2) * myConfig.iComicsRadius;
 
37
        int iMargin = .5 * myConfig.iComicsLineWidth + (1. - sqrt (2) / 2) * myConfig.iComicsRadius + _CAIRO_DIALOG_COMICS_MARGIN;  // on laisse qques pixels d'espace en plus tout autour.
 
38
        //g_print ("iMargin : %d\n", iMargin);
36
39
        pDialog->iRightMargin = iMargin;
37
40
        pDialog->iLeftMargin = iMargin;
38
41
        pDialog->iTopMargin = iMargin;
39
42
        pDialog->iBottomMargin = iMargin;
40
43
        pDialog->iMinBottomGap = CAIRO_DIALOG_MIN_GAP;
41
 
        pDialog->iMinFrameWidth = CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_ROUNDING_MARGIN + CAIRO_DIALOG_TIP_BASE;  // dans l'ordre.
 
44
        pDialog->iMinFrameWidth = CD_TIP_OUTER_MARGIN + CD_TIP_BASE + CD_TIP_INNER_MARGIN + 2*iMargin;
42
45
        pDialog->fAlign = 0.;  // la pointe colle au bord du dialogue.
43
46
        pDialog->container.fRatio = 0.;  // pas de reflet merci.
44
47
        pDialog->container.bUseReflect = FALSE;
47
50
void cd_decorator_draw_decorations_comics (cairo_t *pCairoContext, CairoDialog *pDialog)
48
51
{
49
52
        double fLineWidth = myConfig.iComicsLineWidth;
50
 
        double fRadius = myConfig.iComicsRadius;
 
53
        double fRadius = MIN (myConfig.iComicsRadius, pDialog->iBubbleHeight/2 - fLineWidth);
51
54
        
52
 
        double fGapFromDock = pDialog->iDistanceToDock + .5 * fLineWidth;
53
 
        double cos_gamma = 1 / sqrt (1. + 1. * (CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_BASE) / fGapFromDock * (CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_BASE) / fGapFromDock);
 
55
        /**double fGapFromDock = pDialog->iMinBottomGap + pDialog->iBottomMargin + fLineWidth/2;
 
56
        double cos_gamma = 1 / sqrt (1. + 1. * (CAIRO_DIALOG_TIP_MARGIN + CD_TIP_BASE) / fGapFromDock * (CAIRO_DIALOG_TIP_MARGIN + CD_TIP_BASE) / fGapFromDock);
54
57
        double cos_theta = 1 / sqrt (1. + 1. * CAIRO_DIALOG_TIP_MARGIN / fGapFromDock * CAIRO_DIALOG_TIP_MARGIN / fGapFromDock);
55
 
        double fTipHeight = fGapFromDock / (1. + fLineWidth / 2. / CAIRO_DIALOG_TIP_BASE * (1./cos_gamma + 1./cos_theta));
 
58
        double fTipHeight = fGapFromDock / (1. + fLineWidth / 2. / CD_TIP_BASE * (1./cos_gamma + 1./cos_theta));*/
56
59
        //g_print ("TipHeight <- %d\n", (int)fTipHeight);
57
 
 
58
 
        double fOffsetX = fRadius +     fLineWidth / 2;
59
 
        double fOffsetY = (pDialog->container.bDirectionUp ? fLineWidth / 2 : pDialog->container.iHeight - fLineWidth / 2);
60
 
        int     sens = (pDialog->container.bDirectionUp ?       1 :     -1);
 
60
        double fTipHeight =  pDialog->iMinBottomGap;
 
61
        
 
62
        int iWidth = pDialog->container.iWidth;
 
63
        double fMargin = 2 * fRadius + fLineWidth;
 
64
        double fBaseWidth = iWidth - fMargin;
 
65
        double fTipWidth = CD_TIP_OUTER_MARGIN + CD_TIP_BASE + CD_TIP_INNER_MARGIN;
 
66
        double fOffsetX = fRadius + fLineWidth / 2;
 
67
        double fOffsetY = fLineWidth / 2;
 
68
        
 
69
        // coin haut gauche.
 
70
        if (!pDialog->container.bDirectionUp)  // dessin a l'envers.
 
71
        {
 
72
                cairo_scale (pCairoContext, 1., -1.);
 
73
                cairo_translate (pCairoContext, 0., -pDialog->container.iHeight);
 
74
        }
61
75
        cairo_move_to (pCairoContext, fOffsetX, fOffsetY);
62
 
        //g_print ("  fOffsetX : %.2f; fOffsetY : %.2f\n", fOffsetX, fOffsetY);
63
 
        int     iWidth = pDialog->container.iWidth;
64
 
 
65
 
        cairo_rel_line_to (pCairoContext, iWidth - (2 * fRadius + fLineWidth), 0);
66
 
        // Coin haut droit.
 
76
        
 
77
        cairo_rel_line_to (pCairoContext, fBaseWidth, 0);
 
78
        // Coin haut droit.
67
79
        cairo_rel_curve_to (pCairoContext,
68
80
                0, 0,
69
81
                fRadius, 0,
70
 
                fRadius, sens * fRadius);
71
 
        cairo_rel_line_to (pCairoContext, 0, sens *     (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - (2 * fRadius + fLineWidth)));
72
 
        // Coin bas     droit.
 
82
                fRadius, fRadius);
 
83
        cairo_rel_line_to (pCairoContext, 0, pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - fMargin);
 
84
        // Coin bas droit.
73
85
        cairo_rel_curve_to (pCairoContext,
74
86
                0, 0,
75
 
                0, sens * fRadius,
76
 
                -fRadius, sens * fRadius);
 
87
                0, fRadius,
 
88
                -fRadius, fRadius);
77
89
        // La pointe.
78
 
        double fDeltaMargin;
 
90
        gboolean bRight;
79
91
        if (pDialog->bRight)
80
 
        {
81
 
                fDeltaMargin = MAX (0, pDialog->iAimedX - pDialog->container.iWindowPositionX - fRadius - fLineWidth / 2);
82
 
                //g_print ("fDeltaMargin : %.2f\n",     fDeltaMargin);
83
 
                cairo_rel_line_to (pCairoContext, -iWidth +     fDeltaMargin + fLineWidth +     2 * fRadius + CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_BASE + CAIRO_DIALOG_TIP_ROUNDING_MARGIN ,      0);     
84
 
                cairo_rel_curve_to (pCairoContext,
85
 
                        0, 0,
86
 
                        - CAIRO_DIALOG_TIP_ROUNDING_MARGIN,     0,
87
 
                        - (CAIRO_DIALOG_TIP_ROUNDING_MARGIN     + CAIRO_DIALOG_TIP_MARGIN +     CAIRO_DIALOG_TIP_BASE), sens * fTipHeight);
88
 
                cairo_rel_curve_to (pCairoContext,
89
 
                        0, 0,
90
 
                        CAIRO_DIALOG_TIP_MARGIN, - sens * fTipHeight,
91
 
                        CAIRO_DIALOG_TIP_MARGIN - CAIRO_DIALOG_TIP_ROUNDING_MARGIN,     - sens * fTipHeight);
92
 
                cairo_rel_line_to (pCairoContext, -     CAIRO_DIALOG_TIP_MARGIN - fDeltaMargin + CAIRO_DIALOG_TIP_ROUNDING_MARGIN, 0);
93
 
        }
 
92
                bRight = (pDialog->container.iWindowPositionX + iWidth > pDialog->iAimedX + fTipWidth);
94
93
        else
95
 
        {
96
 
                fDeltaMargin = MAX (0, MIN (- CAIRO_DIALOG_TIP_MARGIN - CAIRO_DIALOG_TIP_ROUNDING_MARGIN - CAIRO_DIALOG_TIP_BASE - fRadius - fLineWidth / 2, pDialog->container.iWindowPositionX - pDialog->iAimedX     - fRadius -     fLineWidth / 2) + pDialog->container.iWidth);
97
 
                //g_print ("fDeltaMargin : %.2f / %d\n", fDeltaMargin, pDialog->container.iWidth);
98
 
                cairo_rel_line_to (pCairoContext, -     (CAIRO_DIALOG_TIP_MARGIN + fDeltaMargin) + CAIRO_DIALOG_TIP_ROUNDING_MARGIN, 0);
99
 
                cairo_rel_curve_to (pCairoContext,
100
 
                        0, 0,
101
 
                        -CAIRO_DIALOG_TIP_ROUNDING_MARGIN, 0,
102
 
                        CAIRO_DIALOG_TIP_MARGIN - CAIRO_DIALOG_TIP_ROUNDING_MARGIN,     sens * fTipHeight);
103
 
                cairo_rel_curve_to (pCairoContext,
104
 
                        0, 0,
105
 
                        - (CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_BASE), - sens     * fTipHeight,
106
 
                        - (CAIRO_DIALOG_TIP_MARGIN + CAIRO_DIALOG_TIP_BASE)     - CAIRO_DIALOG_TIP_ROUNDING_MARGIN,     - sens * fTipHeight);
107
 
                cairo_rel_line_to (pCairoContext, -iWidth +     fDeltaMargin + fLineWidth +     2 *     fRadius + CAIRO_DIALOG_TIP_MARGIN +     CAIRO_DIALOG_TIP_BASE + CAIRO_DIALOG_TIP_ROUNDING_MARGIN, 0);
 
94
                bRight = (pDialog->container.iWindowPositionX + fTipWidth > pDialog->iAimedX);
 
95
        //g_print ("%d, %d, %d -> %d\n", pDialog->container.iWindowPositionX, (int) fTipWidth, pDialog->iAimedX, bRight);
 
96
        int iDeltaIconX;
 
97
        if (bRight)  // dialogue a droite de l'icone, pointe vers la gauche.
 
98
        {
 
99
                iDeltaIconX = MIN (0, pDialog->container.iWindowPositionX - pDialog->iAimedX);  // < 0
 
100
                //g_print ("iDeltaIconX right : %d / %d\n", iDeltaIconX, iWidth);
 
101
                cairo_rel_line_to (pCairoContext, -(fBaseWidth + iDeltaIconX - fTipWidth), 0);
 
102
                cairo_rel_curve_to (pCairoContext,
 
103
                        - CD_TIP_OUTER_MARGIN, 0,
 
104
                        - CD_TIP_OUTER_MARGIN, 0,
 
105
                        - fTipWidth, fTipHeight);
 
106
                cairo_rel_curve_to (pCairoContext,
 
107
                        CD_TIP_INNER_MARGIN, - fTipHeight,
 
108
                        CD_TIP_INNER_MARGIN, - fTipHeight,
 
109
                        0, - fTipHeight);
 
110
                cairo_rel_line_to (pCairoContext, iDeltaIconX, 0);
 
111
        }
 
112
        else  // dialogue a gauche de l'icone, pointe vers la droite.
 
113
        {
 
114
                iDeltaIconX = MAX (0, pDialog->container.iWindowPositionX + iWidth - pDialog->iAimedX);  // > 0
 
115
                //g_print ("iDeltaIconX left : %d / %d\n", iDeltaIconX, iWidth);
 
116
                cairo_rel_line_to (pCairoContext, - iDeltaIconX, 0);
 
117
                cairo_rel_curve_to (pCairoContext,
 
118
                        - (CD_TIP_INNER_MARGIN), 0,
 
119
                        - (CD_TIP_INNER_MARGIN), 0,
 
120
                        0, fTipHeight); 
 
121
                cairo_rel_curve_to (pCairoContext,
 
122
                        - (CD_TIP_INNER_MARGIN + CD_TIP_BASE), - fTipHeight,
 
123
                        - (CD_TIP_INNER_MARGIN + CD_TIP_BASE), - fTipHeight,
 
124
                        - fTipWidth, - fTipHeight);     
 
125
                cairo_rel_line_to (pCairoContext, - fBaseWidth + iDeltaIconX + fTipWidth, 0);
108
126
        }
109
127
 
110
 
        // Coin bas     gauche.
 
128
        // Coin bas gauche.
111
129
        cairo_rel_curve_to (pCairoContext,
112
130
                0, 0,
113
131
                -fRadius, 0,
114
 
                -fRadius, -sens * fRadius);
115
 
        cairo_rel_line_to (pCairoContext, 0, - sens * (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - (2 * fRadius + fLineWidth)));
116
 
        // Coin haut gauche.
 
132
                -fRadius, -fRadius);
 
133
        cairo_rel_line_to (pCairoContext, 0, - (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - fMargin));
 
134
        // Coin haut gauche.
117
135
        cairo_rel_curve_to (pCairoContext,
118
136
                0, 0,
119
 
                0, -sens * fRadius,
120
 
                fRadius, -sens * fRadius);
121
 
        if (fRadius     < 1)
 
137
                0, -fRadius,
 
138
                fRadius, -fRadius);
 
139
        if (fRadius < 1)
122
140
                cairo_close_path (pCairoContext);
123
141
 
124
 
        cairo_set_source_rgba (pCairoContext, myDialogs.fDialogColor[0], myDialogs.fDialogColor[1],     myDialogs.fDialogColor[2], myDialogs.fDialogColor[3]);
 
142
        cairo_set_source_rgba (pCairoContext, myDialogsParam.fDialogColor[0], myDialogsParam.fDialogColor[1],   myDialogsParam.fDialogColor[2], myDialogsParam.fDialogColor[3]);
125
143
        cairo_fill_preserve (pCairoContext);
126
144
 
127
145
        cairo_set_line_width (pCairoContext, fLineWidth);