~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/3.0.0.0rc1

« back to all changes in this revision

Viewing changes to dock-rendering/src/rendering-3D-plane.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne, Matthieu Baerts (matttbe), Julien Lavergne
  • Date: 2009-10-05 19:27:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091005192717-mvqvb395guktr401
Tags: 2.0.9-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream release (LP: #435590)
* debian/control: 
 - Remove ${shlibs:Depends} for integration plug-ins to avoid
   pulling shared libraries which are detected automatically.
 - Added curl as depends for cairo-dock-plug-ins
* debian/rules:
 - Add --enable-dnd2share and --enable-musicplayer to enable new applets.
 - Remove --enable-rhythmbox and --enable-nvidia to remove those applets,
   not maintained upstream.
* Update *.install to take all generated applets.

[ Julien Lavergne ]
* Adjust changelog with Daniel Holbach suggestions.
* cairo-dock-plug-ins.changelogs:  Install specific changelog for 2.0.9
* Build-depends on cairo-dock-dev (>= 2.0.9)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
* This file is a part of the Cairo-Dock project
3
 
*
4
 
* Copyright : (C) see the 'copyright' file.
5
 
* E-mail    : see the 'copyright' file.
6
 
*
7
 
* This program is free software; you can redistribute it and/or
8
 
* modify it under the terms of the GNU General Public License
9
 
* as published by the Free Software Foundation; either version 3
10
 
* of the License, or (at your option) any later version.
11
 
*
12
 
* This program is distributed in the hope that it will be useful,
13
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
* GNU General Public License for more details.
16
 
* You should have received a copy of the GNU General Public License
17
 
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
*/
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
 
#include <math.h>
29
 
#include <string.h>
30
 
#include <stdio.h>
31
 
#include <stdlib.h>
32
 
 
33
 
#include <gtk/gtk.h>
34
 
 
35
 
#include <cairo.h>
36
 
 
37
 
#include <rendering-commons.h>
38
 
#include "rendering-3D-plane.h"
39
 
 
40
 
extern int iVanishingPointY;
41
 
extern CDSpeparatorType my_iDrawSeparator3D;
42
 
extern cairo_surface_t *my_pFlatSeparatorSurface[2];
43
 
extern double my_fSeparatorColor[4];
44
 
extern GLuint my_iFlatSeparatorTexture;
45
 
 
46
 
void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
47
 
{
48
 
        pDock->pFirstDrawnElement = cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth, pDock->iScrollOffset);
49
 
        
50
 
        pDock->iMaxDockHeight = (int) ((1 + g_fAmplitude) * pDock->iMaxIconHeight + myIcons.fReflectSize * pDock->fRatio) + myLabels.iLabelSize + myBackground.iDockLineWidth + myBackground.iFrameMargin;
51
 
        
52
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
53
 
        
54
 
        double fInclinationOnHorizon = 0, fExtraWidth = 0;
55
 
        pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., fExtraWidth));
56
 
        fInclinationOnHorizon = 0.5 * pDock->iMaxDockWidth / iVanishingPointY;
57
 
        pDock->iDecorationsHeight = hi + (pDock->iMaxIconHeight + myBackground.iFrameMargin) / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
58
 
        fExtraWidth = cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclinationOnHorizon, myBackground.iDockRadius, myBackground.iDockLineWidth);
59
 
        //cd_debug ("iMaxDockWidth <- %d; fInclinationOnHorizon <- %.2f; fExtraWidth <- %.2f", pDock->iMaxDockWidth, fInclinationOnHorizon, fExtraWidth);
60
 
        
61
 
        pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., fExtraWidth));
62
 
        //cd_debug ("pDock->iMaxDockWidth <- %d", pDock->iMaxDockWidth);
63
 
        
64
 
        pDock->iDecorationsWidth = pDock->iMaxDockWidth;
65
 
        
66
 
        double fInclination = 0.5 * pDock->fFlatDockWidth / iVanishingPointY;
67
 
        double fExtraWidthMin = cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclination, myBackground.iDockRadius, myBackground.iDockLineWidth);
68
 
        pDock->iMinDockWidth = pDock->fFlatDockWidth + fExtraWidthMin;
69
 
        
70
 
        fInclination = 0.5 * pDock->iMinDockWidth / iVanishingPointY;
71
 
        fExtraWidthMin = cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclination, myBackground.iDockRadius, myBackground.iDockLineWidth);
72
 
        //pDock->iMinDockWidth = pDock->fFlatDockWidth + fExtraWidthMin;
73
 
        
74
 
        pDock->iMinDockHeight = myBackground.iDockLineWidth + myBackground.iFrameMargin + myIcons.fReflectSize * pDock->fRatio + pDock->iMaxIconHeight;
75
 
        
76
 
        if (my_pFlatSeparatorSurface[0] == NULL && (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR))
77
 
                cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
78
 
        pDock->iMinLeftMargin = fExtraWidth/2;
79
 
        pDock->iMinRightMargin = fExtraWidth/2;
80
 
        Icon *pFirstIcon = cairo_dock_get_first_icon (pDock->icons);
81
 
        if (pFirstIcon != NULL)
82
 
                pDock->iMaxRightMargin = fExtraWidth/2 + pFirstIcon->fWidth;
83
 
        Icon *pLastIcon = cairo_dock_get_last_icon (pDock->icons);
84
 
        if (pLastIcon != NULL)
85
 
                pDock->iMaxRightMargin = fExtraWidth/2 + pLastIcon->fWidth;
86
 
        
87
 
        pDock->inputArea.x = fExtraWidthMin/2;
88
 
        pDock->inputArea.y = 0;
89
 
        pDock->inputArea.width = pDock->iMinDockWidth - fExtraWidthMin;
90
 
        pDock->inputArea.height = pDock->iMinDockHeight;
91
 
}
92
 
 
93
 
void cd_rendering_calculate_construction_parameters_3D_plane (Icon *icon, int iCurrentWidth, int iCurrentHeight, int iMaxDockWidth, double fReflectionOffsetY)
94
 
{
95
 
        icon->fDrawX = icon->fX;
96
 
        icon->fDrawY = icon->fY + fReflectionOffsetY;
97
 
        icon->fWidthFactor = 1.;
98
 
        icon->fHeightFactor = 1.;
99
 
        ///icon->fDeltaYReflection = 0.;
100
 
        icon->fOrientation = 0.;
101
 
        if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= iCurrentWidth)
102
 
        {
103
 
                icon->fAlpha = 1;
104
 
        }
105
 
        else
106
 
        {
107
 
                icon->fAlpha = .25;
108
 
        }
109
 
}
110
 
 
111
 
 
112
 
static void cd_rendering_make_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bIncludeEdges, gboolean bBackGround)
113
 
{
114
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
115
 
        hi = pDock->iCurrentHeight - (icon->fDrawY + icon->fHeight * icon->fScale);
116
 
        double fLeftInclination = (icon->fDrawX - pDock->iCurrentWidth / 2) / iVanishingPointY;
117
 
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->iCurrentWidth / 2) / iVanishingPointY;
118
 
        
119
 
        double fHeight, fBigWidth, fLittleWidth;
120
 
        if (bIncludeEdges)
121
 
        {
122
 
                fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + myBackground.iDockLineWidth;
123
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
124
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
125
 
        }
126
 
        else
127
 
        {
128
 
                fHeight = pDock->iDecorationsHeight - myBackground.iDockLineWidth;
129
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
130
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
131
 
        }
132
 
        double fDeltaXLeft = fHeight * fLeftInclination;
133
 
        double fDeltaXRight = fHeight * fRightInclination;
134
 
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
135
 
        
136
 
        int sens;
137
 
        double fDockOffsetX, fDockOffsetY;
138
 
        if (pDock->bDirectionUp)
139
 
        {
140
 
                sens = 1;
141
 
                if (bIncludeEdges)
142
 
                        fDockOffsetY = pDock->iCurrentHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
143
 
                else
144
 
                        fDockOffsetY = pDock->iCurrentHeight - fHeight - myBackground.iDockLineWidth;
145
 
        }
146
 
        else
147
 
        {
148
 
                sens = -1;
149
 
                if (bIncludeEdges)
150
 
                        fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
151
 
                else
152
 
                        fDockOffsetY = fHeight + myBackground.iDockLineWidth;
153
 
        }
154
 
        if (bIncludeEdges)
155
 
                fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
156
 
        else
157
 
                fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
158
 
        
159
 
        if (pDock->bHorizontalDock)
160
 
        {
161
 
                cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY);  // coin haut gauche.
162
 
                cairo_move_to (pCairoContext, 0, 0);  // coin haut gauche.
163
 
                
164
 
                cairo_rel_line_to (pCairoContext, fLittleWidth, 0);
165
 
                cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
166
 
                cairo_rel_line_to (pCairoContext, - fBigWidth, 0);
167
 
                cairo_rel_line_to (pCairoContext, - fDeltaXLeft, - sens * fHeight);
168
 
                
169
 
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
170
 
                {
171
 
                        if (! pDock->bDirectionUp)
172
 
                                cairo_scale (pCairoContext, 1, -1);
173
 
                        cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_HORIZONTAL], MIN (0, (fHeight + hi) * fLeftInclination), 0);
174
 
                }
175
 
        }
176
 
        else
177
 
        {
178
 
                cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX);  // coin haut gauche.
179
 
                cairo_move_to (pCairoContext, 0, 0);  // coin haut gauche.
180
 
                
181
 
                cairo_rel_line_to (pCairoContext, 0, fLittleWidth);
182
 
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
183
 
                cairo_rel_line_to (pCairoContext, 0, - fBigWidth);
184
 
                cairo_rel_line_to (pCairoContext, - sens * fHeight, - fDeltaXLeft);
185
 
                
186
 
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
187
 
                {
188
 
                        if (! pDock->bDirectionUp)
189
 
                                cairo_scale (pCairoContext, -1, 1);
190
 
                        cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_VERTICAL], 0, MIN (0, (fHeight + hi) * fLeftInclination));
191
 
                }
192
 
        }
193
 
}
194
 
 
195
 
static void cd_rendering_draw_3D_separator_edge (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bBackGround)
196
 
{
197
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
198
 
        hi = pDock->iCurrentHeight - (icon->fDrawY + icon->fHeight * icon->fScale);
199
 
        double fLeftInclination = (icon->fDrawX - pDock->iCurrentWidth / 2) / iVanishingPointY;
200
 
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->iCurrentWidth / 2) / iVanishingPointY;
201
 
        
202
 
        double fHeight, fBigWidth, fLittleWidth;
203
 
        fHeight = (bBackGround ? pDock->iDecorationsHeight - hi - 0.5*myBackground.iDockLineWidth : hi + 1.5*myBackground.iDockLineWidth);
204
 
        fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
205
 
        fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
206
 
        
207
 
        double fDeltaXLeft = fHeight * fLeftInclination;
208
 
        double fDeltaXRight = fHeight * fRightInclination;
209
 
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
210
 
        
211
 
        int sens;
212
 
        double fDockOffsetX, fDockOffsetY;
213
 
        if (pDock->bDirectionUp)
214
 
        {
215
 
                sens = 1;
216
 
                fDockOffsetY =  (bBackGround ? 0.5*myBackground.iDockLineWidth : - 1.*myBackground.iDockLineWidth);
217
 
        }
218
 
        else
219
 
        {
220
 
                sens = -1;
221
 
                fDockOffsetY =  (bBackGround ? - 0.5*myBackground.iDockLineWidth : 1.*myBackground.iDockLineWidth);
222
 
        }
