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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

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
}