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;
34
extern cairo_surface_t *my_pFlatSeparatorSurface[2];
36
#define _define_parameters(hi, h0, H, l, r, gamma, h, w, dw)\
37
double hi = /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * pDock->container.fRatio + myDocksParam.iFrameMargin;\
38
double h0 = pDock->iMaxIconHeight/** * pDock->container.fRatio*/;\
39
double H = iVanishingPointY;\
40
double l = myDocksParam.iDockLineWidth;\
41
double r = MIN (myDocksParam.iDockRadius, (hi + h0) / 2);\
42
double gamma = 0, h, w, dw = 0
44
static void cd_rendering_calculate_max_dock_size_3D_plane (CairoDock *pDock)
46
cairo_dock_calculate_icons_positions_at_rest_linear (pDock->icons, pDock->fFlatDockWidth);
48
//pDock->iMaxDockHeight = (int) ((1 + myIconsParam.fAmplitude) * pDock->iMaxIconHeight + myIconsParam.fReflectSize * pDock->container.fRatio) + myIconsParam.iLabelSize + myDocksParam.iDockLineWidth + myDocksParam.iFrameMargin;
50
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
51
double h0max = (1 + myIconsParam.fAmplitude) * pDock->iMaxIconHeight * pDock->container.fRatio + MAX ((pDock->container.bIsHorizontal ? myIconsParam.iLabelSize : 0), myDocksParam.iFrameMargin + myDocksParam.iDockLineWidth);
52
pDock->iMaxDockHeight = (int) (hi + h0max + l);
56
w = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->fFlatDockWidth, 1., 2 * dw)); // pDock->iMaxDockWidth
60
h = hi + h0 / (1 + gamma); // en fait, sqrt (1 + gamma * gamma), mais on simplifie pour diminuer l'ordre de 2. pDock->iDecorationsHeight
62
dw = h * gamma + 0*r + (l+(r==0)*2)*sqrt(1+gamma*gamma); // en fait, h*gamma + r*(1-sin)/cos, or (1-sin)/cos <= 1, on majore pour simplifier. on aurait r + gamma * (h - 2 * r) si on utilisait des cercles au lieu de courbes de Bezier.
64
r = MIN (myDocksParam.iDockRadius, h / 2);
65
dw = r + gamma * (h - r) + (l+(r==0)*2)*sqrt(1+gamma*gamma); // h-2r si on utilisait des cercles au lieu de courbes de Bezier.
66
//g_print ("r:%.1f, h:%.1f => dw=%.1f (%.1f)\n", r, h, dw, h * gamma + 0*r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
69
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
71
double b = H + hi + h0 - W / 2;
73
double g = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
74
cd_debug ("gamma : %f (=) %f", gamma, g);*/
76
int iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->fFlatDockWidth, 1., 2 * dw)); // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
77
pDock->iMaxDockWidth = iMaxDockWidth;
78
pDock->iOffsetForExtend = 0;
79
double Ws = cairo_dock_get_max_authorized_dock_width (pDock);
80
///if (cairo_dock_is_extended_dock (pDock) && w + 2 * dw < Ws) // alors on etend.
81
if (pDock->iRefCount == 0)
83
if (pDock->iMaxDockWidth < Ws) // alors on etend.
85
pDock->iOffsetForExtend = (Ws - pDock->iMaxDockWidth) / 2;
86
double extra = Ws - w;
87
pDock->iMaxDockWidth = ceil (cairo_dock_calculate_max_dock_width (pDock, pDock->fFlatDockWidth, 1., extra)); // on pourra optimiser, ce qui nous interesse ici c'est les fXMin/fXMax.
88
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
90
double b = H + hi + h0 - W / 2;
92
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
93
//g_print ("mode etendu : pDock->iMaxDockWidth : %d, gamma = %f\n", pDock->iMaxDockWidth, gamma);
94
h = hi + h0 / (1 + gamma);
97
pDock->iDecorationsHeight = h;
98
//g_print ("h : %.2f -> %d\n", h, pDock->iDecorationsHeight);
100
pDock->iDecorationsWidth = pDock->iMaxDockWidth;
103
double fRatio = (pDock->iRefCount == 0 && pDock->iVisibility == CAIRO_DOCK_VISI_RESERVE ? 1. : pDock->container.fRatio); // prevent the dock from resizing itself and all the maximized windows each time an icon is removed/inserted.
104
pDock->iMinDockHeight = myDocksParam.iDockLineWidth + myDocksParam.iFrameMargin + /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * fRatio + pDock->iMaxIconHeight * fRatio;
106
//double gamma_min = pDock->fFlatDockWidth / 2 / H;
107
//double dw_min = h * gamma_min + r + (l+(r==0)*2)*sqrt(1+gamma_min*gamma_min);
108
//cairo_dock_calculate_extra_width_for_trapeze (pDock->iDecorationsHeight, fInclination, myDocksParam.iDockRadius, myDocksParam.iDockLineWidth);
110
// on charge les separateurs plat.
111
//g_print ("%d / %d\n", myIconsParam.iSeparatorType, myIconsParam.iSeparatorType);
112
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR)
114
cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
117
pDock->iMinDockWidth = MAX (1, pDock->fFlatDockWidth); // fFlatDockWidth peut etre meme negatif avec un dock vide.
119
pDock->iActiveWidth = iMaxDockWidth;
120
pDock->iActiveHeight = pDock->iMaxDockHeight;
121
if (! pDock->container.bIsHorizontal)
122
pDock->iMaxDockHeight += 8*myIconsParam.iLabelSize; // vertical dock, add some padding to draw the labels.
125
static void cd_rendering_calculate_construction_parameters_3D_plane (Icon *icon, double fOffsetX, double fReflectionOffsetY)
127
icon->fDrawX = icon->fX + fOffsetX;
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
double hi = /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * pDock->container.fRatio + myDocksParam.iFrameMargin;
147
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
148
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
149
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
151
double fHeight, fBigWidth, fLittleWidth;
154
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + 2*myDocksParam.iDockLineWidth;
155
fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
156
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
160
fHeight = pDock->iDecorationsHeight - myDocksParam.iDockLineWidth;
161
fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi);
162
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + hi - fHeight);
164
double fDeltaXLeft = fHeight * fLeftInclination;
165
double fDeltaXRight = fHeight * fRightInclination;
166
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
168
double fDockOffsetX, fDockOffsetY;
171
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
172
fDockOffsetY = pDock->container.iHeight - fHeight - (bBackGround ? myDocksParam.iDockLineWidth + hi : -.5*myDocksParam.iDockLineWidth);
176
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
177
fDockOffsetY = pDock->container.iHeight - fHeight - myDocksParam.iDockLineWidth;
180
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut gauche.
181
cairo_move_to (pCairoContext, 0, 0); // coin haut gauche.
183
cairo_rel_line_to (pCairoContext, fLittleWidth, 0);
184
cairo_rel_line_to (pCairoContext, fDeltaXRight, fHeight);
185
cairo_rel_line_to (pCairoContext, - fBigWidth, 0);
186
cairo_rel_line_to (pCairoContext, - fDeltaXLeft, - fHeight);
188
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR)
190
cairo_clip (pCairoContext);
191
cairo_translate (pCairoContext, MIN (0, (fHeight + hi) * fLeftInclination), 0);
192
cairo_scale (pCairoContext, (fLittleWidth + MAX (fabs (fDeltaXRight), fabs (fDeltaXLeft)))/1, 1.);
193
cairo_set_source_surface (pCairoContext, my_pFlatSeparatorSurface[CAIRO_DOCK_HORIZONTAL], 0, 0);
197
static void cd_rendering_draw_3D_separator_edge (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bBackGround)
199
double hi = /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * pDock->container.fRatio + myDocksParam.iFrameMargin;
200
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
201
double fLeftInclination = (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
202
double fRightInclination = (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
204
double fHeight, fLittleWidth;
205
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi - 0.5*myDocksParam.iDockLineWidth : hi + 1.5*myDocksParam.iDockLineWidth);
206
//fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
207
fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
209
double fDeltaXLeft = fHeight * fLeftInclination;
210
double fDeltaXRight = fHeight * fRightInclination;
211
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
213
double fDockOffsetX, fDockOffsetY;
214
fDockOffsetY = (bBackGround ? 2.*myDocksParam.iDockLineWidth : - 1.0*myDocksParam.iDockLineWidth);
216
fDockOffsetX = (bBackGround ? .5*myDocksParam.iDockLineWidth * fLeftInclination + 1.*fLeftInclination : - 0.5 * myDocksParam.iDockLineWidth * fLeftInclination);
217
//fDockOffsetX = -.5*myDocksParam.iDockLineWidth;
220
cairo_translate (pCairoContext, fDockOffsetX, fDockOffsetY); // coin haut droit.
222
cairo_move_to (pCairoContext, fLittleWidth, 0);
223
cairo_rel_line_to (pCairoContext, fDeltaXRight, fHeight);
225
cairo_move_to (pCairoContext, 0, 0);
226
cairo_rel_line_to (pCairoContext, fDeltaXLeft, fHeight);
230
static void cd_rendering_draw_3D_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
232
if (pDock->container.bIsHorizontal)
234
if (! pDock->container.bDirectionUp)
236
cairo_translate (pCairoContext, 0., pDock->container.iHeight);
237
cairo_scale (pCairoContext, 1., -1.);
242
cairo_translate (pCairoContext, pDock->container.iHeight/2, pDock->container.iWidth/2);
243
cairo_rotate (pCairoContext, G_PI/2);
244
cairo_translate (pCairoContext, -pDock->container.iWidth/2, -pDock->container.iHeight/2);
245
if (pDock->container.bDirectionUp)
247
cairo_translate (pCairoContext, 0., pDock->container.iHeight);
248
cairo_scale (pCairoContext, 1., -1.);
251
cd_rendering_make_3D_separator (icon, pCairoContext, pDock, (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR), bBackGround);
253
if (myIconsParam.iSeparatorType == CAIRO_DOCK_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 (myDocksParam.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, myDocksParam.iDockLineWidth);
265
if (myDocksParam.bUseDefaultColors)
266
gldi_style_colors_set_line_color (pCairoContext);
268
gldi_color_set_cairo (pCairoContext, &myDocksParam.fLineColor);
269
cairo_stroke (pCairoContext);
274
///cairo_fill (pCairoContext);
275
cairo_paint (pCairoContext);
280
static void cd_rendering_render_3D_plane (cairo_t *pCairoContext, CairoDock *pDock)
282
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
283
h = pDock->iDecorationsHeight;
287
//\____________________ On definit la position du cadre.
288
double dx, dy; // position du coin haut gauche du cadre.
289
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
291
double Ws = pDock->container.iWidth;
293
double W = Ws - 2 * (r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
295
double b = H + hi + h0 - W / 2;
297
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
298
h = hi + h0 / (1 + gamma);
299
//g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
302
//g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
307
w = cairo_dock_get_current_dock_width_linear (pDock);
309
dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
310
h = pDock->iDecorationsHeight;
311
Icon *pFirstIcon = cairo_dock_get_first_icon (pDock->icons);
312
dx = (pFirstIcon != NULL ? pFirstIcon->fX - 0*myDocksParam.iFrameMargin : r);
313
dx += (pDock->iOffsetForExtend * (pDock->fAlign - .5) * 2);
317
if (pDock->container.bDirectionUp)
320
dy = pDock->container.iHeight - pDock->iDecorationsHeight - 1.5 * l;
325
dy = pDock->iDecorationsHeight + 1.5 * l;
328
//\____________________ On trace le cadre.
329
cairo_save (pCairoContext);
331
double fDeltaXTrapeze = cairo_dock_draw_frame (pCairoContext, r, l, w, pDock->iDecorationsHeight, dx, dy, sens, gamma, pDock->container.bIsHorizontal, myDocksParam.bRoundedBottomCorner);
333
//\____________________ On dessine les decorations dedans.
334
dy = (pDock->container.bDirectionUp ? pDock->container.iHeight - pDock->iDecorationsHeight - l : l);
335
cairo_dock_render_decorations_in_frame (pCairoContext, pDock, dy, dx-fDeltaXTrapeze, w+2*fDeltaXTrapeze);
337
//\____________________ On dessine le cadre.
340
cairo_set_line_width (pCairoContext, l);
341
if (myDocksParam.bUseDefaultColors)
342
gldi_style_colors_set_line_color (pCairoContext);
344
gldi_color_set_cairo (pCairoContext, &myDocksParam.fLineColor);
345
cairo_stroke (pCairoContext);
348
cairo_new_path (pCairoContext);
350
/// donner un effet d'epaisseur => chaud du slip avec les separateurs physiques !
353
cairo_restore (pCairoContext);
355
//\____________________ On dessine la ficelle qui les joint.
356
if (myIconsParam.iStringLineWidth > 0)
357
cairo_dock_draw_string (pCairoContext, pDock, myIconsParam.iStringLineWidth, FALSE, (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR || myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR));
359
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
360
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
361
if (pFirstDrawnElement == NULL)
364
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
367
GList *ic = pFirstDrawnElement;
368
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR || myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
370
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
375
if (icon->cFileName == NULL && CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
377
cairo_save (pCairoContext);
378
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
379
cairo_restore (pCairoContext);
382
ic = cairo_dock_get_next_element (ic, pDock->icons);
383
} while (ic != pFirstDrawnElement);
389
if (icon->cFileName != NULL || ! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
391
cairo_save (pCairoContext);
392
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
393
cairo_restore (pCairoContext);
396
ic = cairo_dock_get_next_element (ic, pDock->icons);
397
} while (ic != pFirstDrawnElement);
399
if (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
405
if (icon->cFileName == NULL && CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
407
cairo_save (pCairoContext);
408
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
409
cairo_restore (pCairoContext);
412
ic = cairo_dock_get_next_element (ic, pDock->icons);
413
} while (ic != pFirstDrawnElement);
422
cairo_save (pCairoContext);
423
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
424
cairo_restore (pCairoContext);
426
ic = cairo_dock_get_next_element (ic, pDock->icons);
427
} while (ic != pFirstDrawnElement);
431
static gboolean _cd_separator_is_impacted (Icon *icon, CairoDock *pDock, double fXMin, double fXMax, gboolean bBackGround, gboolean bIncludeEdges)
433
double hi = /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * pDock->container.fRatio + myDocksParam.iFrameMargin;
434
hi = (pDock->container.bDirectionUp ? pDock->container.iHeight - (icon->fDrawY + icon->fHeight * icon->fScale) : icon->fDrawY);
435
double fLeftInclination = fabs (icon->fDrawX - pDock->container.iWidth / 2) / iVanishingPointY;
436
double fRightInclination = fabs (icon->fDrawX + icon->fWidth * icon->fScale - pDock->container.iWidth / 2) / iVanishingPointY;
441
fHeight = (bBackGround ? pDock->iDecorationsHeight - hi : hi) + (bIncludeEdges ? myDocksParam.iDockLineWidth : 0);
442
//fBigWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY : iVanishingPointY + fHeight);
443
//fLittleWidth = fabs (fRightInclination - fLeftInclination) * (bBackGround ? iVanishingPointY - fHeight : iVanishingPointY);
447
fHeight = pDock->iDecorationsHeight;
448
//fBigWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY + fHeight);
449
//fLittleWidth = fabs (fRightInclination - fLeftInclination) * (iVanishingPointY - fHeight);
451
//double fDeltaXLeft = fHeight * fLeftInclination;
452
//double fDeltaXRight = fHeight * fRightInclination;
453
//double fDeltaX = MAX (fDeltaXLeft, fDeltaXRight);
454
//g_print ("fBigWidth : %.2f ; fLittleWidth : %.2f\n", fBigWidth, fLittleWidth);
458
double fDockOffsetX, fDockOffsetY;
459
if (pDock->container.bDirectionUp)
463
fDockOffsetY = pDock->container.iHeight - fHeight - (bBackGround ? myDocksParam.iDockLineWidth + hi : 0);
465
fDockOffsetY = pDock->container.iHeight - fHeight;
471
fDockOffsetY = fHeight + (bBackGround ? myDocksParam.iDockLineWidth + hi : 0);
473
fDockOffsetY = fHeight;
477
fDockOffsetX = icon->fDrawX - (bBackGround ? fHeight * fLeftInclination : 0);
479
fDockOffsetX = icon->fDrawX - (fHeight - hi) * fLeftInclination;
481
double fXLeft, fXRight;
482
if (icon->fDrawX + icon->fWidth * icon->fScale / 2 > pDock->container.iWidth / 2) // on est a droite.
488
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
489
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
493
fXLeft = icon->fDrawX;
494
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
499
fXLeft = icon->fDrawX - (fHeight - hi) * fLeftInclination;
500
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + hi * fRightInclination;
509
fXLeft = icon->fDrawX;
510
fXRight = icon->fDrawX + icon->fWidth * icon->fScale + fHeight * fRightInclination;
514
fXLeft = icon->fDrawX - fHeight * fLeftInclination;
515
fXRight = icon->fDrawX + icon->fWidth * icon->fScale;
520
fXLeft = icon->fDrawX - hi * fLeftInclination;
521
fXRight = icon->fDrawX + icon->fWidth * icon->fScale +(fHeight - hi) * fRightInclination;
525
return (fXLeft <= fXMax && floor (fXRight) > fXMin);
528
static void cd_rendering_render_optimized_3D_plane (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
530
//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);
531
double fLineWidth = myDocksParam.iDockLineWidth;
532
double fMargin = myDocksParam.iFrameMargin;
533
int iHeight = pDock->container.iHeight;
535
//\____________________ On dessine les decorations du fond sur la portion de fenetre.
536
cairo_save (pCairoContext);
538
double fDockOffsetX, fDockOffsetY;
539
if (pDock->container.bIsHorizontal)
541
fDockOffsetX = pArea->x;
542
fDockOffsetY = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
546
fDockOffsetX = (pDock->container.bDirectionUp ? iHeight - pDock->iDecorationsHeight - fLineWidth : fLineWidth);
547
fDockOffsetY = pArea->y;
550
//cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
551
if (pDock->container.bIsHorizontal)
552
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pArea->width, pDock->iDecorationsHeight);
554
cairo_rectangle (pCairoContext, fDockOffsetX, fDockOffsetY, pDock->iDecorationsHeight, pArea->height);
556
double fRadius = MIN (myDocksParam.iDockRadius, (pDock->iDecorationsHeight + myDocksParam.iDockLineWidth) / 2 - 1);
557
double fDeltaXTrapeze=0.;
559
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
561
fOffsetX = fRadius + fLineWidth / 2;
565
Icon *pFirstIcon = cairo_dock_get_first_icon (pDock->icons);
566
fOffsetX = (pFirstIcon != NULL ? pFirstIcon->fX - fMargin : fRadius + fLineWidth / 2);
568
double fDockWidth = cairo_dock_get_current_dock_width_linear (pDock);
569
if (pDock->backgroundBuffer.pSurface != NULL)
571
double fInclinationOnHorizon = (fDockWidth / 2) / iVanishingPointY;
572
double fRadius = myDocksParam.iDockRadius;
573
if (2*fRadius > pDock->iDecorationsHeight + fLineWidth)
574
fRadius = (pDock->iDecorationsHeight + fLineWidth) / 2 - 1;
575
double fDeltaXForLoop = fInclinationOnHorizon * (pDock->iDecorationsHeight + fLineWidth - (/**myDocksParam.bRoundedBottomCorner*/TRUE ? 2 : 1) * fRadius);
577
double cosa = 1. / sqrt (1 + fInclinationOnHorizon * fInclinationOnHorizon);
578
fDeltaXTrapeze = fDeltaXForLoop + fRadius * cosa;
580
double sina = cosa * fInclinationOnHorizon;
581
fDeltaXTrapeze = fInclinationOnHorizon * (pDock->iDecorationsHeight - (FALSE ? 2 : 1-sina) * fRadius) + fRadius * (FALSE ? 1 : cosa);
583
cairo_dock_render_decorations_in_frame (pCairoContext, pDock, pDock->container.bIsHorizontal ? fDockOffsetY : fDockOffsetX, fOffsetX-fDeltaXTrapeze, fDockWidth+2*fDeltaXTrapeze);
586
//\____________________ On dessine la partie du cadre qui va bien.
587
cairo_new_path (pCairoContext);
588
cairo_set_line_width (pCairoContext, fLineWidth);
589
if (myDocksParam.bUseDefaultColors)
590
gldi_style_colors_set_line_color (pCairoContext);
592
gldi_color_set_cairo (pCairoContext, &myDocksParam.fLineColor);
593
if (pDock->container.bIsHorizontal)
595
cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY - 0.5*fLineWidth);
596
cairo_rel_line_to (pCairoContext, pArea->width, 0);
597
cairo_stroke (pCairoContext);
599
cairo_new_path (pCairoContext);
600
cairo_move_to (pCairoContext, fDockOffsetX, (pDock->container.bDirectionUp ? iHeight - 0.5*fLineWidth : pDock->iDecorationsHeight + 1.5 * fLineWidth));
601
cairo_rel_line_to (pCairoContext, pArea->width, 0);
605
cairo_move_to (pCairoContext, fDockOffsetX - .5*fLineWidth, fDockOffsetY);
606
cairo_rel_line_to (pCairoContext, 0, pArea->height);
607
cairo_stroke (pCairoContext);
609
cairo_new_path (pCairoContext);
610
cairo_move_to (pCairoContext, (pDock->container.bDirectionUp ? iHeight - fLineWidth / 2 : pDock->iDecorationsHeight + 1.5 * fLineWidth), fDockOffsetY);
611
cairo_rel_line_to (pCairoContext, 0, pArea->height);
613
cairo_stroke (pCairoContext);
615
cairo_restore (pCairoContext);
617
//\____________________ On dessine les icones impactees.
618
GList *pFirstDrawnElement = pDock->icons;
619
if (pFirstDrawnElement != NULL)
621
double fXMin = (pDock->container.bIsHorizontal ? pArea->x : pArea->y), fXMax = (pDock->container.bIsHorizontal ? pArea->x + pArea->width : pArea->y + pArea->height);
622
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
623
double fXLeft, fXRight;
625
GList *ic = pFirstDrawnElement;
627
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR || myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
629
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_SQUARE);
634
if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon) && icon->cFileName == NULL)
636
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)))
638
cairo_save (pCairoContext);
639
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
640
cairo_restore (pCairoContext);
644
ic = cairo_dock_get_next_element (ic, pDock->icons);
645
} while (ic != pFirstDrawnElement);
650
if (! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon) || icon->cFileName != NULL)
652
fXLeft = icon->fDrawX + icon->fScale + 1;
653
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
655
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
657
//if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
660
// icon->fAlpha = .25;
662
cairo_save (pCairoContext);
663
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
664
cairo_restore (pCairoContext);
667
ic = cairo_dock_get_next_element (ic, pDock->icons);
668
} while (ic != pFirstDrawnElement);
670
if (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
676
if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon) && icon->cFileName == NULL)
678
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)))
680
cairo_save (pCairoContext);
681
cd_rendering_draw_3D_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
682
cairo_restore (pCairoContext);
686
ic = cairo_dock_get_next_element (ic, pDock->icons);
687
} while (ic != pFirstDrawnElement);
695
fXLeft = icon->fDrawX + icon->fScale + 1;
696
fXRight = icon->fDrawX + (icon->fWidth - 1) * icon->fScale * icon->fWidthFactor - 1;
698
if (fXLeft <= fXMax && floor (fXRight) > fXMin)
700
//if (icon->fDrawX >= 0 && icon->fDrawX + icon->fWidth * icon->fScale <= pDock->container.iWidth)
703
// icon->fAlpha = .25;
705
cairo_save (pCairoContext);
706
cairo_dock_render_one_icon (icon, pDock, pCairoContext, fDockMagnitude, TRUE);
707
cairo_restore (pCairoContext);
709
ic = cairo_dock_get_next_element (ic, pDock->icons);
710
} while (ic != pFirstDrawnElement);
716
static Icon *cd_rendering_calculate_icons_3D_plane (CairoDock *pDock)
718
Icon *pPointedIcon = cairo_dock_apply_wave_effect_linear (pDock);
720
//\____________________ On calcule les position/etirements/alpha des icones.
721
double fReflectionOffsetY = (pDock->container.bDirectionUp ? -1 : 1) * /**myIconsParam.fReflectSize*/pDock->iIconSize * myIconsParam.fReflectHeightRatio * pDock->container.fRatio;
722
double offsetx = pDock->iOffsetForExtend * (pDock->fAlign - .5) * 2;
725
for (ic = pDock->icons; ic != NULL; ic = ic->next)
728
cd_rendering_calculate_construction_parameters_3D_plane (icon, offsetx, fReflectionOffsetY);
731
cairo_dock_check_if_mouse_inside_linear (pDock);
733
cairo_dock_check_can_drop_linear (pDock);
740
static void cd_rendering_render_3D_plane_opengl (CairoDock *pDock)
742
//\_____________ On definit notre cadre.
743
_define_parameters (hi, h0, H, l, r, gamma, h, w, dw);
744
h = pDock->iDecorationsHeight;
749
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
751
double Ws = pDock->container.iWidth;
752
double W = Ws - 2 * r;
754
double b = H + hi + h0 - W / 2;
756
gamma = (-b + sqrt (b * b - 4 * a * c)) / 2 / a;
757
h = hi + h0 / (1 + gamma);
758
//g_print ("h : %.2f (=) %d\n", h, pDock->iDecorationsHeight);
761
//g_print ("dw : %.2f (=) %.2f\n", dw, h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma));
766
w = cairo_dock_get_current_dock_width_linear (pDock);
768
dw = h * gamma + r + (l+(r==0)*2)*sqrt(1+gamma*gamma);
769
h = pDock->iDecorationsHeight;
770
Icon *pFirstIcon = cairo_dock_get_first_icon (pDock->icons);
771
dx = (pFirstIcon != NULL ? pFirstIcon->fX - myDocksParam.iFrameMargin : r);
772
dx += (pDock->iOffsetForExtend * (pDock->fAlign - .5) * 2);
775
//\_____________ On genere les coordonnees du contour.
776
double fDeltaXTrapeze;
777
const CairoDockGLPath *pFramePath = cairo_dock_generate_trapeze_path (w - (/**myDocksParam.bRoundedBottomCorner*/TRUE ? 0 : 2*l/gamma), h+l, r, myDocksParam.bRoundedBottomCorner, gamma, &fDeltaXTrapeze);
778
dx = dx - fDeltaXTrapeze;
779
dy = pDock->iDecorationsHeight + 1.5*l;
781
//\_____________ On remplit avec le fond.
783
cairo_dock_set_container_orientation_opengl (CAIRO_CONTAINER (pDock));
784
glTranslatef (dx + (w+2*fDeltaXTrapeze)/2,
788
cairo_dock_fill_gl_path (pFramePath, pDock->backgroundBuffer.iTexture);
790
//\_____________ On trace le contour.
794
if (myDocksParam.bUseDefaultColors)
795
gldi_style_colors_set_line_color (NULL);
797
gldi_color_set_opengl (&myDocksParam.fLineColor);
798
_cairo_dock_set_blend_alpha ();
799
cairo_dock_stroke_gl_path (pFramePath, TRUE);
803
//\____________________ On dessine la ficelle qui les joint.
804
if (myIconsParam.iStringLineWidth > 0)
805
cairo_dock_draw_string_opengl (pDock, myIconsParam.iStringLineWidth, FALSE, (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR || myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR));
807
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
808
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
809
if (pFirstDrawnElement == NULL)
812
double fDockMagnitude = cairo_dock_calculate_magnitude (pDock->iMagnitudeIndex);
814
GList *ic = pFirstDrawnElement;
816
///glLoadIdentity ();
817
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR || myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
823
if (icon->cFileName == NULL && CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
826
if (myIconsParam.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR)
827
cd_rendering_draw_flat_separator_opengl (icon, pDock);
829
cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, NULL, NULL);
833
ic = cairo_dock_get_next_element (ic, pDock->icons);
834
} while (ic != pFirstDrawnElement);
840
if (icon->cFileName != NULL || ! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
843
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
847
ic = cairo_dock_get_next_element (ic, pDock->icons);
848
} while (ic != pFirstDrawnElement);
850
if (myIconsParam.iSeparatorType == CAIRO_DOCK_PHYSICAL_SEPARATOR)
856
if (icon->cFileName == NULL && CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (icon))
859
cd_rendering_draw_physical_separator_opengl (icon, pDock, FALSE, NULL, NULL);
863
ic = cairo_dock_get_next_element (ic, pDock->icons);
864
} while (ic != pFirstDrawnElement);
874
cairo_dock_render_one_icon_opengl (icon, pDock, fDockMagnitude, TRUE);
877
ic = cairo_dock_get_next_element (ic, pDock->icons);
878
} while (ic != pFirstDrawnElement);
883
void cd_rendering_register_3D_plane_renderer (const gchar *cRendererName)
885
CairoDockRenderer *pRenderer = g_new0 (CairoDockRenderer, 1);
887
pRenderer->compute_size = cd_rendering_calculate_max_dock_size_3D_plane;
888
pRenderer->calculate_icons = cd_rendering_calculate_icons_3D_plane;
889
pRenderer->render = cd_rendering_render_3D_plane;
890
pRenderer->render_optimized = cd_rendering_render_optimized_3D_plane;
891
pRenderer->render_opengl = cd_rendering_render_3D_plane_opengl;
892
pRenderer->set_subdock_position = cairo_dock_set_subdock_position_linear;
894
pRenderer->bUseReflect = TRUE;
895
pRenderer->cDisplayedName = D_ (cRendererName);
896
pRenderer->cReadmeFilePath = g_strdup (MY_APPLET_SHARE_DATA_DIR"/readme-3D-plane-view");
897
pRenderer->cPreviewFilePath = g_strdup (MY_APPLET_SHARE_DATA_DIR"/preview-3D-plane.jpg");
899
cairo_dock_register_renderer (cRendererName, pRenderer);