223
 
        fDockOffsetX = (bBackGround ? .5*myBackground.iDockLineWidth * fLeftInclination + 1.*fLeftInclination : - 0.5 * myBackground.iDockLineWidth * fLeftInclination);
224
 
        //fDockOffsetX = -.5*myBackground.iDockLineWidth;
225
 
        
226
 
        if (pDock->bHorizontalDock)
227
 
        {
228
 
                cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY);  // coin haut droit.
229
 
                
230
 
                cairo_move_to (pCairoContext, fLittleWidth, 0);
231
 
                cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
232
 
                
233
 
                cairo_move_to (pCairoContext, 0, 0);
234
 
                cairo_rel_line_to (pCairoContext, fDeltaXLeft, sens * fHeight);
235
 
        }
236
 
        else
237
 
        {
238
 
                cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX);  // coin haut droit.
239
 
                
240
 
                cairo_move_to (pCairoContext, 0, fLittleWidth);
241
 
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
242
 
                
243
 
                cairo_move_to (pCairoContext, 0, 0);
244
 
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXLeft);
245
 
        }
246
 
}
247
 
 
248
 
 
249
 
static void cd_rendering_draw_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
250
 
{
251
 
        cd_rendering_make_3D_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR), bBackGround);
252
 
        
253
 
        if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
254
 
        {
255
 
                cairo_set_operator (pCairoContext, CAIRO_OPERATOR_DEST_OUT);
256
 
                cairo_set_source_rgba (pCairoContext, 0.0, 0.0, 0.0, 1.0);
257
 
                cairo_fill (pCairoContext);
258
 
                
259
 
                if (myBackground.iDockLineWidth != 0)
260
 
                {
261
 
                        cd_rendering_draw_3D_separator_edge (icon, pCairoContext, pDock, bBackGround);
262
 
                        
263
 
                        cairo_set_operator (pCairoContext, CAIRO_OPERATOR_OVER);
264
 
                        cairo_set_line_width (pCairoContext, myBackground.iDockLineWidth);
265
 
                        cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
266
 
                        cairo_stroke (pCairoContext);
267
 
                }
268
 
        }
269
 
        else
270
 
        {
271
 
                cairo_fill (pCairoContext);
272
 
        }
273
 
}
274
 
 
275
 
 
276
 
void cd_rendering_render_3D_plane (cairo_t *pCairoContext, CairoDock *pDock)
277
 
{
278
 
        //\____________________ On trace le cadre.
279
 
        double fLineWidth = myBackground.iDockLineWidth;
280
 
        double fMargin = myBackground.iFrameMargin;
281
 
        double fRadius = (pDock->iDecorationsHeight + fLineWidth - 2 * myBackground.iDockRadius > 0 ? myBackground.iDockRadius : (pDock->iDecorationsHeight + fLineWidth) / 2 - 1);
282
 
        double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
283
 
        
284
 
        int sens;
285
 
        double fDockOffsetX, fDockOffsetY;  // Offset du coin haut gauche du cadre.
286
 
        Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
287
 
        fDockOffsetX = (pFirstIcon != NULL ? pFirstIcon->fDrawX + 0 - fMargin : fRadius + fLineWidth / 2);
288
 
        if (pDock->bDirectionUp)
289
 
        {
290
 
                sens = 1;
291
 
                fDockOffsetY = pDock->iCurrentHeight - pDock->iDecorationsHeight - 1.5 * fLineWidth;
292
 
        }
293
 
        else
294
 
        {
295
 
                sens = -1;
296
 
                fDockOffsetY = pDock->iDecorationsHeight + 1.5 * fLineWidth;
297
 
        }
298
 
        
299
 
        cairo_save (pCairoContext);
300
 
        
301
 
        double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
302
 
        double fDeltaXTrapeze = cairo_dock_draw_frame (pCairoContext, fRadius, fLineWidth, fDockWidth, pDock->iDecorationsHeight, fDockOffsetX, fDockOffsetY, sens, fInclinationOnHorizon, pDock->bHorizontalDock);  // fLineWidth
303
 
        
304
 
        //\____________________ On dessine les decorations dedans.
305
 
        fDockOffsetY = (pDock->bDirectionUp ? pDock->iCurrentHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
306
 
        cairo_dock_render_decorations_in_frame (pCairoContext, pDock, fDockOffsetY, fDockOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
307
 
        
308
 
        //\____________________ On dessine le cadre.
309
 
        if (fLineWidth > 0)
310
 
        {
311
 
                cairo_set_line_width (pCairoContext, fLineWidth);
312
 
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
313
 
                cairo_stroke (pCairoContext);
314
 
        }
315
 
        else
316
 
                cairo_new_path (pCairoContext);
317
 
        
318
 
        /// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
319
 
        
320
 
        
321
 
        cairo_restore (pCairoContext);
322
 
        
323
 
        //\____________________ On dessine la ficelle qui les joint.
324
 
        if (myIcons.iStringLineWidth > 0)
325
 
                cairo_dock_draw_string (pCairoContext, pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
326
 
        
327
 
        //\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
328
 
        GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
329
 
        if (pFirstDrawnElement == NULL)
330
 
                return;
331
 
                
332
 
        double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
333
 
        
334
 
        Icon *icon;
335
 
        GList *ic = pFirstDrawnElement;
336
 
        if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
337
 
        {
338
 
                cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
339
 
                do
340
 
                {
341
 
                        icon = ic->data;
342
 
                        
343
 
                        if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
344
 
                        {
345
 
                                cairo_save (pCairoContext);
346
 
                                cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, TRUE);
347
 
                                cairo_restore (pCairoContext);
348
 
                        }
349
 
                        
350
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
351
 
                } while (ic != pFirstDrawnElement);
352
 
                
353
 
                do
354
 
                {
355
 
                        icon = ic->data;
356
 
                        
357
 
                        if (icon->acFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
358
 
                        {
359
 
                                cairo_save (pCairoContext);
360
 
                                cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
361
 
                                cairo_restore (pCairoContext);
362
 
                        }
363
 
                        
364
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
365
 
                } while (ic != pFirstDrawnElement);
366
 
                
367
 
                if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
368
 
                {
369
 
                        do
370
 
                        {
371
 
                                icon = ic->data;
372
 
                                
373
 
                                if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
374
 
                                {
375
 
                                        cairo_save (pCairoContext);
376
 
                                        cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, FALSE);
377
 
                                        cairo_restore (pCairoContext);
378
 
                                }
379
 
                                
380
 
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
381
 
                        } while (ic != pFirstDrawnElement);
382
 
                }
383
 
        }
384
 
        else
385
 
        {
386
 
                do
387
 
                {
388
 
                        icon = ic->data;
389
 
                        
390
 
                        cairo_save (pCairoContext);
391
 
                        cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
392
 
                        cairo_restore (pCairoContext);
393
 
                        
394
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
395
 
                } while (ic != pFirstDrawnElement);
396
 
        }
397
 
}
398
 
 
399
 
static gboolean _cd_separator_is_impacted (Icon *icon, CairoDock *pDock, double fXMin, double fXMax, gboolean bBackGround, gboolean bIncludeEdges)
400
 
{
401
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
402
 
        hi = pDock->iCurrentHeight - (icon->fDrawY + icon->fHeight * icon->fScale);
403
 
        double fLeftInclination = fabs (icon->fDrawX - pDock->iCurrentWidth / 2) / iVanishingPointY;
404
 
        double fRightInclination = fabs (icon->fDrawX + icon->fWidth * icon->fScale - pDock->iCurrentWidth / 2) / iVanishingPointY;
405
 
        
406
 
        double fHeight, fBigWidth, fLittleWidth;
407
 
        if (bIncludeEdges)
408
 
        {
409
 
                fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + (bIncludeEdges ? myBackground.iDockLineWidth : 0);
410
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
411
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
412
 
        }
413
 
        else
414
 
        {
415
 
                fHeight = pDock->iDecorationsHeight;
416
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
417
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
418
 
        }
419
 
        double fDeltaXLeft = fHeight * fLeftInclination;
420
 
        double fDeltaXRight = fHeight * fRightInclination;
421
 
        double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
422
 
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
423
 
        
424
 
        int sens;
425
 
        double fDockOffsetX, fDockOffsetY;
426
 
        if (pDock->bDirectionUp)
427
 
        {
428
 
                sens = 1;
429
 
                if (bIncludeEdges)
430
 
                        fDockOffsetY =  pDock->iCurrentHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
431
 
                else
432
 
                        fDockOffsetY =  pDock->iCurrentHeight - fHeight;
433
 
        }
434
 
        else
435
 
        {
436
 
                sens = -1;
437
 
                if (bIncludeEdges)
438
 
                        fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
439
 
                else
440
 
                        fDockOffsetY = fHeight;
441
 
        }
442
 
        
443
 
        if (bIncludeEdges)
444
 
                        fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
445
 
                else
446
 
                        fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
447
 
        double fXLeft, fXRight;
448
 
        if (icon->fDrawX + icon->fWidth * icon->fScale / 2 > pDock->iCurrentWidth / 2)  // on est a droite.
449
 
        {
450
 
                if (bIncludeEdges)
451
 
                {
452
 
                        if (bBackGround)
453
 
                        {
454
 
                                fXLeft = icon->fDrawX - fHeight * fLeftInclination;
455
 
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
456
 
                        }
457
 
                        else
458
 
                        {
459
 
                                fXLeft = icon->fDrawX;
460
 
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
461
 
                        }
462
 
                }
463
 
                else
464
 
                {
465
 
                        fXLeft = icon->fDrawX - (fHeight - hi) * fLeftInclination;
466
 
                        fXRight = icon->fDrawX + icon->fWidth * icon->fScale + hi * fRightInclination;
467
 
                }
468
 
        }
469
 
        else  // a gauche.
470
 
        {
471
 
                if (bIncludeEdges)
472
 
                {
473
 
                        if (bBackGround)
474
 
                        {
475
 
                                fXLeft = icon->fDrawX;
476
 
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
477
 
                        }
478
 
                        else
479
 
                        {
480
 
                                fXLeft = icon->fDrawX - fHeight * fLeftInclination;
481
 
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
482
 
                        }
483
 
                }
484
 
                else
485
 
                {
486
 
                        fXLeft = icon->fDrawX - hi * fLeftInclination;
487
 
                        fXRight = icon->fDrawX + icon->fWidth * icon->fScale +(fHeight - hi) * fRightInclination;
488
 
                }
489
 
        }
490
 
        
491
 
        return (fXLeft <= fXMax && floor (fXRight) > fXMin);
492
 
}
493
 
 
494
 
void cd_rendering_render_optimized_3D_plane (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
495
 
{
496
 
        //g_print ("%s ((%d;%d) x (%d;%d) / (%dx%d))\n", __func__, pArea->x, pArea->y, pArea->width, pArea->height, pDock->iCurrentWidth, pDock->iCurrentHeight);
497
 
        double fLineWidth = myBackground.iDockLineWidth;
498
 
        double fMargin = myBackground.iFrameMargin;
499
 
        int iWidth = pDock->iCurrentWidth;
500
 
        int iHeight = pDock->iCurrentHeight;
501
 
        
502
 
        //\____________________ On dessine les decorations du fond sur la portion de fenetre.
503
 
        cairo_save (pCairoContext);
504
 
        
505
 
        double fDockOffsetX, fDockOffsetY;
506
 
        if (pDock->bHorizontalDock)
507
 
        {
508
 
                fDockOffsetX = pArea->x;
509
 
                fDockOffsetY = (pDock->bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
510
 
        }
511
 
        else
512
 
        {
513
 
                fDockOffsetX = (pDock->bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
514
 
                fDockOffsetY = pArea->y;
515
 
        }
516
 
        
517
 
        //cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
518
 
        if (pDock->bHorizontalDock)
519
 
                cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pArea->width, pDock->iDecorationsHeight);
520
 
        else
521
 
                cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pDock->iDecorationsHeight, pArea->height);
522
 
        
523
 
        double fRadius = MIN (myBackground.iDockRadius, (pDock->iDecorationsHeight + myBackground.iDockLineWidth) / 2 - 1);
524
 
        Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
525
 
        double fDeltaXTrapeze=0.;
526
 
        double fOffsetX = (pFirstIcon != NULL ? pFirstIcon->fX + 0 - fMargin : fRadius + fLineWidth / 2);
527
 
        double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
528
 
        if (g_pBackgroundSurface != NULL)
529
 
        {
530
 
                double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
531
 
                double fRadius = myBackground.iDockRadius;
532
 
                if (2*fRadius > pDock->iDecorationsHeight + fLineWidth)
533
 
                        fRadius = (pDock->iDecorationsHeight + fLineWidth) / 2 - 1;
534
 
                double fDeltaXForLoop = fInclinationOnHorizon * (pDock->iDecorationsHeight + fLineWidth - (myBackground.bRoundedBottomCorner ? 2 : 1) * fRadius);
535
 
                
536
 
                double cosa = 1. / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
537
 
                fDeltaXTrapeze = fDeltaXForLoop + fRadius * cosa;
538
 
                Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
539
 
                fOffsetX = (pFirstIcon != NULL ? pFirstIcon->fX + 0 - fMargin : fRadius + fLineWidth / 2);
540
 
                
541
 
                double sina = cosa * fInclinationOnHorizon;
542
 
                fDeltaXTrapeze = fInclinationOnHorizon * (pDock->iDecorationsHeight - (FALSE ? 2 : 1-sina) * fRadius) + fRadius * (FALSE ? 1 : cosa);
543
 
        }
544
 
        cairo_dock_render_decorations_in_frame (pCairoContext, pDock, pDock->bHorizontalDock ? fDockOffsetY : fDockOffsetX, fOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
545
 
        
546
 
        
547
 
        //\____________________ On dessine la partie du cadre qui va bien.
548
 
        cairo_new_path (pCairoContext);
549
 
        
550
 
        if (pDock->bHorizontalDock)
551
 
        {
552
 
                cairo_set_line_width (pCairoContext, fLineWidth);
553
 
                cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY - 0.5*fLineWidth);
554
 
                cairo_rel_line_to (pCairoContext, pArea->width, 0);
555
 
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
556
 
                cairo_stroke (pCairoContext);
557
 
                
558
 
                cairo_new_path (pCairoContext);
559
 
                cairo_move_to (pCairoContext, fDockOffsetX, (pDock->bDirectionUp ? iHeight - 0.5*fLineWidth : pDock->iDecorationsHeight + 1.5 * fLineWidth));
560
 
                cairo_rel_line_to (pCairoContext, pArea->width, 0);
561
 
        }
562
 
        else
563
 
        {
564
 
                cairo_move_to (pCairoContext, fDockOffsetX - .5*fLineWidth, fDockOffsetY);
565
 
                cairo_rel_line_to (pCairoContext, 0, pArea->height);
566
 
                cairo_set_line_width (pCairoContext, fLineWidth);
567
 
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
568
 
                cairo_stroke (pCairoContext);
569
 
                
570
 
                cairo_new_path (pCairoContext);
571
 
                cairo_move_to (pCairoContext, (pDock->bDirectionUp ? iHeight - fLineWidth / 2 : pDock->iDecorationsHeight + 1.5 * fLineWidth), fDockOffsetY);
572
 
                cairo_rel_line_to (pCairoContext, 0, pArea->height);
573
 
        }
574
 
        cairo_set_line_width (pCairoContext, fLineWidth);
575
 
        cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
576
 
        cairo_stroke (pCairoContext);
577
 
        
578
 
        cairo_restore (pCairoContext);
579
 
        
580
 
        //\____________________ On dessine les icones impactees.
581
 
        GList *pFirstDrawnElement = (pDock->pFirstDrawnElement != NULL ? pDock->pFirstDrawnElement : pDock->icons);
582
 
        if (pFirstDrawnElement != NULL)
583
 
        {
584
 
                double fXMin = (pDock->bHorizontalDock ? pArea->x : pArea->y), fXMax = (pDock->bHorizontalDock ? pArea->x + pArea->width : pArea->y + pArea->height);
585
 
                double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
586
 
                double fXLeft, fXRight;
587
 
                Icon *icon;
588
 
                GList *ic = pFirstDrawnElement;
589
 
                
590
 
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
591
 
                {
592
 
                        cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
593
 
                        do
594
 
                        {
595
 
                                icon = ic->data;
596
 
                                
597
 
                                if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->acFileName == NULL)
598
 
                                {
599
 
                                        if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
600
 
                                        {
601
 
                                                cairo_save (pCairoContext);
602
 
                                                cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, TRUE);
603
 
                                                cairo_restore (pCairoContext);
604
 
                                        }
605
 
                                }
606
 
                                
607
 
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
608
 
                        } while (ic != pFirstDrawnElement);
609
 
                        
610
 
                        do
611
 
                        {
612
 
                                icon = ic->data;
613
 
                                if (! CAIRO_DOCK_IS_SEPARATOR (icon) || icon->acFileName != NULL)
614
 
                                {
615
 
                                        fXLeft = icon->fDrawX + icon->fScale + 1;
616
 
                                        fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
617
 
                                        
618
 
                                        if (fXLeft <= fXMax && floor (fXRight) > fXMin)
619
 
                                        {
620
 
                                                if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->iCurrentWidth)
621
 
                                                        icon->fAlpha = 1;
622
 
                                                else
623
 
                                                        icon->fAlpha = .25;
624
 
                                                
625
 
                                                cairo_save (pCairoContext);
626
 
                                                
627
 
                                                cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
628
 
                                                
629
 
                                                cairo_restore (pCairoContext);
630
 
                                        }
631
 
                                }
632
 
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
633
 
                        } while (ic != pFirstDrawnElement);
634
 
                        
635
 
                        if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
636
 
                        {
637
 
                                do
638
 
                                {
639
 
                                        icon = ic->data;
640
 
                                        
641
 
                                        if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->acFileName == NULL)
642
 
                                        {
643
 
                                                if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
644
 
                                                {
645
 
                                                        cairo_save (pCairoContext);
646
 
                                                        cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, FALSE);
647
 
                                                        cairo_restore (pCairoContext);
648
 
                                                }
649
 
                                        }
650
 
                                        
651
 
                                        ic = cairo_dock_get_next_element (ic, pDock->icons);
652
 
                                } while (ic != pFirstDrawnElement);
653
 
                        }
654
 
                }
