2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
******************************************************************************/
37
#include <rendering-commons.h>
38
#include "rendering-3D-plane.h"
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;
46
void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
48
pDock->pFirstDrawnElement = cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth, pDock->iScrollOffset);
50
pDock->iMaxDockHeight = (int) ((1 + g_fAmplitude) * pDock->iMaxIconHeight + myIcons.fReflectSize * pDock->fRatio) + myLabels.iLabelSize + myBackground.iDockLineWidth + myBackground.iFrameMargin;
52
double hi = myIcons.fReflectSize * pDock->fRatio + myBackground.iFrameMargin;
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);
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);
64
pDock->iDecorationsWidth = pDock->iMaxDockWidth;
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;
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;
74
pDock->iMinDockHeight = myBackground.iDockLineWidth + myBackground.iFrameMargin + myIcons.fReflectSize * pDock->fRatio + pDock->iMaxIconHeight;
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;
87
pDock->inputArea.x = fExtraWidthMin/2;
88
pDock->inputArea.y = 0;
89
pDock->inputArea.width = pDock->iMinDockWidth - fExtraWidthMin;
90
pDock->inputArea.height = pDock->iMinDockHeight;
93
void cd_rendering_calculate_construction_parameters_3D_plane (Icon *icon, int iCurrentWidth, int iCurrentHeight, int iMaxDockWidth, double fReflectionOffsetY)
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)
112
static void cd_rendering_make_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bIncludeEdges, gboolean bBackGround)
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;
119
double fHeight, fBigWidth, fLittleWidth;
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);
128
fHeight = pDock->iDecorationsHeight - myBackground.iDockLineWidth;
129
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
130
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
132
double fDeltaXLeft = fHeight * fLeftInclination;
133
double fDeltaXRight = fHeight * fRightInclination;
134
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
137
double fDockOffsetX, fDockOffsetY;
138
if (pDock->bDirectionUp)
142
fDockOffsetY = pDock->iCurrentHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
144
fDockOffsetY = pDock->iCurrentHeight - fHeight - myBackground.iDockLineWidth;
150
fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
152
fDockOffsetY = fHeight + myBackground.iDockLineWidth;
155
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
157
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
159
if (pDock->bHorizontalDock)
161
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut gauche.
162
cairo_move_to (pCairoContext, 0, 0); // coin haut gauche.
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);
169
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
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);
178
cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX); // coin haut gauche.
179
cairo_move_to (pCairoContext, 0, 0); // coin haut gauche.
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);
186
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
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));
195
static void cd_rendering_draw_3D_separator_edge (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bBackGround)
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;
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);
207
double fDeltaXLeft = fHeight * fLeftInclination;
208
double fDeltaXRight = fHeight * fRightInclination;
209
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
212
double fDockOffsetX, fDockOffsetY;
213
if (pDock->bDirectionUp)
216
fDockOffsetY = (bBackGround ? 0.5*myBackground.iDockLineWidth : - 1.*myBackground.iDockLineWidth);
221
fDockOffsetY = (bBackGround ? - 0.5*myBackground.iDockLineWidth : 1.*myBackground.iDockLineWidth);
223
fDockOffsetX = (bBackGround ? .5*myBackground.iDockLineWidth * fLeftInclination + 1.*fLeftInclination : - 0.5 * myBackground.iDockLineWidth * fLeftInclination);
224
//fDockOffsetX = -.5*myBackground.iDockLineWidth;
226
if (pDock->bHorizontalDock)
228
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut droit.
230
cairo_move_to (pCairoContext, fLittleWidth, 0);
231
cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
233
cairo_move_to (pCairoContext, 0, 0);
234
cairo_rel_line_to (pCairoContext, fDeltaXLeft, sens * fHeight);
238
cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX); // coin haut droit.
240
cairo_move_to (pCairoContext, 0, fLittleWidth);
241
cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
243
cairo_move_to (pCairoContext, 0, 0);
244
cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXLeft);
249
static void cd_rendering_draw_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
251
cd_rendering_make_3D_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR), bBackGround);
253
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
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);
259
if (myBackground.iDockLineWidth != 0)
261
cd_rendering_draw_3D_separator_edge (icon, pCairoContext, pDock, bBackGround);
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);
271
cairo_fill (pCairoContext);
276
void cd_rendering_render_3D_plane (cairo_t *pCairoContext, CairoDock *pDock)
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);
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)
291
fDockOffsetY = pDock->iCurrentHeight - pDock->iDecorationsHeight - 1.5 * fLineWidth;
296
fDockOffsetY = pDock->iDecorationsHeight + 1.5 * fLineWidth;
299
cairo_save (pCairoContext);
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
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);
308
//\____________________ On dessine le cadre.
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);
316
cairo_new_path (pCairoContext);
318
/// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
321
cairo_restore (pCairoContext);
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));
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)
332
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
335
GList *ic = pFirstDrawnElement;
336
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
338
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
343
if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
345
cairo_save (pCairoContext);
346
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, TRUE);
347
cairo_restore (pCairoContext);
350
ic = cairo_dock_get_next_element (ic, pDock->icons);
351
} while (ic != pFirstDrawnElement);
357
if (icon->acFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
359
cairo_save (pCairoContext);
360
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
361
cairo_restore (pCairoContext);
364
ic = cairo_dock_get_next_element (ic, pDock->icons);
365
} while (ic != pFirstDrawnElement);
367
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
373
if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
375
cairo_save (pCairoContext);
376
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, FALSE);
377
cairo_restore (pCairoContext);
380
ic = cairo_dock_get_next_element (ic, pDock->icons);
381
} while (ic != pFirstDrawnElement);
390
cairo_save (pCairoContext);
391
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
392
cairo_restore (pCairoContext);
394
ic = cairo_dock_get_next_element (ic, pDock->icons);
395
} while (ic != pFirstDrawnElement);
399
static gboolean _cd_separator_is_impacted (Icon *icon, CairoDock *pDock, double fXMin, double fXMax, gboolean bBackGround, gboolean bIncludeEdges)
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;
406
double fHeight, fBigWidth, fLittleWidth;
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);
415
fHeight = pDock->iDecorationsHeight;
416
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
417
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
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);
425
double fDockOffsetX, fDockOffsetY;
426
if (pDock->bDirectionUp)
430
fDockOffsetY = pDock->iCurrentHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
432
fDockOffsetY = pDock->iCurrentHeight - fHeight;
438
fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
440
fDockOffsetY = fHeight;
444
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
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.
454
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
455
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
459
fXLeft = icon->fDrawX;
460
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
465
fXLeft = icon->fDrawX - (fHeight - hi) * fLeftInclination;
466
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + hi * fRightInclination;
475
fXLeft = icon->fDrawX;
476
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
480
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
481
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
486
fXLeft = icon->fDrawX - hi * fLeftInclination;
487
fXRight = icon->fDrawX + icon->fWidth * icon->fScale +(fHeight - hi) * fRightInclination;
491
return (fXLeft <= fXMax && floor (fXRight) > fXMin);
494
void cd_rendering_render_optimized_3D_plane (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
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;
502
//\____________________ On dessine les decorations du fond sur la portion de fenetre.
503
cairo_save (pCairoContext);
505
double fDockOffsetX, fDockOffsetY;
506
if (pDock->bHorizontalDock)
508
fDockOffsetX = pArea->x;
509
fDockOffsetY = (pDock->bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
513
fDockOffsetX = (pDock->bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
514
fDockOffsetY = pArea->y;
517
//cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
518
if (pDock->bHorizontalDock)
519
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pArea->width, pDock->iDecorationsHeight);
521
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pDock->iDecorationsHeight, pArea->height);
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)
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);
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);
541
double sina = cosa * fInclinationOnHorizon;
542
fDeltaXTrapeze = fInclinationOnHorizon * (pDock->iDecorationsHeight - (FALSE ? 2 : 1-sina) * fRadius) + fRadius * (FALSE ? 1 : cosa);
544
cairo_dock_render_decorations_in_frame (pCairoContext, pDock, pDock->bHorizontalDock ? fDockOffsetY : fDockOffsetX, fOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
547
//\____________________ On dessine la partie du cadre qui va bien.
548
cairo_new_path (pCairoContext);
550
if (pDock->bHorizontalDock)
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);
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);
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);
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);
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);
578
cairo_restore (pCairoContext);
580
//\____________________ On dessine les icones impactees.
581
GList *pFirstDrawnElement = (pDock->pFirstDrawnElement != NULL ? pDock->pFirstDrawnElement : pDock->icons);
582
if (pFirstDrawnElement != NULL)
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;
588
GList *ic = pFirstDrawnElement;
590
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
592
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
597
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->acFileName == NULL)
599
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
601
cairo_save (pCairoContext);
602
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, TRUE);
603
cairo_restore (pCairoContext);
607
ic = cairo_dock_get_next_element (ic, pDock->icons);
608
} while (ic != pFirstDrawnElement);
613
if (! CAIRO_DOCK_IS_SEPARATOR (icon) || icon->acFileName != NULL)
615
fXLeft = icon->fDrawX + icon->fScale + 1;
616
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
618
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
620
if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->iCurrentWidth)
625
cairo_save (pCairoContext);
627
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
629
cairo_restore (pCairoContext);
632
ic = cairo_dock_get_next_element (ic, pDock->icons);
633
} while (ic != pFirstDrawnElement);
635
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
641
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->acFileName == NULL)
643
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
645
cairo_save (pCairoContext);
646
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->bHorizontalDock, FALSE);
647
cairo_restore (pCairoContext);
651
ic = cairo_dock_get_next_element (ic, pDock->icons);
652
} while (ic != pFirstDrawnElement);
660
fXLeft = icon->fDrawX + icon->fScale + 1;
661
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
663
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
665
if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->iCurrentWidth)
670
cairo_save (pCairoContext);
672
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
674
cairo_restore (pCairoContext);
676
ic = cairo_dock_get_next_element (ic, pDock->icons);
677
} while (ic != pFirstDrawnElement);
683
Icon *cd_rendering_calculate_icons_3D_plane (CairoDock *pDock)
685
Icon *pPointedIcon = cairo_dock_apply_wave_effect (pDock);
687
//\____________________ On calcule les position/etirements/alpha des icones.
688
double fReflectionOffsetY = (pDock->bDirectionUp ? -1 : 1) * myIcons.fReflectSize * pDock->fRatio;
691
for (ic = pDock->icons; ic != NULL; ic = ic->next)
694
cd_rendering_calculate_construction_parameters_3D_plane (icon, pDock->iCurrentWidth, pDock->iCurrentHeight, pDock->iMaxDockWidth, fReflectionOffsetY);
697
cairo_dock_check_if_mouse_inside_linear (pDock);
699
cairo_dock_check_can_drop_linear (pDock);
705
void cd_rendering_render_3D_plane_opengl (CairoDock *pDock)
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);
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);
717
if ((pDock->bHorizontalDock && ! pDock->bDirectionUp) || (! pDock->bHorizontalDock && pDock->bDirectionUp))
718
fDockOffsetY = pDock->iCurrentHeight - .5 * fLineWidth;
720
fDockOffsetY = pDock->iDecorationsHeight + 1.5 * fLineWidth;
722
double fFrameHeight = pDock->iDecorationsHeight + fLineWidth/* - 2 * fRadius*/;
723
double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
724
double fDeltaXTrapeze;
726
GLfloat *pVertexTab = cairo_dock_generate_trapeze_path (fDockWidth - (myBackground.bRoundedBottomCorner ? 0*fLineWidth : 2*fLineWidth/fInclinationOnHorizon), fFrameHeight, fRadius, myBackground.bRoundedBottomCorner, fInclinationOnHorizon, &fDeltaXTrapeze, &iNbVertex);
728
if (! pDock->bHorizontalDock)
729
fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX + fDeltaXTrapeze;
731
fDockOffsetX = fDockOffsetX-fDeltaXTrapeze;
733
//\____________________ On dessine les decorations dedans.
734
//fDockOffsetY = (!pDock->bDirectionUp ? pDock->iCurrentHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
736
cairo_dock_draw_frame_background_opengl (g_iBackgroundTexture, fDockWidth+2*fDeltaXTrapeze, fFrameHeight, fDockOffsetX, fDockOffsetY, pVertexTab, iNbVertex, pDock->bHorizontalDock, pDock->bDirectionUp, pDock->fDecorationsOffsetX);
738
//\____________________ On dessine le cadre.
740
cairo_dock_draw_current_path_opengl (fLineWidth, myBackground.fLineColor, iNbVertex);
743
/// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
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));
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)
755
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
757
GList *ic = pFirstDrawnElement;
760
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
766
if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
769
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
770
cd_rendering_draw_flat_separator_opengl (icon, pDock);
772
cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, NULL, NULL);
776
ic = cairo_dock_get_next_element (ic, pDock->icons);
777
} while (ic != pFirstDrawnElement);
783
if (icon->acFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
786
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
790
ic = cairo_dock_get_next_element (ic, pDock->icons);
791
} while (ic != pFirstDrawnElement);
793
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
799
if (icon->acFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
802
cd_rendering_draw_physical_separator_opengl (icon, pDock, FALSE, NULL, NULL);
806
ic = cairo_dock_get_next_element (ic, pDock->icons);
807
} while (ic != pFirstDrawnElement);
818
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
822
ic = cairo_dock_get_next_element (ic, pDock->icons);
823
} while (ic != pFirstDrawnElement);
828
void cd_rendering_register_3D_plane_renderer (const gchar *cRendererName)
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);
842
cairo_dock_register_renderer (cRendererName, pRenderer);
846
void cd_rendering_draw_flat_separator_opengl (Icon *icon, CairoDock *pDock)
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;
852
double fHeight, fBigWidth, fLittleWidth;
854
fHeight = pDock->iDecorationsHeight;
855
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
856
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
858
double fDeltaXLeft = fHeight * fLeftInclination;
859
double fDeltaXRight = fHeight * fRightInclination;
860
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
862
double fDockOffsetX, fDockOffsetY;
863
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
864
fDockOffsetY = fHeight + myBackground.iDockLineWidth;
867
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
868
glColor4f (1., 1., 1., 1.);
870
glEnable (GL_TEXTURE_2D);
871
glBindTexture (GL_TEXTURE_2D, my_iFlatSeparatorTexture);
872
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
874
glPolygonMode (GL_FRONT, GL_FILL);
876
if (pDock->bHorizontalDock)
878
if (! pDock->bDirectionUp)
879
fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
881
glTranslatef (fDockOffsetX, fDockOffsetY, 0.); // coin haut gauche.
882
if (! pDock->bDirectionUp)
883
glScalef (1., -1., 1.);
887
if (pDock->bDirectionUp)
888
fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
889
fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX;
891
glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
892
glRotatef (-90., 0., 0., 1.);
893
if (pDock->bDirectionUp)
894
glScalef (1., -1., 1.);
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
908
glDisable (GL_TEXTURE_2D);
909
glDisable (GL_BLEND);
912
void cd_rendering_draw_physical_separator_opengl (Icon *icon, CairoDock *pDock, gboolean bBackGround, Icon *prev_icon, Icon *next_icon)
914
if (prev_icon == NULL)
916
if (next_icon == NULL)
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;
923
double fHeight, fBigWidth, fLittleWidth;
926
fHeight = pDock->iDecorationsHeight + myBackground.iDockLineWidth - hi;
927
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0);
928
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0 - fHeight);
932
fHeight = hi + myBackground.iDockLineWidth;
933
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
934
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
936
double fDeltaXLeft = fHeight * fLeftInclination;
937
double fDeltaXRight = fHeight * fRightInclination;
938
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
940
double fDockOffsetX, fDockOffsetY;
943
fDockOffsetX = icon->fDrawX - fHeight * fLeftInclination;
944
fDockOffsetY = pDock->iDecorationsHeight + 2*myBackground.iDockLineWidth;
948
fDockOffsetX = icon->fDrawX;
949
fDockOffsetY = fHeight;
953
glBlendFunc (GL_ONE, GL_ZERO);
954
glColor4f (0., 0., 0., 0.);
956
glPolygonMode (GL_FRONT, GL_FILL);
958
if (pDock->bHorizontalDock)
960
if (! pDock->bDirectionUp)
961
fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
963
glTranslatef (fDockOffsetX, fDockOffsetY, 0.); // coin haut gauche.
964
if (! pDock->bDirectionUp)
965
glScalef (1., -1., 1.);
969
if (pDock->bDirectionUp)
970
fDockOffsetY = pDock->iCurrentHeight - fDockOffsetY;
971
fDockOffsetX = pDock->iCurrentWidth - fDockOffsetX;
973
glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
974
glRotatef (-90., 0., 0., 1.);
975
if (pDock->bDirectionUp)
976
glScalef (1., -1., 1.);
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
986
if (myBackground.iDockLineWidth != 0)
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);
993
glLineWidth (myBackground.iDockLineWidth);
994
glColor4f (myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
997
glVertex3f(fLittleWidth, 0., 0.);
998
glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);
1002
glVertex3f(0., 0., 0.);
1003
glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);
1006
glDisable(GL_LINE_SMOOTH);
1009
glDisable (GL_BLEND);