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);
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/>.
29
#include "rendering-commons.h"
30
#include "rendering-3D-plane.h"
32
extern int iVanishingPointY;
33
extern CDSpeparatorType my_iDrawSeparator3D;
34
extern cairo_surface_t *my_pFlatSeparatorSurface[2];
35
extern double my_fSeparatorColor[4];
36
extern GLuint my_iFlatSeparatorTexture;
38
#define _define_parameters(hi, h0, H, l, r, gamma, h, w, dw)\
39
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;\
40
double h0max = (1 + g_fAmplitude) * pDock->iMaxIconHeight + MAX (myLabels.iLabelSize, myBackground.iFrameMargin + myBackground.iDockLineWidth);\
41
double h0 = pDock->iMaxIconHeight;\
42
double H = iVanishingPointY;\
43
double l = myBackground.iDockLineWidth;\
44
double r = MIN (myBackground.iDockRadius, (hi + h0) / 2);\
45
double gamma = 0, h, w, dw = 0
47
void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
49
pDock->pFirstDrawnElement = cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth, pDock->iScrollOffset);
51
//pDock->iMaxDockHeight = (int) ((1 + g_fAmplitude) * pDock->iMaxIconHeight + myIcons.fReflectSize * pDock->container.fRatio) + myLabels.iLabelSize + myBackground.iDockLineWidth + myBackground.iFrameMargin;
53
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
54
pDock->iMaxDockHeight = (int) (hi + h0max + l);
57
w = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., 2 * dw)); // pDock->iMaxDockWidth
61
h = hi + h0 / (1 + gamma); // en fait, sqrt (1 + gamma * gamma), mais on simplifie pour diminuer l'ordre de 2. pDock->iDecorationsHeight
63
dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma); // en fait, h*gamma + r*(1-sin)/cos, or (1-sin)/cos <= 1, on majore pour simplifier. on aurait r + gamma * (h - 2 * r) si on utilisait des cercles au lieu de courbes de Bezier.
66
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
68
double b = H + hi + h0 - W / 2;
70
double g = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
71
g_print ("gamma : %f (=) %f\n", gamma, g);*/
73
double Ws = cairo_dock_get_max_authorized_dock_width (pDock);
74
if (cairo_dock_is_extended_dock (pDock) && w + 2 * dw < Ws) // alors on etend.
76
double extra = Ws - w;
77
pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., extra)); // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
78
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
80
double b = H + hi + h0 - W / 2;
82
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
83
//g_print ("mode etendu : pDock->iMaxDockWidth : %d, gamma = %f\n", pDock->iMaxDockWidth, gamma);
84
h = hi + h0 / (1 + gamma);
86
else // rien d'autre a faire
88
pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->pFirstDrawnElement, pDock->fFlatDockWidth, 1., 2 * dw)); // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
90
pDock->iDecorationsHeight = h;
91
//g_print ("h : %.2f -> %d\n", h, pDock->iDecorationsHeight);
93
pDock->iDecorationsWidth = pDock->iMaxDockWidth;
96
pDock->iMinDockHeight = myBackground.iDockLineWidth + myBackground.iFrameMargin + myIcons.fReflectSize * pDock->container.fRatio + pDock->iMaxIconHeight;
98
double gamma_min = pDock->fFlatDockWidth / 2 / H;
99
double dw_min = h * gamma_min + r + (l+(r==0)*2)*sqrt(1+gamma_min*gamma_min);
100
//cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclination, myBackground.iDockRadius, myBackground.iDockLineWidth);
102
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
104
//g_print ("extended\n");
105
pDock->iMinDockWidth = cairo_dock_get_max_authorized_dock_width (pDock);
109
pDock->iMinDockWidth = pDock->fFlatDockWidth + 2 * dw_min;
111
//g_print ("pDock->iMinDockWidth : %d\n", pDock->iMinDockWidth);
114
pDock->inputArea.x = (pDock->iMinDockWidth - pDock->fFlatDockWidth) / 2;
115
pDock->inputArea.y = 0;
116
pDock->inputArea.width = pDock->fFlatDockWidth;
117
pDock->inputArea.height = pDock->iMinDockHeight;
118
//g_print ("input area : %d + %d\n", pDock->inputArea.x, pDock->inputArea.width);
120
// on charge les separateurs plat.
121
if (my_pFlatSeparatorSurface[0] == NULL && my_iFlatSeparatorTexture == 0 && my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
122
cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
125
void cd_rendering_calculate_construction_parameters_3D_plane (Icon *icon, int iWidth, int iHeight, int iMaxDockWidth, double fReflectionOffsetY)
127
icon->fDrawX = icon->fX;
128
icon->fDrawY = icon->fY + fReflectionOffsetY;
129
icon->fWidthFactor = 1.;
130
icon->fHeightFactor = 1.;
131
///icon->fDeltaYReflection = 0.;
132
icon->fOrientation = 0.;
133
//if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= iWidth)
144
static void cd_rendering_make_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bIncludeEdges, gboolean bBackGround)
146
gboolean bDirectionUp = pDock->container.bDirectionUp;
147
gboolean bIsHorizontal = pDock->container.bIsHorizontal;
149
bIsHorizontal = TRUE;
150
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
151
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
152
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
153
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
155
double fHeight, fBigWidth, fLittleWidth;
158
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + myBackground.iDockLineWidth;
159
fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
160
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
164
fHeight = pDock->iDecorationsHeight - myBackground.iDockLineWidth;
165
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
166
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
168
double fDeltaXLeft = fHeight * fLeftInclination;
169
double fDeltaXRight = fHeight * fRightInclination;
170
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
173
double fDockOffsetX, fDockOffsetY;
178
fDockOffsetY = pDock->container.iHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
180
fDockOffsetY = pDock->container.iHeight - fHeight - myBackground.iDockLineWidth;
186
fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
188
fDockOffsetY = fHeight + myBackground.iDockLineWidth;
191
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
193
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
197
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut gauche.
198
cairo_move_to (pCairoContext, 0, 0); // coin haut gauche.
200
cairo_rel_line_to (pCairoContext, fLittleWidth, 0);
201
cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
202
cairo_rel_line_to (pCairoContext, - fBigWidth, 0);
203
cairo_rel_line_to (pCairoContext, - fDeltaXLeft, - sens * fHeight);
205
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
208
cairo_scale (pCairoContext, 1, -1);
209
cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_HORIZONTAL], MIN (0, (fHeight + hi) * fLeftInclination), 0);
214
cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX); // coin haut gauche.
215
cairo_move_to (pCairoContext, 0, 0); // coin haut gauche.
217
cairo_rel_line_to (pCairoContext, 0, fLittleWidth);
218
cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
219
cairo_rel_line_to (pCairoContext, 0, - fBigWidth);
220
cairo_rel_line_to (pCairoContext, - sens * fHeight, - fDeltaXLeft);
222
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
225
cairo_scale (pCairoContext, -1, 1);
226
cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_VERTICAL], 0, MIN (0, (fHeight + hi) * fLeftInclination));
231
static void cd_rendering_draw_3D_separator_edge (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bBackGround)
233
gboolean bDirectionUp = pDock->container.bDirectionUp;
234
gboolean bIsHorizontal = pDock->container.bIsHorizontal;
236
bIsHorizontal = TRUE;
237
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
238
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
239
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
240
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
242
double fHeight, fBigWidth, fLittleWidth;
243
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi - 0.5*myBackground.iDockLineWidth : hi + 1.5*myBackground.iDockLineWidth);
244
fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
245
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
247
double fDeltaXLeft = fHeight * fLeftInclination;
248
double fDeltaXRight = fHeight * fRightInclination;
249
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
252
double fDockOffsetX, fDockOffsetY;
256
fDockOffsetY = (bBackGround ? 0.5*myBackground.iDockLineWidth : - 1.*myBackground.iDockLineWidth);
261
fDockOffsetY = (bBackGround ? - 0.5*myBackground.iDockLineWidth : 1.*myBackground.iDockLineWidth);
263
fDockOffsetX = (bBackGround ? .5*myBackground.iDockLineWidth * fLeftInclination + 1.*fLeftInclination : - 0.5 * myBackground.iDockLineWidth * fLeftInclination);
264
//fDockOffsetX = -.5*myBackground.iDockLineWidth;
268
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut droit.
270
cairo_move_to (pCairoContext, fLittleWidth, 0);
271
cairo_rel_line_to (pCairoContext, fDeltaXRight, sens * fHeight);
273
cairo_move_to (pCairoContext, 0, 0);
274
cairo_rel_line_to (pCairoContext, fDeltaXLeft, sens * fHeight);
278
cairo_translate (pCairoContext, fDockOffsetY, fDockOffsetX); // coin haut droit.
280
cairo_move_to (pCairoContext, 0, fLittleWidth);
281
cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXRight);
283
cairo_move_to (pCairoContext, 0, 0);
284
cairo_rel_line_to (pCairoContext, sens * fHeight, fDeltaXLeft);
289
static void cd_rendering_draw_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
291
if (pDock->container.bIsHorizontal)
293
if (! pDock->container.bDirectionUp)
295
cairo_translate (pCairoContext, 0., pDock->container.iHeight);
296
cairo_scale (pCairoContext, 1., -1.);
301
if (pDock->container.bDirectionUp)
310
cd_rendering_make_3D_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR), bBackGround);
312
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
314
cairo_set_operator (pCairoContext, CAIRO_OPERATOR_DEST_OUT);
315
cairo_set_source_rgba (pCairoContext, 0.0, 0.0, 0.0, 1.0);
316
cairo_fill (pCairoContext);
318
if (myBackground.iDockLineWidth != 0)
320
cd_rendering_draw_3D_separator_edge (icon, pCairoContext, pDock, bBackGround);
322
cairo_set_operator (pCairoContext, CAIRO_OPERATOR_OVER);
323
cairo_set_line_width (pCairoContext, myBackground.iDockLineWidth);
324
cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
325
cairo_stroke (pCairoContext);
330
cairo_fill (pCairoContext);
335
void cd_rendering_render_3D_plane (cairo_t *pCairoContext, CairoDock *pDock)
337
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
338
h = pDock->iDecorationsHeight;
342
//\____________________ On definit la position du cadre.
343
double dx, dy; // position du coin haut gauche du cadre.
344
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
346
double Ws = pDock->container.iWidth;
348
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
350
double b = H + hi + h0 - W / 2;
352
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
353
h = hi + h0 / (1 + gamma);
354
//g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
357
//g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
362
w = cairo_dock_get_current_dock_width_linear (pDock);
364
dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
365
h = pDock->iDecorationsHeight;
366
Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
367
dx = (pFirstIcon != NULL ? pFirstIcon->fX - 0*myBackground.iFrameMargin : r);
371
if (pDock->container.bDirectionUp)
374
dy = pDock->container.iHeight - pDock->iDecorationsHeight - 1.5 * l;
379
dy = pDock->iDecorationsHeight + 1.5 * l;
382
//\____________________ On trace le cadre.
383
cairo_save (pCairoContext);
385
double fDeltaXTrapeze = cairo_dock_draw_frame (pCairoContext, r, l, w, pDock->iDecorationsHeight, dx, dy, sens, gamma, pDock->container.bIsHorizontal);
387
//\____________________ On dessine les decorations dedans.
388
dy = (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iDecorationsHeight - l : l);
389
cairo_dock_render_decorations_in_frame (pCairoContext, pDock, dy, dx-fDeltaXTrapeze, w+2*fDeltaXTrapeze);
391
//\____________________ On dessine le cadre.
394
cairo_set_line_width (pCairoContext, l);
395
cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
396
cairo_stroke (pCairoContext);
399
cairo_new_path (pCairoContext);
401
/// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
404
cairo_restore (pCairoContext);
406
//\____________________ On dessine la ficelle qui les joint.
407
if (myIcons.iStringLineWidth > 0)
408
cairo_dock_draw_string (pCairoContext, pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
410
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
411
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
412
if (pFirstDrawnElement == NULL)
415
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
418
GList *ic = pFirstDrawnElement;
419
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
421
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
426
if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
428
cairo_save (pCairoContext);
429
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
430
cairo_restore (pCairoContext);
433
ic = cairo_dock_get_next_element (ic, pDock->icons);
434
} while (ic != pFirstDrawnElement);
440
if (icon->cFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
442
cairo_save (pCairoContext);
443
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
444
cairo_restore (pCairoContext);
447
ic = cairo_dock_get_next_element (ic, pDock->icons);
448
} while (ic != pFirstDrawnElement);
450
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
456
if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
458
cairo_save (pCairoContext);
459
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
460
cairo_restore (pCairoContext);
463
ic = cairo_dock_get_next_element (ic, pDock->icons);
464
} while (ic != pFirstDrawnElement);
473
cairo_save (pCairoContext);
474
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
475
cairo_restore (pCairoContext);
477
ic = cairo_dock_get_next_element (ic, pDock->icons);
478
} while (ic != pFirstDrawnElement);
482
static gboolean _cd_separator_is_impacted (Icon *icon, CairoDock *pDock, double fXMin, double fXMax, gboolean bBackGround, gboolean bIncludeEdges)
484
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
485
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
486
double fLeftInclination = fabs (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
487
double fRightInclination = fabs (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
489
double fHeight, fBigWidth, fLittleWidth;
492
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + (bIncludeEdges ? myBackground.iDockLineWidth : 0);
493
fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
494
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
498
fHeight = pDock->iDecorationsHeight;
499
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
500
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
502
double fDeltaXLeft = fHeight * fLeftInclination;
503
double fDeltaXRight = fHeight * fRightInclination;
504
double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
505
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
508
double fDockOffsetX, fDockOffsetY;
509
if (pDock->container.bDirectionUp)
513
fDockOffsetY = pDock->container.iHeight - fHeight - (bBackGround ? myBackground.iDockLineWidth + hi : 0);
515
fDockOffsetY = pDock->container.iHeight - fHeight;
521
fDockOffsetY = fHeight + (bBackGround ? myBackground.iDockLineWidth + hi : 0);
523
fDockOffsetY = fHeight;
527
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
529
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
530
double fXLeft, fXRight;
531
if (icon->fDrawX + icon->fWidth * icon->fScale / 2 > pDock->container.iWidth / 2) // on est a droite.
537
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
538
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
542
fXLeft = icon->fDrawX;
543
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
548
fXLeft = icon->fDrawX - (fHeight - hi) * fLeftInclination;
549
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + hi * fRightInclination;
558
fXLeft = icon->fDrawX;
559
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
563
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
564
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
569
fXLeft = icon->fDrawX - hi * fLeftInclination;
570
fXRight = icon->fDrawX + icon->fWidth * icon->fScale +(fHeight - hi) * fRightInclination;
574
return (fXLeft <= fXMax && floor (fXRight) > fXMin);
577
void cd_rendering_render_optimized_3D_plane (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
579
//g_print ("%s ((%d;%d) x (%d;%d) / (%dx%d))\n", __func__, pArea->x, pArea->y, pArea->width, pArea->height, pDock->container.iWidth, pDock->container.iHeight);
580
double fLineWidth = myBackground.iDockLineWidth;
581
double fMargin = myBackground.iFrameMargin;
582
int iWidth = pDock->container.iWidth;
583
int iHeight = pDock->container.iHeight;
585
//\____________________ On dessine les decorations du fond sur la portion de fenetre.
586
cairo_save (pCairoContext);
588
double fDockOffsetX, fDockOffsetY;
589
if (pDock->container.bIsHorizontal)
591
fDockOffsetX = pArea->x;
592
fDockOffsetY = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
596
fDockOffsetX = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
597
fDockOffsetY = pArea->y;
600
//cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
601
if (pDock->container.bIsHorizontal)
602
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pArea->width, pDock->iDecorationsHeight);
604
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pDock->iDecorationsHeight, pArea->height);
606
double fRadius = MIN (myBackground.iDockRadius, (pDock->iDecorationsHeight + myBackground.iDockLineWidth) / 2 - 1);
607
double fDeltaXTrapeze=0.;
609
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
611
fOffsetX = fRadius + fLineWidth / 2;
615
Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
616
fOffsetX = (pFirstIcon != NULL ? pFirstIcon->fX - fMargin : fRadius + fLineWidth / 2);
618
double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
619
if (g_pBackgroundSurface != NULL)
621
double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
622
double fRadius = myBackground.iDockRadius;
623
if (2*fRadius > pDock->iDecorationsHeight + fLineWidth)
624
fRadius = (pDock->iDecorationsHeight + fLineWidth) / 2 - 1;
625
double fDeltaXForLoop = fInclinationOnHorizon * (pDock->iDecorationsHeight + fLineWidth - (myBackground.bRoundedBottomCorner ? 2 : 1) * fRadius);
627
double cosa = 1. / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
628
fDeltaXTrapeze = fDeltaXForLoop + fRadius * cosa;
630
double sina = cosa * fInclinationOnHorizon;
631
fDeltaXTrapeze = fInclinationOnHorizon * (pDock->iDecorationsHeight - (FALSE ? 2 : 1-sina) * fRadius) + fRadius * (FALSE ? 1 : cosa);
633
cairo_dock_render_decorations_in_frame (pCairoContext, pDock, pDock->container.bIsHorizontal ? fDockOffsetY : fDockOffsetX, fOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
636
//\____________________ On dessine la partie du cadre qui va bien.
637
cairo_new_path (pCairoContext);
639
if (pDock->container.bIsHorizontal)
641
cairo_set_line_width (pCairoContext, fLineWidth);
642
cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY - 0.5*fLineWidth);
643
cairo_rel_line_to (pCairoContext, pArea->width, 0);
644
cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
645
cairo_stroke (pCairoContext);
647
cairo_new_path (pCairoContext);
648
cairo_move_to (pCairoContext, fDockOffsetX, (pDock->container.bDirectionUp ? iHeight - 0.5*fLineWidth : pDock->iDecorationsHeight + 1.5 * fLineWidth));
649
cairo_rel_line_to (pCairoContext, pArea->width, 0);
653
cairo_move_to (pCairoContext, fDockOffsetX - .5*fLineWidth, fDockOffsetY);
654
cairo_rel_line_to (pCairoContext, 0, pArea->height);
655
cairo_set_line_width (pCairoContext, fLineWidth);
656
cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
657
cairo_stroke (pCairoContext);
659
cairo_new_path (pCairoContext);
660
cairo_move_to (pCairoContext, (pDock->container.bDirectionUp ? iHeight - fLineWidth / 2 : pDock->iDecorationsHeight + 1.5 * fLineWidth), fDockOffsetY);
661
cairo_rel_line_to (pCairoContext, 0, pArea->height);
663
cairo_set_line_width (pCairoContext, fLineWidth);
664
cairo_set_source_rgba (pCairoContext, myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
665
cairo_stroke (pCairoContext);
667
cairo_restore (pCairoContext);
669
//\____________________ On dessine les icones impactees.
670
GList *pFirstDrawnElement = (pDock->pFirstDrawnElement != NULL ? pDock->pFirstDrawnElement : pDock->icons);
671
if (pFirstDrawnElement != NULL)
673
double fXMin = (pDock->container.bIsHorizontal ? pArea->x : pArea->y), fXMax = (pDock->container.bIsHorizontal ? pArea->x + pArea->width : pArea->y + pArea->height);
674
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
675
double fXLeft, fXRight;
677
GList *ic = pFirstDrawnElement;
679
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
681
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
686
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
688
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
690
cairo_save (pCairoContext);
691
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
692
cairo_restore (pCairoContext);
696
ic = cairo_dock_get_next_element (ic, pDock->icons);
697
} while (ic != pFirstDrawnElement);
702
if (! CAIRO_DOCK_IS_SEPARATOR (icon) || icon->cFileName != NULL)
704
fXLeft = icon->fDrawX + icon->fScale + 1;
705
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
707
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
709
//if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
712
// icon->fAlpha = .25;
714
cairo_save (pCairoContext);
716
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
718
cairo_restore (pCairoContext);
721
ic = cairo_dock_get_next_element (ic, pDock->icons);
722
} while (ic != pFirstDrawnElement);
724
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
730
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
732
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
734
cairo_save (pCairoContext);
735
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
736
cairo_restore (pCairoContext);
740
ic = cairo_dock_get_next_element (ic, pDock->icons);
741
} while (ic != pFirstDrawnElement);
749
fXLeft = icon->fDrawX + icon->fScale + 1;
750
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
752
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
754
//if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
757
// icon->fAlpha = .25;
759
cairo_save (pCairoContext);
761
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
763
cairo_restore (pCairoContext);
765
ic = cairo_dock_get_next_element (ic, pDock->icons);
766
} while (ic != pFirstDrawnElement);
772
Icon *cd_rendering_calculate_icons_3D_plane (CairoDock *pDock)
774
Icon *pPointedIcon = cairo_dock_apply_wave_effect (pDock);
776
//\____________________ On calcule les position/etirements/alpha des icones.
777
double fReflectionOffsetY = (pDock->container.bDirectionUp ? -1 : 1) * myIcons.fReflectSize * pDock->container.fRatio;
780
for (ic = pDock->icons; ic != NULL; ic = ic->next)
783
cd_rendering_calculate_construction_parameters_3D_plane (icon, pDock->container.iWidth, pDock->container.iHeight, pDock->iMaxDockWidth, fReflectionOffsetY);
786
cairo_dock_check_if_mouse_inside_linear (pDock);
788
cairo_dock_check_can_drop_linear (pDock);
794
void cd_rendering_render_3D_plane_opengl (CairoDock *pDock)
796
//\____________________ On genere le cadre.
797
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
798
h = pDock->iDecorationsHeight;
803
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
805
double Ws = pDock->container.iWidth;
806
double W = Ws - 2 * r;
808
double b = H + hi + h0 - W / 2;
810
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
811
h = hi + h0 / (1 + gamma);
812
//g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
815
//g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
820
w = cairo_dock_get_current_dock_width_linear (pDock);
822
dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
823
h = pDock->iDecorationsHeight;
824
Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
825
dx = (pFirstIcon != NULL ? pFirstIcon->fX - myBackground.iFrameMargin : r);
828
//\____________________ On trace le cadre.
830
if ((pDock->container.bDirectionUp && pDock->container.bIsHorizontal) || (!pDock->container.bDirectionUp && !pDock->container.bIsHorizontal))
833
//dy = pDock->container.iHeight - pDock->iDecorationsHeight - 1.5 * l;
834
dy = pDock->iDecorationsHeight + 1.5*l;
839
//dy = pDock->iDecorationsHeight + 1.5 * l;
840
dy = pDock->container.iHeight - .5 * l;
844
double fDeltaXTrapeze;
845
GLfloat *pVertexTab = cairo_dock_generate_trapeze_path (w - (myBackground.bRoundedBottomCorner ? 0 : 2*l/gamma), h+l, r, myBackground.bRoundedBottomCorner, gamma, &fDeltaXTrapeze, &iNbVertex);
847
if (! pDock->container.bIsHorizontal)
848
dx = pDock->container.iWidth - dx + fDeltaXTrapeze;
850
dx = dx - fDeltaXTrapeze;
852
//\____________________ On dessine les decorations dedans.
853
//fDockOffsetY = (!pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
855
cairo_dock_draw_frame_background_opengl (g_iBackgroundTexture, w+2*fDeltaXTrapeze, h+l, dx, dy, pVertexTab, iNbVertex, pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX);
857
//\____________________ On dessine le cadre.
859
cairo_dock_draw_current_path_opengl (l, myBackground.fLineColor, iNbVertex);
862
/// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
865
//\____________________ On dessine la ficelle qui les joint.
866
if (myIcons.iStringLineWidth > 0)
867
cairo_dock_draw_string_opengl (pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
869
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
870
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
871
if (pFirstDrawnElement == NULL)
874
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
876
GList *ic = pFirstDrawnElement;
879
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
885
if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
888
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
889
cd_rendering_draw_flat_separator_opengl (icon, pDock);
891
cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, NULL, NULL);
895
ic = cairo_dock_get_next_element (ic, pDock->icons);
896
} while (ic != pFirstDrawnElement);
902
if (icon->cFileName != NULL || ! CAIRO_DOCK_IS_SEPARATOR (icon))
905
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
909
ic = cairo_dock_get_next_element (ic, pDock->icons);
910
} while (ic != pFirstDrawnElement);
912
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
918
if (icon->cFileName == NULL && CAIRO_DOCK_IS_SEPARATOR (icon))
921
cd_rendering_draw_physical_separator_opengl (icon, pDock, FALSE, NULL, NULL);
925
ic = cairo_dock_get_next_element (ic, pDock->icons);
926
} while (ic != pFirstDrawnElement);
937
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
941
ic = cairo_dock_get_next_element (ic, pDock->icons);
942
} while (ic != pFirstDrawnElement);
947
void cd_rendering_draw_flat_separator_opengl (Icon *icon, CairoDock *pDock)
949
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
950
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
951
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
953
double fHeight = pDock->iDecorationsHeight;
954
double fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
955
double fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
957
double fDeltaXLeft = fHeight * fLeftInclination;
958
double fDeltaXRight = fHeight * fRightInclination;
959
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
961
double fDockOffsetX, fDockOffsetY;
962
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
963
fDockOffsetY = fHeight + myBackground.iDockLineWidth;
966
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
967
glColor4f (1., 1., 1., 1.);
969
glEnable (GL_TEXTURE_2D);
970
glBindTexture (GL_TEXTURE_2D, my_iFlatSeparatorTexture);
971
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
973
glPolygonMode (GL_FRONT, GL_FILL);
975
if (pDock->container.bIsHorizontal)
977
if (! pDock->container.bDirectionUp)
978
fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
980
glTranslatef (fDockOffsetX, fDockOffsetY, 0.); // coin haut gauche.
981
if (! pDock->container.bDirectionUp)
982
glScalef (1., -1., 1.);
986
if (pDock->container.bDirectionUp)
987
fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
988
fDockOffsetX = pDock->container.iWidth - fDockOffsetX;
990
glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
991
glRotatef (-90., 0., 0., 1.);
992
if (pDock->container.bDirectionUp)
993
glScalef (1., -1., 1.);
997
glTexCoord2f(0., 0.);
998
glVertex3f(0., 0., 0.); // Bottom Left Of The Texture and Quad
999
glTexCoord2f(1., 0.);
1000
glVertex3f(fLittleWidth, 0., 0.); // Bottom Right Of The Texture and Quad
1001
glTexCoord2f(1., 1.);
1002
glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.); // Top Right Of The Texture and Quad
1003
glTexCoord2f(0., 1.);
1004
glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.); // Top Left Of The Texture and Quad
1007
glDisable (GL_TEXTURE_2D);
1008
glDisable (GL_BLEND);
1011
void cd_rendering_draw_physical_separator_opengl (Icon *icon, CairoDock *pDock, gboolean bBackGround, Icon *prev_icon, Icon *next_icon)
1013
if (prev_icon == NULL)
1015
if (next_icon == NULL)
1017
double hi = myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin;
1018
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
1019
//g_print ("%s : hi = %.2f/%.2f\n", icon->cName, myIcons.fReflectSize * pDock->container.fRatio + myBackground.iFrameMargin, pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale));
1020
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
1021
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
1023
double fHeight, fBigWidth, fLittleWidth;
1026
fHeight = pDock->iDecorationsHeight + myBackground.iDockLineWidth - hi;
1027
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0);
1028
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + 0 - fHeight);
1032
fHeight = hi + myBackground.iDockLineWidth;
1033
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
1034
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
1036
double fDeltaXLeft = fHeight * fLeftInclination;
1037
double fDeltaXRight = fHeight * fRightInclination;
1039
double fDockOffsetX, fDockOffsetY;
1042
fDockOffsetX = icon->fDrawX - fHeight * fLeftInclination;
1043
fDockOffsetY = pDock->iDecorationsHeight + 2*myBackground.iDockLineWidth;
1047
fDockOffsetX = icon->fDrawX;
1048
fDockOffsetY = fHeight;
1050
//g_print ("X : %.2f + %.2f/%.2f ; Y : %.2f + %.2f\n", fDockOffsetX, fBigWidth, fLittleWidth, fDockOffsetY, fHeight);
1052
glEnable (GL_BLEND);
1053
glBlendFunc (GL_ONE, GL_ZERO);
1054
glColor4f (0., 0., 0., 0.);
1056
glPolygonMode (GL_FRONT, GL_FILL);
1058
if (pDock->container.bIsHorizontal)
1060
if (! pDock->container.bDirectionUp)
1061
fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
1063
glTranslatef (fDockOffsetX, fDockOffsetY, 0.); // coin haut gauche.
1064
if (! pDock->container.bDirectionUp)
1065
glScalef (1., -1., 1.);
1069
if (pDock->container.bDirectionUp)
1070
fDockOffsetY = pDock->container.iHeight - fDockOffsetY;
1071
fDockOffsetX = pDock->container.iWidth - fDockOffsetX;
1073
glTranslatef (fDockOffsetY, fDockOffsetX, 0.);
1074
glRotatef (-90., 0., 0., 1.);
1075
if (pDock->container.bDirectionUp)
1076
glScalef (1., -1., 1.);
1080
glVertex3f(0., 0., 0.); // Bottom Left Of The Texture and Quad
1081
glVertex3f(fLittleWidth, 0., 0.); // Bottom Right Of The Texture and Quad
1082
glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.); // Top Right Of The Texture and Quad
1083
glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.); // Top Left Of The Texture and Quad
1086
if (myBackground.iDockLineWidth != 0)
1088
glPolygonMode (GL_FRONT, GL_LINE);
1089
glEnable (GL_LINE_SMOOTH);
1090
glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1091
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1093
glLineWidth (myBackground.iDockLineWidth);
1094
glColor4f (myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
1097
glVertex3f(fLittleWidth, 0., 0.);
1098
glVertex3f(fLittleWidth + fDeltaXRight, - fHeight, 0.);
1102
glVertex3f(0., 0., 0.);
1103
glVertex3f(fLittleWidth + fDeltaXRight - fBigWidth, - fHeight, 0.);
1106
glDisable(GL_LINE_SMOOTH);
1109
glDisable (GL_BLEND);
1113
void cd_rendering_register_3D_plane_renderer (const gchar *cRendererName)
1115
CairoDockRenderer *pRenderer = g_new0 (CairoDockRenderer, 1);
1116
pRenderer->cReadmeFilePath = g_strdup_printf ("%s/readme-3D-plane-view", MY_APPLET_SHARE_DATA_DIR);
1117
pRenderer->cPreviewFilePath = g_strdup_printf ("%s/preview-3D-plane.jpg", MY_APPLET_SHARE_DATA_DIR);
1118
pRenderer->compute_size = cd_rendering_calculate_max_dock_size_3D_plane;
1119
pRenderer->calculate_icons = cd_rendering_calculate_icons_3D_plane;
1120
pRenderer->render = cd_rendering_render_3D_plane;
1121
pRenderer->render_optimized = cd_rendering_render_optimized_3D_plane;
1122
pRenderer->render_opengl = cd_rendering_render_3D_plane_opengl;
1123
pRenderer->set_subdock_position = cairo_dock_set_subdock_position_linear;
1124
pRenderer->bUseReflect = TRUE;
1125
pRenderer->cDisplayedName = D_ (cRendererName);
1127
cairo_dock_register_renderer (cRendererName, pRenderer);