655
 
                else
656
 
                {
657
 
                        do
658
 
                        {
659
 
                                icon = ic->data;
660
 
                                fXLeft = icon->fDrawX + icon->fScale + 1;
661
 
                                fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
662
 
                                
663
 
                                if (fXLeft <= fXMax && floor (fXRight) > fXMin)
664
 
                                {
665
 
                                        if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->iCurrentWidth)
666
 
                                                icon->fAlpha = 1;
667
 
                                        else
668
 
                                                icon->fAlpha = .25;
669
 
                                        
670
 
                                        cairo_save (pCairoContext);
671
 
                                        
672
 
                                        cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
673
 
                                        
674
 
                                        cairo_restore (pCairoContext);
675
 
                                }
676
 
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
677
 
                        } while (ic != pFirstDrawnElement);
678
 
                }
679
 
        }
680
 
}
681
 
 
682
 
 
683
 
Icon *cd_rendering_calculate_icons_3D_plane (CairoDock *pDock)
684
 
{
685
 
        Icon *pPointedIcon = cairo_dock_apply_wave_effect (pDock);
686
 
        
687
 
        //\____________________ On calcule les position/etirements/alpha des icones.
688
 
        double fReflectionOffsetY = (pDock->bDirectionUp ? -1 : 1) * myIcons.fReflectSize * pDock->fRatio;
689
 
        Icon* icon;
690
 
        GList* ic;
691
 
        for (ic = pDock->icons; ic != NULL; ic = ic->next)
692
 
        {
693
 
                icon = ic->data;
694
 
                cd_rendering_calculate_construction_parameters_3D_plane (icon, pDock->iCurrentWidth, pDock->iCurrentHeight, pDock->iMaxDockWidth, fReflectionOffsetY);
695
 
        }
696
 
        
697
 
        cairo_dock_check_if_mouse_inside_linear (pDock);
698
 
        
699
 
        cairo_dock_check_can_drop_linear (pDock);
700
 
        
701
 
        return pPointedIcon;
702
 
}
703
 
 
704
 
 
705
 
void cd_rendering_render_3D_plane_opengl (CairoDock *pDock)
706
 
