34
34
static double *s_pReferenceCurveS = NULL;
35
35
static double *s_pReferenceCurveX = NULL;
36
36
static double *s_pReferenceCurveY = NULL;
37
int iVanishingPointY = 200;
37
extern int iVanishingPointY;
39
extern CDSpeparatorType my_iDrawSeparator3D;
39
extern CairoDockSpeparatorType my_iDrawSeparator3D;
40
40
extern double my_fSeparatorColor[4];
42
42
extern gdouble my_fCurveCurvature;
43
43
extern gint my_iCurveAmplitude;
45
45
extern cairo_surface_t *my_pFlatSeparatorSurface[2];
46
extern GLuint my_iFlatSeparatorTexture;
49
48
//const guint curveOffsetX = 75;
61
60
double ti = .5 * (1. - sqrt (MAX (1. - 4./3 * hi / h, 0.01)));\
62
61
double xi = xCurve (my_fCurveCurvature, ti);\
65
void cd_rendering_calculate_max_dock_size_curve (CairoDock *pDock)
64
static void cd_rendering_calculate_reference_curve (double alpha)
66
if (s_pReferenceCurveS == NULL)
68
s_pReferenceCurveS = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
71
if (s_pReferenceCurveX == NULL)
73
s_pReferenceCurveX = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
76
if (s_pReferenceCurveY == NULL)
78
s_pReferenceCurveY = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
83
for (i = 0; i < RENDERING_INTERPOLATION_NB_PTS+1; i ++)
85
s = (double) i / RENDERING_INTERPOLATION_NB_PTS;
87
s_pReferenceCurveS[i] = s;
88
s_pReferenceCurveX[i] = xCurve (my_fCurveCurvature, s);
89
s_pReferenceCurveY[i] = yCurve (s);
93
static double cd_rendering_interpol_curve_parameter (double x)
95
return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveS);
98
static double cd_rendering_interpol_curve_height (double x)
100
return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveY);
103
static void cd_rendering_calculate_max_dock_size_curve (CairoDock *pDock)
67
105
static double fCurveCurvature = 0;
68
106
if (s_pReferenceCurveS == NULL || my_fCurveCurvature != fCurveCurvature)
111
149
my_iDrawSeparator3D = myIcons.iSeparatorType;
112
150
memcpy (my_fSeparatorColor, myIcons.fSeparatorColor, 4*sizeof(double));
113
if (myIcons.iSeparatorType == CD_FLAT_SEPARATOR)
151
if (myIcons.iSeparatorType == CAIRO_DOCK_FLAT_SEPARATOR)
115
153
cd_rendering_load_flat_separator (CAIRO_CONTAINER (g_pMainDock));
119
pDock->iMinDockWidth = pDock->fFlatDockWidth;
157
pDock->iMinDockWidth = MAX (1, pDock->fFlatDockWidth); // fFlatDockWidth peut etre meme negatif avec un dock vide.
319
357
cairo_rel_line_to (pCairoContext, - fBigWidth, 0);
320
358
cairo_rel_line_to (pCairoContext, - fDeltaXLeft, - sens * fHeight);
322
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
360
if (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR)
324
362
if (! pDock->container.bDirectionUp)
325
363
cairo_scale (pCairoContext, 1, -1);
336
374
cairo_rel_line_to (pCairoContext, 0, - fBigWidth);
337
375
cairo_rel_line_to (pCairoContext, - sens * fHeight, - fDeltaXLeft);
339
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
377
if (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR)
341
379
if (! pDock->container.bDirectionUp)
342
380
cairo_scale (pCairoContext, -1, 1);
421
459
static void cd_rendering_draw_3D_curve_separator (Icon *icon, cairo_t *pCairoContext, CairoDock *pDock, gboolean bHorizontal, gboolean bBackGround)
423
cd_rendering_make_3D_curve_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR), bBackGround);
461
cd_rendering_make_3D_curve_separator (icon, pCairoContext, pDock, (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR), bBackGround);
425
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
463
if (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)
427
465
cairo_set_operator (pCairoContext, CAIRO_OPERATOR_DEST_OUT);
428
466
cairo_set_source_rgba (pCairoContext, 0.0, 0.0, 0.0, 1.0);
464
502
// on trace la ligne du bas
465
503
cairo_rel_line_to (pCairoContext, 0, - fFrameWidth);
467
void cairo_dock_draw_curved_frame (cairo_t *pCairoContext, double fFrameWidth, double fControlHeight, double fDockOffsetX, double fDockOffsetY, gboolean bHorizontal, int sens)
505
static void cairo_dock_draw_curved_frame (cairo_t *pCairoContext, double fFrameWidth, double fControlHeight, double fDockOffsetX, double fDockOffsetY, gboolean bHorizontal, int sens)
470
508
cairo_dock_draw_curved_frame_horizontal (pCairoContext, fFrameWidth, fControlHeight, fDockOffsetX, fDockOffsetY, sens);
472
510
cairo_dock_draw_curved_frame_vertical (pCairoContext, fFrameWidth, fControlHeight, fDockOffsetX, fDockOffsetY, sens);
476
void cd_rendering_calculate_reference_curve (double alpha)
478
if (s_pReferenceCurveS == NULL)
480
s_pReferenceCurveS = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
483
if (s_pReferenceCurveX == NULL)
485
s_pReferenceCurveX = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
488
if (s_pReferenceCurveY == NULL)
490
s_pReferenceCurveY = g_new (double, RENDERING_INTERPOLATION_NB_PTS+1);
495
for (i = 0; i < RENDERING_INTERPOLATION_NB_PTS+1; i ++)
497
s = (double) i / RENDERING_INTERPOLATION_NB_PTS;
499
s_pReferenceCurveS[i] = s;
500
s_pReferenceCurveX[i] = xCurve (my_fCurveCurvature, s);
501
s_pReferenceCurveY[i] = yCurve (s);
505
double cd_rendering_interpol_curve_parameter (double x)
507
return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveS);
510
double cd_rendering_interpol_curve_height (double x)
512
return cd_rendering_interpol (x, s_pReferenceCurveX, s_pReferenceCurveY);
516
void cd_rendering_render_curve (cairo_t *pCairoContext, CairoDock *pDock)
513
static void cd_rendering_render_curve (cairo_t *pCairoContext, CairoDock *pDock)
518
515
//\____________________ On definit la position du cadre.
519
516
double fLineWidth = myBackground.iDockLineWidth;
570
567
//\____________________ On dessine la ficelle qui les joint.
571
568
if (myIcons.iStringLineWidth > 0)
572
cairo_dock_draw_string (pCairoContext, pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
569
cairo_dock_draw_string (pCairoContext, pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR || my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR));
574
571
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
575
572
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
581
578
GList *ic = pFirstDrawnElement;
583
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
580
if (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR || my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)
585
582
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_BUTT);
611
608
ic = cairo_dock_get_next_element (ic, pDock->icons);
612
609
} while (ic != pFirstDrawnElement);
614
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
611
if (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)
739
736
return (fXLeft <= fXMax && floor (fXRight) > fXMin);
742
void cd_rendering_render_optimized_curve (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
739
static void cd_rendering_render_optimized_curve (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea)
744
741
//\____________________ On trace le cadre.
745
742
double fLineWidth = myBackground.iDockLineWidth;
894
891
GList *ic = pFirstDrawnElement;
896
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
893
if (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR || my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)
898
895
cairo_set_line_cap (pCairoContext, CAIRO_LINE_CAP_BUTT);
903
900
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
905
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
902
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, TRUE, (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)))
907
904
cairo_save (pCairoContext);
908
905
cd_rendering_draw_3D_curve_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, TRUE);
938
935
ic = cairo_dock_get_next_element (ic, pDock->icons);
939
936
} while (ic != pFirstDrawnElement);
941
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
938
if (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)
947
944
if (CAIRO_DOCK_IS_SEPARATOR (icon) && icon->cFileName == NULL)
949
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)))
946
if (_cd_separator_is_impacted (icon, pDock, fXMin, fXMax, FALSE, (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)))
951
948
cairo_save (pCairoContext);
952
949
cd_rendering_draw_3D_curve_separator (icon, pCairoContext, pDock, pDock->container.bIsHorizontal, FALSE);
1071
1068
#define DELTA_ROUND_DEGREE 1
1072
1069
#define RADIAN (G_PI / 180.0) // Conversion Radian/Degres
1073
1070
#define P(t,p,q,r,s) (1-t) * (1-t) * (1-t) * p + 3 * t * (1-t) * (1 - t) * q + 3 * t * t * (1-t) * r + t * t * t * s
1074
GLfloat *cairo_dock_generate_curve_path (double fRelativeControlHeight, int *iNbPoints)
1071
const CairoDockGLPath *cairo_dock_generate_curve_path (double fRelativeControlHeight)
1076
//static GLfloat pVertexTab[((180/DELTA_ROUND_DEGREE+1)+1)*3];
1073
static CairoDockGLPath *pPath = NULL;
1077
double xp = -w, xq = - my_fCurveCurvature * w, xr = - xq, xs = - xp;
1078
double yp = 0., yq = fRelativeControlHeight, yr = yq, ys = yp;
1079
int iNbPoints = 180/DELTA_ROUND_DEGREE;
1082
pPath = cairo_dock_new_gl_path (iNbPoints+1, xp, yp, 1., 1.);
1085
cairo_dock_gl_path_move_to (pPath, xp, yp);
1088
cairo_dock_gl_path_curve_to (pPath, iNbPoints, xq, yq, xr, yr, xs, ys);
1090
/** //static GLfloat pVertexTab[((180/DELTA_ROUND_DEGREE+1)+1)*3];
1077
1091
_cairo_dock_define_static_vertex_tab ((180/DELTA_ROUND_DEGREE+1)+1);
1079
1093
(1 - my_fCurveCurvature) * fFrameWidth / 2, -sens * fControlHeight,
1080
1094
(1 + my_fCurveCurvature) * fFrameWidth / 2, -sens * fControlHeight,
1082
1096
double w = 1. / 2;
1083
1097
double h = 1. / 2;
1084
1098
double xp = -w, xq = - my_fCurveCurvature * w, xr = - xq, xs = - xp;
1102
1116
//vy(i) = vy(0);
1104
1118
*iNbPoints = i+1;
1105
_cairo_dock_return_vertex_tab ();
1119
_cairo_dock_return_vertex_tab ();*/
1108
void cd_rendering_render_curve_opengl (CairoDock *pDock)
1124
static void cd_rendering_render_curve_opengl (CairoDock *pDock)
1110
1126
//\____________________ On definit la position du cadre.
1111
1127
double fLineWidth = myBackground.iDockLineWidth;
1115
1131
w = cairo_dock_get_current_dock_width_linear (pDock) - 2 * myBackground.iFrameMargin;
1116
1132
dw = w * xi / (1 - 2 * xi);
1119
1134
double dx, dy; // position de la pointe gauche.
1120
1135
if (cairo_dock_is_extended_dock (pDock)) // mode panel etendu.
1128
1143
Icon *pFirstIcon = cairo_dock_get_first_drawn_icon (pDock);
1129
1144
dx = (pFirstIcon != NULL ? pFirstIcon->fDrawX - dw : fLineWidth / 2);
1131
if (! pDock->container.bIsHorizontal)
1132
dx = pDock->container.iWidth - dx + 0;
1134
if ((pDock->container.bIsHorizontal && ! pDock->container.bDirectionUp) || (! pDock->container.bIsHorizontal && pDock->container.bDirectionUp))
1135
dy = pDock->container.iHeight - .5 * fLineWidth;
1137
dy = pDock->iDecorationsHeight + 1.5 * fLineWidth;
1147
dy = pDock->iDecorationsHeight + 1.5 * fLineWidth;
1138
1148
double fFrameHeight = pDock->iDecorationsHeight + fLineWidth;
1140
//\____________________ On genere le cadre.
1142
GLfloat *pVertexTab = cairo_dock_generate_curve_path (4./3, &iNbVertex);
1150
//\_____________ On genere les coordonnees du contour.
1151
const CairoDockGLPath *pFramePath = cairo_dock_generate_curve_path (4./3);
1144
1153
//\________________ On met en place le clipping.
1145
1154
glDisable (GL_DEPTH_TEST);
1149
1158
glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); // on remplace tout ce qui est dedans.
1150
1159
glColorMask (FALSE, FALSE, FALSE, FALSE); // desactive l'ecriture dans toutes les composantes du Tampon Chromatique.
1152
double fEpsilon = (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR ? 2. : 0); // erreur d'arrondi quand tu nous tiens.
1161
//\_____________ On remplit avec le fond.
1162
double fEpsilon = (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR ? 2. : 0); // erreur d'arrondi quand tu nous tiens.
1153
1163
glPushMatrix ();
1154
cairo_dock_draw_frame_background_opengl (0,
1164
cairo_dock_set_container_orientation_opengl (CAIRO_CONTAINER (pDock));
1165
glTranslatef (dx + (w+2*dw)/2,
1168
glScalef (w + 2 * dw, fFrameHeight + fLineWidth + fEpsilon, 1.);
1169
cairo_dock_fill_gl_path (pFramePath, 0);
1171
/*cairo_dock_draw_frame_background_opengl (0,
1155
1172
w + 2 * dw, fFrameHeight + fLineWidth + fEpsilon,
1156
1173
dx, dy + (fLineWidth+fEpsilon)/2,
1157
1174
pVertexTab, iNbVertex,
1158
pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX); // le cadre est trace au milieu de la ligne, donc on augmente de l la hauteur (et donc de l/2 pixels la hauteur du cadre, car [-.5, .5]), et pour compenser on se translate de l/2.
1175
pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX); // le cadre est trace au milieu de la ligne, donc on augmente de l la hauteur (et donc de l/2 pixels la hauteur du cadre, car [-.5, .5]), et pour compenser on se translate de l/2.*/
1159
1176
glPopMatrix ();
1161
1178
glColorMask (TRUE, TRUE, TRUE, TRUE);
1166
1183
//\____________________ On dessine les decorations dedans.
1167
1184
glPushMatrix ();
1168
cairo_dock_draw_frame_background_opengl (g_pDockBackgroundBuffer.iTexture,
1185
cairo_dock_set_container_orientation_opengl (CAIRO_CONTAINER (pDock));
1186
glTranslatef (dx + (w+2*dw)/2,
1189
glScalef (w + 2 * dw, fFrameHeight, 1.);
1190
cairo_dock_fill_gl_path (pFramePath, pDock->backgroundBuffer.iTexture);
1191
/*cairo_dock_draw_frame_background_opengl (pDock->backgroundBuffer.iTexture,
1169
1192
w + 2 * dw, fFrameHeight,
1171
1194
pVertexTab, iNbVertex,
1172
pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX);
1195
pDock->container.bIsHorizontal, pDock->container.bDirectionUp, pDock->fDecorationsOffsetX);*/
1174
1197
//\____________________ On dessine le cadre.
1175
1198
if (fLineWidth > 0)
1176
cairo_dock_draw_current_path_opengl (fLineWidth, myBackground.fLineColor, iNbVertex);
1200
glLineWidth (fLineWidth);
1201
glColor4f (myBackground.fLineColor[0], myBackground.fLineColor[1], myBackground.fLineColor[2], myBackground.fLineColor[3]);
1202
_cairo_dock_set_blend_alpha ();
1203
cairo_dock_stroke_gl_path (pFramePath, TRUE);
1178
1205
glPopMatrix ();
1180
1207
//\____________________ On dessine la ficelle qui les joint.
1181
1208
if (myIcons.iStringLineWidth > 0)
1182
cairo_dock_draw_string_opengl (pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CD_FLAT_SEPARATOR || my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR));
1209
cairo_dock_draw_string_opengl (pDock, myIcons.iStringLineWidth, FALSE, (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR || my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR));
1184
1211
//\____________________ On dessine les icones et les etiquettes, en tenant compte de l'ordre pour dessiner celles en arriere-plan avant celles en avant-plan.
1185
1212
GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pDock->icons);
1203
1230
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
1205
1232
glPushMatrix ();
1206
if (my_iDrawSeparator3D == CD_FLAT_SEPARATOR)
1233
if (my_iDrawSeparator3D == CAIRO_DOCK_FLAT_SEPARATOR)
1207
1234
cd_rendering_draw_flat_separator_opengl (icon, pDock);
1209
1236
cd_rendering_draw_physical_separator_opengl (icon, pDock, TRUE, (ic->prev ? ic->prev->data : NULL), (ic->next ? ic->next->data : NULL));
1229
1256
ic = cairo_dock_get_next_element (ic, pDock->icons);
1230
1257
} while (ic != pFirstDrawnElement);
1232
if (my_iDrawSeparator3D == CD_PHYSICAL_SEPARATOR)
1259
if (my_iDrawSeparator3D == CAIRO_DOCK_PHYSICAL_SEPARATOR)