{
707
 
        //\____________________ On genere le cadre.
708
 
        double fLineWidth = myBackground.iDockLineWidth;
709
 
        double fMargin = myBackground.iFrameMargin;
710
 
        double fRadius = (pDock->iDecorationsHeight + fLineWidth - 2 * myBackground.iDockRadius > 0 ? myBackground.iDockRadius : (pDock->iDecorationsHeight + fLineWidth) / 2 - 1);
711
 
        double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
712
 
        
713
 
        double fDockOffsetX, fDockOffsetY;  // Offset du coin haut gauche du cadre.
714
 
        Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
715
 
        fDockOffsetX = (pFirstIcon != NULL ? pFirstIcon->fDrawX + 0 - fMargin : fRadius + fLineWidth / 2);
716
 
        
717
 
        if ((pDock->bHorizontalDock && ! pDock->bDirectionUp) || (! pDock->bHorizontalDock && pDock->bDirectionUp))
718
 
                fDockOffsetY = pDock->iCurrentHeight - .5 * fLineWidth;
719
 
        else
720
 
                fDockOffsetY = pDock->iDecorationsHeight + 1.5 * fLineWidth;
721
 
        
722
 
        double fFrameHeight = pDock->iDecorationsHeight + fLineWidth/* - 2 * fRadius*/;
723
 
        double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
724
 
        double fDeltaXTrapeze;
725
 
        int iNbVertex;
726
 
        GLfloat *pVertexTab = cairo_dock_generate_trapeze_path (fDockWidth - (myBackground.bRoundedBottomCorner ? 0*fLineWidth : 2*fLineWidth/fInclinationOnHorizon), fFrameHeight, fRadius, myBackground.bRoundedBottomCorner, fInclinationOnHorizon, &fDeltaXTrapeze, &iNbVertex);
727
 
        
728
 
        if (! pDock->bHorizontalDock)
729
 
                fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX + fDeltaXTrapeze;
730
 
        else
731
 
                fDockOffsetX = fDockOffsetX-fDeltaXTrapeze;
732
 
        
733
 
        //\____________________ On dessine les decorations dedans.
734
 
        //fDockOffsetY = (!pDock->bDirectionUp ? pDock->iCurrentHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
735
 
        glPushMatrix ();
736
 
        cairo_dock_draw_frame_background_opengl (g_iBackgroundTexture, fDockWidth+2*fDeltaXTrapeze, fFrameHeight, fDockOffsetX, fDockOffsetY, pVertexTab, iNbVertex, pDock->bHorizontalDock, pDock->bDirectionUp, pDock->fDecorationsOffsetX);
737
 
        
738
 
        //\____________________ On dessine le cadre.
739
 
        if (fLineWidth != 0)
740
 
                cairo_dock_draw_current_path_opengl (fLineWidth, myBackground.fLineColor, iNbVertex);
741
 
        glPopMatrix ();
742
 
        
743
 
        /// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
744
 
        
745
 
        
746
 
        //\____________________ On dessine la ficelle qui les joint.
747
 
        if (myIcons.iStringLineWidth > 0)
748
 
                cairo_dock_draw_string_opengl (pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
749
 
        
750
 
        //\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
751
 
        GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
752
 
        if (pFirstDrawnElement == NULL)
753
 
                return;
754
 
                
755
 
        double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
756
 
        Icon *icon;
757
 
        GList *ic = pFirstDrawnElement;
758
 
        
759
 
        glLoadIdentity ();
760
 
        if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
761
 
        {
762
 
                do
763
 
                {
764
 
                        icon = ic->data;
765
 
                        
766
 
                        if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
767
 
                        {
768
 
                                glPushMatrix ();
769
 
                                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
770
 
                                        cd_rendering_draw_flat_separator_opengl (icon, pDock);
771
 
                                else
772
 
                                        cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, NULL, NULL);
773
 
                                glPopMatrix ();
774
 
                        }
775
 
                        
776
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
777
 
                } while (ic != pFirstDrawnElement);
778
 
                
779
 
                do
780
 
                {
781
 
                        icon = ic->data;
782
 
                        
783
 
                        if (icon->acFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
784
 
                        {
785
 
                                glPushMatrix ();
786
 
                                cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
787
 
                                glPopMatrix ();
788
 
                        }
789
 
                        
790
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
791
 
                } while (ic != pFirstDrawnElement);
792
 
                
793
 
                if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
794
 
                {
795
 
                        do
796
 
                        {
797
 
                                icon = ic->data;
798
 
                                
799
 
                                if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
800
 
                                {
801
 
                                        glPushMatrix ();
802
 
                                        cd_rendering_draw_physical_separator_opengl (icon, pDock, FALSE, NULL, NULL);
803
 
                                        glPopMatrix ();
804
 
                                }
805
 
                                
806
 
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
807
 
                        } while (ic != pFirstDrawnElement);
808
 
                }
809
 
        }
810
 
        else
811
 
        {
812
 
                do
813
 
                {
814
 
                        icon = ic->data;
815
 
                        
816
 
                        glPushMatrix ();
817
 
                        
818
 
                        cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
819
 
                        
820
 
                        glPopMatrix ();
821
 
                        
822
 
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
823
 
                } while (ic != pFirstDrawnElement);
824
 
        }
825
 
}
826
 
 
827
 
 
828
 
void cd_rendering_register_3D_plane_renderer (const gchar *cRendererName)
829
 
{
830
 
        CairoDockRenderer *pRenderer = g_new0 (CairoDockRenderer, 1);
831
 
        pRenderer->cReadmeFilePath = g_strdup_printf ("%s/readme-3D-plane-view", MY_APPLET_SHARE_DATA_DIR);
832
 
        pRenderer->cPreviewFilePath = g_strdup_printf ("%s/preview-3D-plane.jpg", MY_APPLET_SHARE_DATA_DIR);
833
 
        pRenderer->calculate_max_dock_size = cd_rendering_calculate_max_dock_size_3D_plane;
834
 
        pRenderer->calculate_icons = cd_rendering_calculate_icons_3D_plane;
835
 
        pRenderer->render = cd_rendering_render_3D_plane;
836
 
        pRenderer->render_optimized = cd_rendering_render_optimized_3D_plane;
837
 
        pRenderer->render_opengl = cd_rendering_render_3D_plane_opengl;
838
 
        pRenderer->set_subdock_position = cairo_dock_set_subdock_position_linear;
839
 
        pRenderer->bUseReflect = TRUE;
840
 
        pRenderer->cDisplayedName = D_ (cRendererName);
841
 
        
842
 
        cairo_dock_register_renderer (cRendererName, pRenderer);
843
 
}
844
 
 
845
 
 
846
 
void cd_rendering_draw_flat_separator_opengl (Icon *icon, CairoDock *pDock)
847
 
{
848
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
849
 
        double fLeftInclination = (icon->fDrawX - pDock->iCurrentWidth / 2) / iVanishingPointY;
850
 
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->iCurrentWidth / 2) / iVanishingPointY;
851
 
        
852
 
        double fHeight, fBigWidth, fLittleWidth;
853
 
        
854
 
        fHeight = pDock->iDecorationsHeight;
855
 
        fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
856
 
        fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
857
 
        
858
 
        double fDeltaXLeft = fHeight * fLeftInclination;
859
 
        double fDeltaXRight = fHeight * fRightInclination;
860
 
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
861
 
        
862
 
        double fDockOffsetX, fDockOffsetY;
863
 
        fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
864
 
        fDockOffsetY = fHeight + myBackground.iDockLineWidth;
865
 
        
866
 
        glEnable (GL_BLEND);
867
 
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
868
 
        glColor4f (1., 1., 1., 1.);
869
 
        
870
 
        glEnable (GL_TEXTURE_2D);
871
 
        glBindTexture (GL_TEXTURE_2D, my_iFlatSeparatorTexture);
872
 
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
873
 
        
874
 
        glPolygonMode (GL_FRONT, GL_FILL);
875
 
        
876
 
        if (pDock->bHorizontalDock)
877
 
        {
878
 
                if (! pDock->bDirectionUp)
879
 
                        fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
880
 
                
881
 
                glTranslatef (fDockOffsetX, fDockOffsetY, 0.);  // coin haut gauche.
882
 
                if (! pDock->bDirectionUp)
883
 
                        glScalef (1., -1., 1.);
884
 
        }
885
 
        else
886
 
        {
887
 
                if (pDock->bDirectionUp)
888
 
                        fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
889
 
                fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX;
890
 
                
891
 
                glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
892
 
                glRotatef (-90., 0., 0., 1.);
893
 
                if (pDock->bDirectionUp)
894
 
                        glScalef (1., -1., 1.);
895
 
        }
896
 
        
897
 
        glBegin(GL_QUADS);
898
 
        glTexCoord2f(0., 0.);
899
 
        glVertex3f(0., 0., 0.);  // Bottom Left Of The Texture and Quad
900
 
        glTexCoord2f(1., 0.);
901
 
        glVertex3f(fLittleWidth, 0., 0.);  // Bottom Right Of The Texture and Quad
902
 
        glTexCoord2f(1., 1.);
903
 
        glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);  // Top Right Of The Texture and Quad
904
 
        glTexCoord2f(0., 1.);
905
 
        glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);  // Top Left Of The Texture and Quad
906
 
        glEnd();
907
 
        
908
 
        glDisable (GL_TEXTURE_2D);
909
 
        glDisable (GL_BLEND);
910
 
}
911
 
 
912
 
void cd_rendering_draw_physical_separator_opengl (Icon *icon, CairoDock *pDock, gboolean bBackGround, Icon *prev_icon, Icon *next_icon)
913
 
{
914
 
        if (prev_icon == NULL)
915
 
                prev_icon = icon;
916
 
        if (next_icon == NULL)
917
 
                next_icon = icon;
918
 
        double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
919
 
        hi = pDock->iCurrentHeight - (icon->fDrawY + icon->fHeight * icon->fScale);
920
 
        double fLeftInclination = (icon->fDrawX - pDock->iCurrentWidth / 2) / iVanishingPointY;
921
 
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->iCurrentWidth / 2) / iVanishingPointY;
922
 
        
923
 
        double fHeight, fBigWidth, fLittleWidth;
924
 
        if (bBackGround)
925
 
        {
926
 
                fHeight = pDock->iDecorationsHeight + myBackground.iDockLineWidth - hi;
927
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0);
928
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0 - fHeight);
929
 
        }
930
 
        else
931
 
        {
932
 
                fHeight = hi + myBackground.iDockLineWidth;
933
 
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
934
 
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
935
 
        }
936
 
        double fDeltaXLeft = fHeight * fLeftInclination;
937
 
        double fDeltaXRight = fHeight * fRightInclination;
938
 
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
939
 
        
940
 
        double fDockOffsetX, fDockOffsetY;
941
 
        if (bBackGround)
942
 
        {
943
 
                fDockOffsetX = icon->fDrawX - fHeight * fLeftInclination;
944
 
                fDockOffsetY = pDock->iDecorationsHeight + 2*myBackground.iDockLineWidth;
945
 
        }
946
 
        else
947
 
        {
948
 
                fDockOffsetX = icon->fDrawX;
949
 
                fDockOffsetY = fHeight;
950
 
        }
951
 
        
952
 
        glEnable (GL_BLEND);
953
 
        glBlendFunc (GL_ONE, GL_ZERO);
954
 
        glColor4f (0., 0., 0., 0.);
955
 
        
956
 
        glPolygonMode (GL_FRONT, GL_FILL);
957
 
        
958
 
        if (pDock->bHorizontalDock)
959
 
        {
960
 
                if (! pDock->bDirectionUp)
961
 
                        fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
962
 
                
963
 
                glTranslatef (fDockOffsetX, fDockOffsetY, 0.);  // coin haut gauche.
964
 
                if (! pDock->bDirectionUp)
965
 
                        glScalef (1., -1., 1.);
966
 
        }
967
 
        else
968
 
        {
969
 
                if (pDock->bDirectionUp)
970
 
                        fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
971
 
                fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX;
972
 
                
973
 
                glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
974
 
                glRotatef (-90., 0., 0., 1.);
975
 
                if (pDock->bDirectionUp)
976
 
                        glScalef (1., -1., 1.);
977
 
        }
978
 
        
979
 
        glBegin(GL_QUADS);
980
 
        glVertex3f(0., 0., 0.);  // Bottom Left Of The Texture and Quad
981
 
        glVertex3f(fLittleWidth, 0., 0.);  // Bottom Right Of The Texture and Quad
982
 
        glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);  // Top Right Of The Texture and Quad
983
 
        glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);  // Top Left Of The Texture and Quad
984
 
        glEnd();
985
 
        
986
 
        if (myBackground.iDockLineWidth != 0)
987
 
        {
988
 
                glPolygonMode (GL_FRONT, GL_LINE);
989
 
                glEnable (GL_LINE_SMOOTH);
990
 
                glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
991
 
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
992
 
                
993
 
                glLineWidth (myBackground.iDockLineWidth);
994
 
                glColor4f (myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
995
 
                
996
 
                glBegin(GL_LINES);
997
 
                glVertex3f(fLittleWidth, 0., 0.);
998
 
                glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);
999
 
                glEnd();
1000
 
                
1001
 
                glBegin(GL_LINES);
1002
 
                glVertex3f(0., 0., 0.);
1003
 
                glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);
1004
 
                glEnd();
1005
 
                
1006
 
                glDisable(GL_LINE_SMOOTH);
1007
 
        }
1008
 
        
1009
 
        glDisable (GL_BLEND);
1010
 
}
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
#include <math.h>
 
21
#include <string.h>
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
 
 
25
#include <gtk/gtk.h>
 
26
 
 
27
#include <cairo.h>
 
28
 
 
29
#include "rendering-commons.h"
 
30
#include "rendering-3D-plane.h"
 
31
 
 
32
extern int iVanishingPointY;
 
33
extern CDSpeparatorType my_iDrawSeparator3D;
 
34
extern cairo_surface_t *my_pFlatSeparatorSurface[2];
 
35
extern double my_fSeparatorColor[4];
 
36
extern GLuint my_iFlatSeparatorTexture;
 
37
 
 
38
#define _define_parameters(hi, h0, H, l, r, gamma, h, w, dw)\
 
39
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;\
 
40
        double h0max = (1 + g_fAmplitude) * pDock->iMaxIconHeight + MAX (myLabels.iLabelSize, myBackground.iFrameMargin + myBackground.iDockLineWidth);\
 
41
        double h0 = pDock->iMaxIconHeight;\
 
42
        double H = iVanishingPointY;\
 
43
        double l = myBackground.iDockLineWidth;\
 
44
        double r = MIN (myBackground.iDockRadius, (hi + h0) / 2);\
 
45
        double gamma = 0, h, w, dw = 0
 
46
 
 
47
void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
 
48
{
 
49
        pDock->pFirstDrawnElement = cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth, pDock->iScrollOffset);
 
50
        
 
51
        //pDock->iMaxDockHeight = (int) ((1 + g_fAmplitude) * pDock->iMaxIconHeight + myIcons.fReflectSize * pDock->container.fRatio) + myLabels.iLabelSize + myBackground.iDockLineWidth + myBackground.iFrameMargin;
 
52
        
 
53
        _define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
 
54
        pDock->iMaxDockHeight = (int) (hi + h0max + l);
 
55
        // 1ere estimation.
 
56
        // w
 
57
        w = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., 2 * dw));  // pDock->iMaxDockWidth
 
58
        // -> gamma
 
59
        gamma = w / 2 / H;
 
60
        // -> h
 
61
        h = hi + h0 / (1 + gamma);  // en fait, sqrt (1 + gamma * gamma), mais on simplifie pour diminuer l'ordre de 2. pDock->iDecorationsHeight
 
62
        // -> dw
 
63
        dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);  // en fait, h*gamma + r*(1-sin)/cos, or (1-sin)/cos <= 1, on majore pour simplifier. on aurait r + gamma * (h - 2 * r) si on utilisait des cercles au lieu de courbes de Bezier.
 
64
        
 
65
        /*double Ws = w+2*dw;
 
66
        double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
 
67
        double a = H + hi;
 
68
        double b = H + hi + h0 - W / 2;
 
69
        double c = - W / 2;
 
70
        double g = (-b + sqrt (b * b - 4 * a * c)) / 2  / a;
 
71
        g_print ("gamma : %f (=) %f\n", gamma, g);*/
 
72
        
 
73
        double Ws = cairo_dock_get_max_authorized_dock_width (pDock);
 
74
        if (cairo_dock_is_extended_dock (pDock) && w + 2 * dw < Ws)  // alors on etend.
 
75
        {
 
76
                double extra = Ws - w;
 
77
                pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., extra));  // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
 
78
                double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
 
79
                double a = H + hi;
 
80
                double b = H + hi + h0 - W / 2;
 
81
                double c = - W / 2;
 
82
                gamma = (-b + sqrt (b * b - 4 * a * c)) / 2  / a;
 
83
                //g_print ("mode etendu : pDock->iMaxDockWidth : %d, gamma = %f\n", pDock->iMaxDockWidth, gamma);
 
84
                h = hi + h0 / (1 + gamma);
 
85
        }
 
86
        else  // rien d'autre a faire
 
87
        {
 
88
                pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., 2 * dw));  // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
 
89
        }
 
90
        pDock->iDecorationsHeight = h;
 
91
        //g_print ("h : %.2f -> %d\n", h, pDock->iDecorationsHeight);
 
92
        
 
93
        pDock->iDecorationsWidth = pDock->iMaxDockWidth;
 
94
        
 
95
        // taille min.
 
96
        pDock->iMinDockHeight = myBackground.iDockLineWidth + myBackground.iFrameMargin + myIcons.fReflectSize * pDock->container.fRatio + pDock->iMaxIconHeight;
 
97
        
 
98
        double gamma_min = pDock->fFlatDockWidth / 2 / H;
 
99
        double dw_min = h * gamma_min + r + (l+(r==0)*2)*sqrt(1+gamma_min*gamma_min);
 
100
        //cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclination, myBackground.iDockRadius, myBackground.iDockLineWidth);
 
101
        
 
102
        if (cairo_dock_is_extended_dock (pDock))  // mode panel etendu.
 
103
        {
 
104
                //g_print ("extended\n");
 
105
                pDock->iMinDockWidth = cairo_dock_get_max_authorized_dock_width (pDock);
 
106
        }
 
107
        else
 
108
        {
 
109
                pDock->iMinDockWidth = pDock->fFlatDockWidth + 2 * dw_min;
 
110
        }
 
111
        //g_print ("pDock->iMinDockWidth : %d\n", pDock->iMinDockWidth);
 
112
        
 
113
        // input shape
 
114
        pDock->inputArea.x = (pDock->iMinDockWidth - pDock->fFlatDockWidth) / 2;
 
115
        pDock->inputArea.y = 0;
 
116
        pDock->inputArea.width = pDock->fFlatDockWidth;
 
117
        pDock->inputArea.height = pDock->iMinDockHeight;
 
118
        //g_print ("input area : %d + %d\n", pDock->inputArea.x, pDock->inputArea.width);
 
119
        
 
120
        // on charge les separateurs plat.
 
121
        if (my_pFlatSeparatorSurface[0] == NULL && my_iFlatSeparatorTexture == 0 && my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
 
122
                cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
 
123
}
 
124
 
 
125
void cd_rendering_calculate_construction_parameters_3D_plane (Icon *icon, int iWidth, int iHeight, int iMaxDockWidth, double fReflectionOffsetY)
 
126
{
 
127
        icon->fDrawX = icon->fX;
 
128
        icon->fDrawY = icon->fY + fReflectionOffsetY;
 
129
        icon->fWidthFactor = 1.;
 
130
        icon->fHeightFactor = 1.;
 
131
        ///icon->fDeltaYReflection = 0.;
 
132
        icon->fOrientation = 0.;
 
133
        //if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= iWidth)
 
134
        {
 
135
                icon->fAlpha = 1;
 
136
        }
 
137
        /*else
 
138
        {
 
139
                icon->fAlpha = .25;
 
140
        }*/
 
141
}
 
142
 
 
143
 
 
144
static void cd_rendering_make_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bIncludeEdges, gboolean bBackGround)
 
145
{
 
146
        gboolean bDirectionUp = pDock->container.bDirectionUp;
 
147
        gboolean bIsHorizontal = pDock->container.bIsHorizontal;
 
148
        bDirectionUp = TRUE;
 
149
        bIsHorizontal = TRUE;
 
150
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
 
151
        hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
 
152
        double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
 
153
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
 
154
        
 
155
        double fHeight, fBigWidth, fLittleWidth;
 
156
        if (bIncludeEdges)
 
157
        {
 
158
                fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + myBackground.iDockLineWidth;
 
159
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
 
160
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
 
161
        }
 
162
        else
 
163
        {
 
164
                fHeight = pDock->iDecorationsHeight - myBackground.iDockLineWidth;
 
165
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
 
166
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
 
167
        }
 
168
        double fDeltaXLeft = fHeight * fLeftInclination;
 
169
        double fDeltaXRight = fHeight * fRightInclination;
 
170
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
 
171
        
 
172
        int sens;
 
173
        double fDockOffsetX, fDockOffsetY;
 
174
        if (bDirectionUp)
 
175
        {
 
176
                sens = 1;
 
177
                if (bIncludeEdges)
 
178
                        fDockOffsetY = pDock->container.iHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
 
179
                else
 
180
                        fDockOffsetY = pDock->container.iHeight - fHeight - myBackground.iDockLineWidth;
 
181
        }
 
182
        else
 
183
        {
 
184
                sens = -1;
 
185
                if (bIncludeEdges)
 
186
                        fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
 
187
                else
 
188
                        fDockOffsetY = fHeight + myBackground.iDockLineWidth;
 
189
        }
 
190
        if (bIncludeEdges)
 
191
                fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
 
192
        else
 
193
                fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
 
194
        
 
195
        if (bIsHorizontal)
 
196
        {
 
197
                cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY);  // coin haut gauche.
 
198
                cairo_move_to (pCairoContext, 0, 0);  // coin haut gauche.
 
199
                
 
200
                cairo_rel_line_to (pCairoContext, fLittleWidth, 0);
 
201
                cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
 
202
                cairo_rel_line_to (pCairoContext, - fBigWidth, 0);
 
203
                cairo_rel_line_to (pCairoContext, - fDeltaXLeft, - sens * fHeight);
 
204
                
 
205
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
 
206
                {
 
207
                        if (! bDirectionUp)
 
208
                                cairo_scale (pCairoContext, 1, -1);
 
209
                        cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_HORIZONTAL], MIN (0, (fHeight + hi) * fLeftInclination), 0);
 
210
                }
 
211
        }
 
212
        else
 
213
        {
 
214
                cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX);  // coin haut gauche.
 
215
                cairo_move_to (pCairoContext, 0, 0);  // coin haut gauche.
 
216
                
 
217
                cairo_rel_line_to (pCairoContext, 0, fLittleWidth);
 
218
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
 
219
                cairo_rel_line_to (pCairoContext, 0, - fBigWidth);
 
220
                cairo_rel_line_to (pCairoContext, - sens * fHeight, - fDeltaXLeft);
 
221
                
 
222
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
 
223
                {
 
224
                        if (! bDirectionUp)
 
225
                                cairo_scale (pCairoContext, -1, 1);
 
226
                        cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_VERTICAL], 0, MIN (0, (fHeight + hi) * fLeftInclination));
 
227
                }
 
228
        }
 
229
}
 
230
 
 
231
static void cd_rendering_draw_3D_separator_edge (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bBackGround)
 
232
{
 
233
        gboolean bDirectionUp = pDock->container.bDirectionUp;
 
234
        gboolean bIsHorizontal = pDock->container.bIsHorizontal;
 
235
        bDirectionUp = TRUE;
 
236
        bIsHorizontal = TRUE;
 
237
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
 
238
        hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
 
239
        double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
 
240
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
 
241
        
 
242
        double fHeight, fBigWidth, fLittleWidth;
 
243
        fHeight = (bBackGround ? pDock->iDecorationsHeight - hi - 0.5*myBackground.iDockLineWidth : hi + 1.5*myBackground.iDockLineWidth);
 
244
        fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
 
245
        fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
 
246
        
 
247
        double fDeltaXLeft = fHeight * fLeftInclination;
 
248
        double fDeltaXRight = fHeight * fRightInclination;
 
249
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
 
250
        
 
251
        int sens;
 
252
        double fDockOffsetX, fDockOffsetY;
 
253
        if (bDirectionUp)
 
254
        {
 
255
                sens = 1;
 
256
                fDockOffsetY =  (bBackGround ? 0.5*myBackground.iDockLineWidth : - 1.*myBackground.iDockLineWidth);
 
257
        }
 
258
        else
 
259
        {
 
260
                sens = -1;
 
261
                fDockOffsetY =  (bBackGround ? - 0.5*myBackground.iDockLineWidth : 1.*myBackground.iDockLineWidth);
 
262
        }
 
263
        fDockOffsetX = (bBackGround ? .5*myBackground.iDockLineWidth * fLeftInclination + 1.*fLeftInclination : - 0.5 * myBackground.iDockLineWidth * fLeftInclination);
 
264
        //fDockOffsetX = -.5*myBackground.iDockLineWidth;
 
265
        
 
266
        if (bIsHorizontal)
 
267
        {
 
268
                cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY);  // coin haut droit.
 
269
                
 
270
                cairo_move_to (pCairoContext, fLittleWidth, 0);
 
271
                cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
 
272
                
 
273
                cairo_move_to (pCairoContext, 0, 0);
 
274
                cairo_rel_line_to (pCairoContext, fDeltaXLeft, sens * fHeight);
 
275
        }
 
276
        else
 
277
        {
 
278
                cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX);  // coin haut droit.
 
279
                
 
280
                cairo_move_to (pCairoContext, 0, fLittleWidth);
 
281
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
 
282
                
 
283
                cairo_move_to (pCairoContext, 0, 0);
 
284
                cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXLeft);
 
285
        }
 
286
}
 
287
 
 
288
 
 
289
static void cd_rendering_draw_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
 
290
{
 
291
        if (pDock->container.bIsHorizontal)
 
292
        {
 
293
                if (! pDock->container.bDirectionUp)
 
294
                {
 
295
                        cairo_translate (pCairoContext, 0., pDock->container.iHeight);
 
296
                        cairo_scale (pCairoContext, 1., -1.);
 
297
                }
 
298
        }
 
299
        else
 
300
        {
 
301
                if (pDock->container.bDirectionUp)
 
302
                {
 
303
                        
 
304
                }
 
305
                else
 
306
                {
 
307
                        
 
308
                }
 
309
        }
 
310
        cd_rendering_make_3D_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR), bBackGround);
 
311
        
 
312
        if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
313
        {
 
314
                cairo_set_operator (pCairoContext, CAIRO_OPERATOR_DEST_OUT);
 
315
                cairo_set_source_rgba (pCairoContext, 0.0, 0.0, 0.0, 1.0);
 
316
                cairo_fill (pCairoContext);
 
317
                
 
318
                if (myBackground.iDockLineWidth != 0)
 
319
                {
 
320
                        cd_rendering_draw_3D_separator_edge (icon, pCairoContext, pDock, bBackGround);
 
321
                        
 
322
                        cairo_set_operator (pCairoContext, CAIRO_OPERATOR_OVER);
 
323
                        cairo_set_line_width (pCairoContext, myBackground.iDockLineWidth);
 
324
                        cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
325
                        cairo_stroke (pCairoContext);
 
326
                }
 
327
        }
 
328
        else
 
329
        {
 
330
                cairo_fill (pCairoContext);
 
331
        }
 
332
}
 
333
 
 
334
 
 
335
void cd_rendering_render_3D_plane (cairo_t *pCairoContext, CairoDock *pDock)
 
336
{
 
337
        _define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
 
338
        h = pDock->iDecorationsHeight;
 
339
        if (h < 2 * r)
 
340
                r = h / 2;
 
341
        
 
342
        //\____________________ On definit la position du cadre.
 
343
        double dx, dy;  // position du coin haut gauche du cadre.
 
344
        if (cairo_dock_is_extended_dock (pDock))  // mode panel etendu.
 
345
        {
 
346
                double Ws = pDock->container.iWidth;
 
347
                gamma = Ws / 2 / H;
 
348
                double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
 
349
                double a = H + hi;
 
350
                double b = H + hi + h0 - W / 2;
 
351
                double c = - W / 2;
 
352
                gamma = (-b + sqrt (b * b - 4 * a * c)) / 2  / a;
 
353
                h = hi + h0 / (1 + gamma);
 
354
                //g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
 
355
                w = 2 * H * gamma;
 
356
                dw = (Ws - w) / 2;
 
357
                //g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
 
358
                dx = dw;
 
359
        }
 
360
        else
 
361
        {
 
362
                w = cairo_dock_get_current_dock_width_linear (pDock);
 
363
                gamma = w / 2 / H;
 
364
                dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
 
365
                h = pDock->iDecorationsHeight;
 
366
                Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
 
367
                dx = (pFirstIcon != NULL ? pFirstIcon->fX - 0*myBackground.iFrameMargin : r);
 
368
        }
 
369
        
 
370
        int sens;
 
371
        if (pDock->container.bDirectionUp)
 
372
        {
 
373
                sens = 1;
 
374
                dy = pDock->container.iHeight - pDock->iDecorationsHeight - 1.5 * l;
 
375
        }
 
376
        else
 
377
        {
 
378
                sens = -1;
 
379
                dy = pDock->iDecorationsHeight + 1.5 * l;
 
380
        }
 
381
        
 
382
        //\____________________ On trace le cadre.
 
383
        cairo_save (pCairoContext);
 
384
        
 
385
        double fDeltaXTrapeze = cairo_dock_draw_frame (pCairoContext, r, l, w, pDock->iDecorationsHeight, dx, dy, sens, gamma, pDock->container.bIsHorizontal);
 
386
        
 
387
        //\____________________ On dessine les decorations dedans.
 
388
        dy = (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iDecorationsHeight - l : l);
 
389
        cairo_dock_render_decorations_in_frame (pCairoContext, pDock, dy, dx-fDeltaXTrapeze, w+2*fDeltaXTrapeze);
 
390
        
 
391
        //\____________________ On dessine le cadre.
 
392
        if (l > 0)
 
393
        {
 
394
                cairo_set_line_width (pCairoContext, l);
 
395
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
396
                cairo_stroke (pCairoContext);
 
397
        }
 
398
        else
 
399
                cairo_new_path (pCairoContext);
 
400
        
 
401
        /// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
 
402
        
 
403
        
 
404
        cairo_restore (pCairoContext);
 
405
        
 
406
        //\____________________ On dessine la ficelle qui les joint.
 
407
        if (myIcons.iStringLineWidth > 0)
 
408
                cairo_dock_draw_string (pCairoContext, pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
 
409
        
 
410
        //\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
 
411
        GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
 
412
        if (pFirstDrawnElement == NULL)
 
413
                return;
 
414
                
 
415
        double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
 
416
        
 
417
        Icon *icon;
 
418
        GList *ic = pFirstDrawnElement;
 
419
        if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
420
        {
 
421
                cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
 
422
                do
 
423
                {
 
424
                        icon = ic->data;
 
425
                        
 
426
                        if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
 
427
                        {
 
428
                                cairo_save (pCairoContext);
 
429
                                cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
 
430
                                cairo_restore (pCairoContext);
 
431
                        }
 
432
                        
 
433
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
434
                } while (ic != pFirstDrawnElement);
 
435
                
 
436
                do
 
437
                {
 
438
                        icon = ic->data;
 
439
                        
 
440
                        if (icon->cFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
 
441
                        {
 
442
                                cairo_save (pCairoContext);
 
443
                                cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
 
444
                                cairo_restore (pCairoContext);
 
445
                        }
 
446
                        
 
447
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
448
                } while (ic != pFirstDrawnElement);
 
449
                
 
450
                if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
451
                {
 
452
                        do
 
453
                        {
 
454
                                icon = ic->data;
 
455
                                
 
456
                                if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
 
457
                                {
 
458
                                        cairo_save (pCairoContext);
 
459
                                        cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
 
460
                                        cairo_restore (pCairoContext);
 
461
                                }
 
462
                                
 
463
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
 
464
                        } while (ic != pFirstDrawnElement);
 
465
                }
 
466
        }
 
467
        else
 
468
        {
 
469
                do
 
470
                {
 
471
                        icon = ic->data;
 
472
                        
 
473
                        cairo_save (pCairoContext);
 
474
                        cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
 
475
                        cairo_restore (pCairoContext);
 
476
                        
 
477
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
478
                } while (ic != pFirstDrawnElement);
 
479
        }
 
480
}
 
481
 
 
482
static gboolean _cd_separator_is_impacted (Icon *icon, CairoDock *pDock, double fXMin, double fXMax, gboolean bBackGround, gboolean bIncludeEdges)
 
483
{
 
484
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
 
485
        hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
 
486
        double fLeftInclination = fabs (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
 
487
        double fRightInclination = fabs (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
 
488
        
 
489
        double fHeight, fBigWidth, fLittleWidth;
 
490
        if (bIncludeEdges)
 
491
        {
 
492
                fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + (bIncludeEdges ? myBackground.iDockLineWidth : 0);
 
493
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
 
494
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
 
495
        }
 
496
        else
 
497
        {
 
498
                fHeight = pDock->iDecorationsHeight;
 
499
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
 
500
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
 
501
        }
 
502
        double fDeltaXLeft = fHeight * fLeftInclination;
 
503
        double fDeltaXRight = fHeight * fRightInclination;
 
504
        double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
 
505
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
 
506
        
 
507
        int sens;
 
508
        double fDockOffsetX, fDockOffsetY;
 
509
        if (pDock->container.bDirectionUp)
 
510
        {
 
511
                sens = 1;
 
512
                if (bIncludeEdges)
 
513
                        fDockOffsetY =  pDock->container.iHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
 
514
                else
 
515
                        fDockOffsetY =  pDock->container.iHeight - fHeight;
 
516
        }
 
517
        else
 
518
        {
 
519
                sens = -1;
 
520
                if (bIncludeEdges)
 
521
                        fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
 
522
                else
 
523
                        fDockOffsetY = fHeight;
 
524
        }
 
525
        
 
526
        if (bIncludeEdges)
 
527
                        fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
 
528
                else
 
529
                        fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
 
530
        double fXLeft, fXRight;
 
531
        if (icon->fDrawX + icon->fWidth * icon->fScale / 2 > pDock->container.iWidth / 2)  // on est a droite.
 
532
        {
 
533
                if (bIncludeEdges)
 
534
                {
 
535
                        if (bBackGround)
 
536
                        {
 
537
                                fXLeft = icon->fDrawX - fHeight * fLeftInclination;
 
538
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
 
539
                        }
 
540
                        else
 
541
                        {
 
542
                                fXLeft = icon->fDrawX;
 
543
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
 
544
                        }
 
545
                }
 
546
                else
 
547
                {
 
548
                        fXLeft = icon->fDrawX - (fHeight - hi) * fLeftInclination;
 
549
                        fXRight = icon->fDrawX + icon->fWidth * icon->fScale + hi * fRightInclination;
 
550
                }
 
551
        }
 
552
        else  // a gauche.
 
553
        {
 
554
                if (bIncludeEdges)
 
555
                {
 
556
                        if (bBackGround)
 
557
                        {
 
558
                                fXLeft = icon->fDrawX;
 
559
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
 
560
                        }
 
561
                        else
 
562
                        {
 
563
                                fXLeft = icon->fDrawX - fHeight * fLeftInclination;
 
564
                                fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
 
565
                        }
 
566
                }
 
567
                else
 
568
                {
 
569
                        fXLeft = icon->fDrawX - hi * fLeftInclination;
 
570
                        fXRight = icon->fDrawX + icon->fWidth * icon->fScale +(fHeight - hi) * fRightInclination;
 
571
                }
 
572
        }
 
573
        
 
574
        return (fXLeft <= fXMax && floor (fXRight) > fXMin);
 
575
}
 
576
 
 
577
void cd_rendering_render_optimized_3D_plane (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
 
578
{
 
579
        //g_print ("%s ((%d;%d) x (%d;%d) / (%dx%d))\n", __func__, pArea->x, pArea->y, pArea->width, pArea->height, pDock->container.iWidth, pDock->container.iHeight);
 
580
        double fLineWidth = myBackground.iDockLineWidth;
 
581
        double fMargin = myBackground.iFrameMargin;
 
582
        int iWidth = pDock->container.iWidth;
 
583
        int iHeight = pDock->container.iHeight;
 
584
        
 
585
        //\____________________ On dessine les decorations du fond sur la portion de fenetre.
 
586
        cairo_save (pCairoContext);
 
587
        
 
588
        double fDockOffsetX, fDockOffsetY;
 
589
        if (pDock->container.bIsHorizontal)
 
590
        {
 
591
                fDockOffsetX = pArea->x;
 
592
                fDockOffsetY = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
 
593
        }
 
594
        else
 
595
        {
 
596
                fDockOffsetX = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
 
597
                fDockOffsetY = pArea->y;
 
598
        }
 
599
        
 
600
        //cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
 
601
        if (pDock->container.bIsHorizontal)
 
602
                cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pArea->width, pDock->iDecorationsHeight);
 
603
        else
 
604
                cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pDock->iDecorationsHeight, pArea->height);
 
605
        
 
606
        double fRadius = MIN (myBackground.iDockRadius, (pDock->iDecorationsHeight + myBackground.iDockLineWidth) / 2 - 1);
 
607
        double fDeltaXTrapeze=0.;
 
608
        double fOffsetX;
 
609
        if (cairo_dock_is_extended_dock (pDock))  // mode panel etendu.
 
610
        {
 
611
                fOffsetX = fRadius + fLineWidth / 2;
 
612
        }
 
613
        else
 
614
        {
 
615
                Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
 
616
                fOffsetX = (pFirstIcon != NULL ? pFirstIcon->fX - fMargin : fRadius + fLineWidth / 2);
 
617
        }
 
618
        double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
 
619
        if (g_pBackgroundSurface != NULL)
 
620
        {
 
621
                double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
 
622
                double fRadius = myBackground.iDockRadius;
 
623
                if (2*fRadius > pDock->iDecorationsHeight + fLineWidth)
 
624
                        fRadius = (pDock->iDecorationsHeight + fLineWidth) / 2 - 1;
 
625
                double fDeltaXForLoop = fInclinationOnHorizon * (pDock->iDecorationsHeight + fLineWidth - (myBackground.bRoundedBottomCorner ? 2 : 1) * fRadius);
 
626
                
 
627
                double cosa = 1. / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
 
628
                fDeltaXTrapeze = fDeltaXForLoop + fRadius * cosa;
 
629
                
 
630
                double sina = cosa * fInclinationOnHorizon;
 
631
                fDeltaXTrapeze = fInclinationOnHorizon * (pDock->iDecorationsHeight - (FALSE ? 2 : 1-sina) * fRadius) + fRadius * (FALSE ? 1 : cosa);
 
632
        }
 
633
        cairo_dock_render_decorations_in_frame (pCairoContext, pDock, pDock->container.bIsHorizontal ? fDockOffsetY : fDockOffsetX, fOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
 
634
        
 
635
        
 
636
        //\____________________ On dessine la partie du cadre qui va bien.
 
637
        cairo_new_path (pCairoContext);
 
638
        
 
639
        if (pDock->container.bIsHorizontal)
 
640
        {
 
641
                cairo_set_line_width (pCairoContext, fLineWidth);
 
642
                cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY - 0.5*fLineWidth);
 
643
                cairo_rel_line_to (pCairoContext, pArea->width, 0);
 
644
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
645
                cairo_stroke (pCairoContext);
 
646
                
 
647
                cairo_new_path (pCairoContext);
 
648
                cairo_move_to (pCairoContext, fDockOffsetX, (pDock->container.bDirectionUp ? iHeight - 0.5*fLineWidth : pDock->iDecorationsHeight + 1.5 * fLineWidth));
 
649
                cairo_rel_line_to (pCairoContext, pArea->width, 0);
 
650
        }
 
651
        else
 
652
        {
 
653
                cairo_move_to (pCairoContext, fDockOffsetX - .5*fLineWidth, fDockOffsetY);
 
654
                cairo_rel_line_to (pCairoContext, 0, pArea->height);
 
655
                cairo_set_line_width (pCairoContext, fLineWidth);
 
656
                cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
657
                cairo_stroke (pCairoContext);
 
658
                
 
659
                cairo_new_path (pCairoContext);
 
660
                cairo_move_to (pCairoContext, (pDock->container.bDirectionUp ? iHeight - fLineWidth / 2 : pDock->iDecorationsHeight + 1.5 * fLineWidth), fDockOffsetY);
 
661
                cairo_rel_line_to (pCairoContext, 0, pArea->height);
 
662
        }
 
663
        cairo_set_line_width (pCairoContext, fLineWidth);
 
664
        cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
665
        cairo_stroke (pCairoContext);
 
666
        
 
667
        cairo_restore (pCairoContext);
 
668
        
 
669
        //\____________________ On dessine les icones impactees.
 
670
        GList *pFirstDrawnElement = (pDock->pFirstDrawnElement != NULL ? pDock->pFirstDrawnElement : pDock->icons);
 
671
        if (pFirstDrawnElement != NULL)
 
672
        {
 
673
                double fXMin = (pDock->container.bIsHorizontal ? pArea->x : pArea->y), fXMax = (pDock->container.bIsHorizontal ? pArea->x + pArea->width : pArea->y + pArea->height);
 
674
                double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
 
675
                double fXLeft, fXRight;
 
676
                Icon *icon;
 
677
                GList *ic = pFirstDrawnElement;
 
678
                
 
679
                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
680
                {
 
681
                        cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
 
682
                        do
 
683
                        {
 
684
                                icon = ic->data;
 
685
                                
 
686
                                if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
 
687
                                {
 
688
                                        if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
 
689
                                        {
 
690
                                                cairo_save (pCairoContext);
 
691
                                                cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
 
692
                                                cairo_restore (pCairoContext);
 
693
                                        }
 
694
                                }
 
695
                                
 
696
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
 
697
                        } while (ic != pFirstDrawnElement);
 
698
                        
 
699
                        do
 
700
                        {
 
701
                                icon = ic->data;
 
702
                                if (! CAIRO_DOCK_IS_SEPARATOR (icon) || icon->cFileName != NULL)
 
703
                                {
 
704
                                        fXLeft = icon->fDrawX + icon->fScale + 1;
 
705
                                        fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
 
706
                                        
 
707
                                        if (fXLeft <= fXMax && floor (fXRight) > fXMin)
 
708
                                        {
 
709
                                                //if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
 
710
                                                        icon->fAlpha = 1;
 
711
                                                //else
 
712
                                                //      icon->fAlpha = .25;
 
713
                                                
 
714
                                                cairo_save (pCairoContext);
 
715
                                                
 
716
                                                cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
 
717
                                                
 
718
                                                cairo_restore (pCairoContext);
 
719
                                        }
 
720
                                }
 
721
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
 
722
                        } while (ic != pFirstDrawnElement);
 
723
                        
 
724
                        if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
725
                        {
 
726
                                do
 
727
                                {
 
728
                                        icon = ic->data;
 
729
                                        
 
730
                                        if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
 
731
                                        {
 
732
                                                if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
 
733
                                                {
 
734
                                                        cairo_save (pCairoContext);
 
735
                                                        cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
 
736
                                                        cairo_restore (pCairoContext);
 
737
                                                }
 
738
                                        }
 
739
                                        
 
740
                                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
741
                                } while (ic != pFirstDrawnElement);
 
742
                        }
 
743
                }
 
744
                else
 
745
                {
 
746
                        do
 
747
                        {
 
748
                                icon = ic->data;
 
749
                                fXLeft = icon->fDrawX + icon->fScale + 1;
 
750
                                fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
 
751
                                
 
752
                                if (fXLeft <= fXMax && floor (fXRight) > fXMin)
 
753
                                {
 
754
                                        //if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
 
755
                                                icon->fAlpha = 1;
 
756
                                        //else
 
757
                                        //      icon->fAlpha = .25;
 
758
                                        
 
759
                                        cairo_save (pCairoContext);
 
760
                                        
 
761
                                        cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
 
762
                                        
 
763
                                        cairo_restore (pCairoContext);
 
764
                                }
 
765
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
 
766
                        } while (ic != pFirstDrawnElement);
 
767
                }
 
768
        }
 
769
}
 
770
 
 
771
 
 
772
Icon *cd_rendering_calculate_icons_3D_plane (CairoDock *pDock)
 
773
{
 
774
        Icon *pPointedIcon = cairo_dock_apply_wave_effect (pDock);
 
775
        
 
776
        //\____________________ On calcule les position/etirements/alpha des icones.
 
777
        double fReflectionOffsetY = (pDock->container.bDirectionUp ? -1 : 1) * myIcons.fReflectSize * pDock->container.fRatio;
 
778
        Icon* icon;
 
779
        GList* ic;
 
780
        for (ic = pDock->icons; ic != NULL; ic = ic->next)
 
781
        {
 
782
                icon = ic->data;
 
783
                cd_rendering_calculate_construction_parameters_3D_plane (icon, pDock->container.iWidth, pDock->container.iHeight, pDock->iMaxDockWidth, fReflectionOffsetY);
 
784
        }
 
785
        
 
786
        cairo_dock_check_if_mouse_inside_linear (pDock);
 
787
        
 
788
        cairo_dock_check_can_drop_linear (pDock);
 
789
        
 
790
        return pPointedIcon;
 
791
}
 
792
 
 
793
 
 
794
void cd_rendering_render_3D_plane_opengl (CairoDock *pDock)
 
795
{
 
796
        //\____________________ On genere le cadre.
 
797
        _define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
 
798
        h = pDock->iDecorationsHeight;
 
799
        if (h < 2 * r)
 
800
                r = h / 2;
 
801
        
 
802
        double dx, dy;
 
803
        if (cairo_dock_is_extended_dock (pDock))  // mode panel etendu.
 
804
        {
 
805
                double Ws = pDock->container.iWidth;
 
806
                double W = Ws - 2 * r;
 
807
                double a = H + hi;
 
808
                double b = H + hi + h0 - W / 2;
 
809
                double c = - W / 2;
 
810
                gamma = (-b + sqrt (b * b - 4 * a * c)) / 2  / a;
 
811
                h = hi + h0 / (1 + gamma);
 
812
                //g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
 
813
                w = 2 * H * gamma;
 
814
                dw = (Ws - w) / 2;
 
815
                //g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
 
816
                dx =dw;
 
817
        }
 
818
        else
 
819
        {
 
820
                w = cairo_dock_get_current_dock_width_linear (pDock);
 
821
                gamma = w / 2 / H;
 
822
                dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
 
823
                h = pDock->iDecorationsHeight;
 
824
                Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
 
825
                dx = (pFirstIcon != NULL ? pFirstIcon->fX - myBackground.iFrameMargin : r);
 
826
        }
 
827
        
 
828
        //\____________________ On trace le cadre.
 
829
        int sens;
 
830
        if ((pDock->container.bDirectionUp && pDock->container.bIsHorizontal) || (!pDock->container.bDirectionUp && !pDock->container.bIsHorizontal))
 
831
        {
 
832
                sens = 1;
 
833
                //dy = pDock->container.iHeight - pDock->iDecorationsHeight - 1.5 * l;
 
834
                dy = pDock->iDecorationsHeight + 1.5*l;
 
835
        }
 
836
        else
 
837
        {
 
838
                sens = -1;
 
839
                //dy = pDock->iDecorationsHeight + 1.5 * l;
 
840
                dy = pDock->container.iHeight - .5 * l;
 
841
        }
 
842
        
 
843
        int iNbVertex;
 
844
        double fDeltaXTrapeze;
 
845
        GLfloat *pVertexTab = cairo_dock_generate_trapeze_path (w - (myBackground.bRoundedBottomCorner ? 0 : 2*l/gamma), h+l, r, myBackground.bRoundedBottomCorner, gamma, &fDeltaXTrapeze, &iNbVertex);
 
846
        
 
847
        if (! pDock->container.bIsHorizontal)
 
848
                dx = pDock->container.iWidth - dx + fDeltaXTrapeze;
 
849
        else
 
850
                dx = dx - fDeltaXTrapeze;
 
851
        
 
852
        //\____________________ On dessine les decorations dedans.
 
853
        //fDockOffsetY = (!pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
 
854
        glPushMatrix ();
 
855
        cairo_dock_draw_frame_background_opengl (g_iBackgroundTexture, w+2*fDeltaXTrapeze, h+l, dx, dy, pVertexTab, iNbVertex, pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX);
 
856
        
 
857
        //\____________________ On dessine le cadre.
 
858
        if (l != 0)
 
859
                cairo_dock_draw_current_path_opengl (l, myBackground.fLineColor, iNbVertex);
 
860
        glPopMatrix ();
 
861
        
 
862
        /// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
 
863
        
 
864
        
 
865
        //\____________________ On dessine la ficelle qui les joint.
 
866
        if (myIcons.iStringLineWidth > 0)
 
867
                cairo_dock_draw_string_opengl (pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
 
868
        
 
869
        //\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
 
870
        GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
 
871
        if (pFirstDrawnElement == NULL)
 
872
                return;
 
873
                
 
874
        double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
 
875
        Icon *icon;
 
876
        GList *ic = pFirstDrawnElement;
 
877
        
 
878
        glLoadIdentity ();
 
879
        if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
880
        {
 
881
                do
 
882
                {
 
883
                        icon = ic->data;
 
884
                        
 
885
                        if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
 
886
                        {
 
887
                                glPushMatrix ();
 
888
                                if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
 
889
                                        cd_rendering_draw_flat_separator_opengl (icon, pDock);
 
890
                                else
 
891
                                        cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, NULL, NULL);
 
892
                                glPopMatrix ();
 
893
                        }
 
894
                        
 
895
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
896
                } while (ic != pFirstDrawnElement);
 
897
                
 
898
                do
 
899
                {
 
900
                        icon = ic->data;
 
901
                        
 
902
                        if (icon->cFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
 
903
                        {
 
904
                                glPushMatrix ();
 
905
                                cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
 
906
                                glPopMatrix ();
 
907
                        }
 
908
                        
 
909
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
910
                } while (ic != pFirstDrawnElement);
 
911
                
 
912
                if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
 
913
                {
 
914
                        do
 
915
                        {
 
916
                                icon = ic->data;
 
917
                                
 
918
                                if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
 
919
                                {
 
920
                                        glPushMatrix ();
 
921
                                        cd_rendering_draw_physical_separator_opengl (icon, pDock, FALSE, NULL, NULL);
 
922
                                        glPopMatrix ();
 
923
                                }
 
924
                                
 
925
                                ic = cairo_dock_get_next_element (ic, pDock->icons);
 
926
                        } while (ic != pFirstDrawnElement);
 
927
                }
 
928
        }
 
929
        else
 
930
        {
 
931
                do
 
932
                {
 
933
                        icon = ic->data;
 
934
                        
 
935
                        glPushMatrix ();
 
936
                        
 
937
                        cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
 
938
                        
 
939
                        glPopMatrix ();
 
940
                        
 
941
                        ic = cairo_dock_get_next_element (ic, pDock->icons);
 
942
                } while (ic != pFirstDrawnElement);
 
943
        }
 
944
}
 
945
 
 
946
 
 
947
void cd_rendering_draw_flat_separator_opengl (Icon *icon, CairoDock *pDock)
 
948
{
 
949
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
 
950
        double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
 
951
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
 
952
        
 
953
        double fHeight = pDock->iDecorationsHeight;
 
954
        double fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
 
955
        double fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
 
956
        
 
957
        double fDeltaXLeft = fHeight * fLeftInclination;
 
958
        double fDeltaXRight = fHeight * fRightInclination;
 
959
        //g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
 
960
        
 
961
        double fDockOffsetX, fDockOffsetY;
 
962
        fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
 
963
        fDockOffsetY = fHeight + myBackground.iDockLineWidth;
 
964
        
 
965
        glEnable (GL_BLEND);
 
966
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
967
        glColor4f (1., 1., 1., 1.);
 
968
        
 
969
        glEnable (GL_TEXTURE_2D);
 
970
        glBindTexture (GL_TEXTURE_2D, my_iFlatSeparatorTexture);
 
971
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
972
        
 
973
        glPolygonMode (GL_FRONT, GL_FILL);
 
974
        
 
975
        if (pDock->container.bIsHorizontal)
 
976
        {
 
977
                if (! pDock->container.bDirectionUp)
 
978
                        fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
 
979
                
 
980
                glTranslatef (fDockOffsetX, fDockOffsetY, 0.);  // coin haut gauche.
 
981
                if (! pDock->container.bDirectionUp)
 
982
                        glScalef (1., -1., 1.);
 
983
        }
 
984
        else
 
985
        {
 
986
                if (pDock->container.bDirectionUp)
 
987
                        fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
 
988
                fDockOffsetX = pDock->container.iWidth - fDockOffsetX;
 
989
                
 
990
                glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
 
991
                glRotatef (-90., 0., 0., 1.);
 
992
                if (pDock->container.bDirectionUp)
 
993
                        glScalef (1., -1., 1.);
 
994
        }
 
995
        
 
996
        glBegin(GL_QUADS);
 
997
        glTexCoord2f(0., 0.);
 
998
        glVertex3f(0., 0., 0.);  // Bottom Left Of The Texture and Quad
 
999
        glTexCoord2f(1., 0.);
 
1000
        glVertex3f(fLittleWidth, 0., 0.);  // Bottom Right Of The Texture and Quad
 
1001
        glTexCoord2f(1., 1.);
 
1002
        glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);  // Top Right Of The Texture and Quad
 
1003
        glTexCoord2f(0., 1.);
 
1004
        glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);  // Top Left Of The Texture and Quad
 
1005
        glEnd();
 
1006
        
 
1007
        glDisable (GL_TEXTURE_2D);
 
1008
        glDisable (GL_BLEND);
 
1009
}
 
1010
 
 
1011
void cd_rendering_draw_physical_separator_opengl (Icon *icon, CairoDock *pDock, gboolean bBackGround, Icon *prev_icon, Icon *next_icon)
 
1012
{
 
1013
        if (prev_icon == NULL)
 
1014
                prev_icon = icon;
 
1015
        if (next_icon == NULL)
 
1016
                next_icon = icon;
 
1017
        double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
 
1018
        hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
 
1019
        //g_print ("%s : hi = %.2f/%.2f\n", icon->cName, myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin, pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale));
 
1020
        double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
 
1021
        double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
 
1022
        
 
1023
        double fHeight, fBigWidth, fLittleWidth;
 
1024
        if (bBackGround)
 
1025
        {
 
1026
                fHeight = pDock->iDecorationsHeight + myBackground.iDockLineWidth - hi;
 
1027
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0);
 
1028
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0 - fHeight);
 
1029
        }
 
1030
        else
 
1031
        {
 
1032
                fHeight = hi + myBackground.iDockLineWidth;
 
1033
                fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
 
1034
                fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
 
1035
        }
 
1036
        double fDeltaXLeft = fHeight * fLeftInclination;
 
1037
        double fDeltaXRight = fHeight * fRightInclination;
 
1038
        
 
1039
        double fDockOffsetX, fDockOffsetY;
 
1040
        if (bBackGround)
 
1041
        {
 
1042
                fDockOffsetX = icon->fDrawX - fHeight * fLeftInclination;
 
1043
                fDockOffsetY = pDock->iDecorationsHeight + 2*myBackground.iDockLineWidth;
 
1044
        }
 
1045
        else
 
1046
        {
 
1047
                fDockOffsetX = icon->fDrawX;
 
1048
                fDockOffsetY = fHeight;
 
1049
        }
 
1050
        //g_print ("X : %.2f + %.2f/%.2f ; Y : %.2f + %.2f\n", fDockOffsetX, fBigWidth, fLittleWidth, fDockOffsetY, fHeight);
 
1051
        
 
1052
        glEnable (GL_BLEND);
 
1053
        glBlendFunc (GL_ONE, GL_ZERO);
 
1054
        glColor4f (0., 0., 0., 0.);
 
1055
        
 
1056
        glPolygonMode (GL_FRONT, GL_FILL);
 
1057
        
 
1058
        if (pDock->container.bIsHorizontal)
 
1059
        {
 
1060
                if (! pDock->container.bDirectionUp)
 
1061
                        fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
 
1062
                
 
1063
                glTranslatef (fDockOffsetX, fDockOffsetY, 0.);  // coin haut gauche.
 
1064
                if (! pDock->container.bDirectionUp)
 
1065
                        glScalef (1., -1., 1.);
 
1066
        }
 
1067
        else
 
1068
        {
 
1069
                if (pDock->container.bDirectionUp)
 
1070
                        fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
 
1071
                fDockOffsetX = pDock->container.iWidth - fDockOffsetX;
 
1072
                
 
1073
                glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
 
1074
                glRotatef (-90., 0., 0., 1.);
 
1075
                if (pDock->container.bDirectionUp)
 
1076
                        glScalef (1., -1., 1.);
 
1077
        }
 
1078
        
 
1079
        glBegin(GL_QUADS);
 
1080
        glVertex3f(0., 0., 0.);  // Bottom Left Of The Texture and Quad
 
1081
        glVertex3f(fLittleWidth, 0., 0.);  // Bottom Right Of The Texture and Quad
 
1082
        glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);  // Top Right Of The Texture and Quad
 
1083
        glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);  // Top Left Of The Texture and Quad
 
1084
        glEnd();
 
1085
        
 
1086
        if (myBackground.iDockLineWidth != 0)
 
1087
        {
 
1088
                glPolygonMode (GL_FRONT, GL_LINE);
 
1089
                glEnable (GL_LINE_SMOOTH);
 
1090
                glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
 
1091
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
1092
                
 
1093
                glLineWidth (myBackground.iDockLineWidth);
 
1094
                glColor4f (myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
 
1095
                
 
1096
                glBegin(GL_LINES);
 
1097
                glVertex3f(fLittleWidth, 0., 0.);
 
1098
                glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);
 
1099
                glEnd();
 
1100
                
 
1101
                glBegin(GL_LINES);
 
1102
                glVertex3f(0., 0., 0.);
 
1103
                glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);
 
1104
                glEnd();
 
1105
                
 
1106
                glDisable(GL_LINE_SMOOTH);
 
1107
        }
 
1108
        
 
1109
        glDisable (GL_BLEND);
 
1110
}
 
1111
 
 
1112
 
 
1113
void cd_rendering_register_3D_plane_renderer (const gchar *cRendererName)
 
1114
{
 
1115
        CairoDockRenderer *pRenderer = g_new0 (CairoDockRenderer, 1);
 
1116
        pRenderer->cReadmeFilePath = g_strdup_printf ("%s/readme-3D-plane-view", MY_APPLET_SHARE_DATA_DIR);
 
1117
        pRenderer->cPreviewFilePath = g_strdup_printf ("%s/preview-3D-plane.jpg", MY_APPLET_SHARE_DATA_DIR);
 
1118
        pRenderer->compute_size = cd_rendering_calculate_max_dock_size_3D_plane;
 
1119
        pRenderer->calculate_icons = cd_rendering_calculate_icons_3D_plane;
 
1120
        pRenderer->render = cd_rendering_render_3D_plane;
 
1121
        pRenderer->render_optimized = cd_rendering_render_optimized_3D_plane;
 
1122
        pRenderer->render_opengl = cd_rendering_render_3D_plane_opengl;
 
1123
        pRenderer->set_subdock_position = cairo_dock_set_subdock_position_linear;
 
1124
        pRenderer->bUseReflect = TRUE;
 
1125
        pRenderer->cDisplayedName = D_ (cRendererName);
 
1126
        
 
1127
        cairo_dock_register_renderer (cRendererName, pRenderer);
 
1128
}