130
162
cairo_close_path (pCairoContext);
132
164
// On remplit le fond.
133
if (myDialogsParam.bUseDefaultColors)
134
gldi_style_colors_set_bg_color (pCairoContext);
136
cairo_set_source_rgba (pCairoContext, myDialogsParam.fBgColor[0], myDialogsParam.fBgColor[1], myDialogsParam.fBgColor[2], myDialogsParam.fBgColor[3]);
137
///cairo_fill_preserve (pCairoContext);
138
cairo_save (pCairoContext);
139
cairo_clip_preserve (pCairoContext);
140
gldi_style_colors_paint_bg_color (pCairoContext, pDialog->container.iWidth);
141
cairo_restore (pCairoContext);
165
cairo_set_source_rgba (pCairoContext, myDialogsParam.fDialogColor[0], myDialogsParam.fDialogColor[1], myDialogsParam.fDialogColor[2], myDialogsParam.fDialogColor[3]);
166
cairo_fill_preserve (pCairoContext);
143
168
// On trace le contour.
144
if (fLineWidth != 0) // draw the outline with same color as bg, but opaque
146
if (myDialogsParam.bUseDefaultColors)
147
gldi_style_colors_set_line_color (pCairoContext);
149
cairo_set_source_rgba (pCairoContext, myDialogsParam.fLineColor[0], myDialogsParam.fLineColor[1], myDialogsParam.fLineColor[2], myDialogsParam.fLineColor[3]);
150
cairo_set_line_width (pCairoContext, fLineWidth);
151
cairo_stroke (pCairoContext);
156
static void _render_menu (GtkWidget *pMenu, cairo_t *pCairoContext)
158
GldiMenuParams *pParams = g_object_get_data (G_OBJECT(pMenu), "gldi-params");
159
int iMarginPosition = -1;
160
int iAimedX = 0, iAimedY = 0;
161
int ah = CD_ARROW_HEIGHT;
162
if (pParams && pParams->pIcon) // main menu
164
iMarginPosition = pParams->iMarginPosition;
165
iAimedX = pParams->iAimedX;
166
iAimedY = pParams->iAimedY;
169
// draw the outline and set the clip
171
gtk_widget_get_allocation (pMenu, &alloc);
173
int w = alloc.width, h = alloc.height;
175
gdk_window_get_position (gtk_widget_get_window (gtk_widget_get_toplevel(pMenu)), &x, &y);
177
double fRadius = CD_RADIUS, fLineWidth = myDialogsParam.iLineWidth;
178
double fDockOffsetX = fRadius + fLineWidth/2;
179
double fDockOffsetY = fLineWidth/2;
180
double fFrameWidth, fFrameHeight;
181
fFrameWidth = w - 2*fRadius - fLineWidth;
182
fFrameHeight = h - fLineWidth;
183
switch (iMarginPosition)
203
double fTipHeight = ah + fRadius; // we want the tip of the arrow to reach the border, not the middle of the stroke
204
double dh = fTipHeight + fRadius;
205
int iDeltaIconX = 0, iDeltaIconY = 0;
207
switch (iMarginPosition)
211
dh = MIN (dh, .3 * w);
212
iDeltaIconX = iAimedX - (x + w/2);
213
if (fabs (iDeltaIconX) < 3) // filter useless tiny delta (and rounding errors).
215
if (iDeltaIconX != 0) // on va limiter la courbature du petit cote.
217
double dhmin = dh * MAX (1. - fabs (iDeltaIconX) / (w/2), .5);
218
if (iDeltaIconX > 0) // pointe decale vers la droite.
236
dh = MIN (dh, .3 * h);
237
iDeltaIconY = iAimedY - (y + h/2);
238
if (fabs (iDeltaIconY) < 3) // filter useless tiny delta (and rounding errors).
240
if (iDeltaIconY != 0) // on va limiter la courbature du petit cote.
242
double dhmin = dh * MAX (1. - fabs (iDeltaIconY) / (h/2), .5);
243
if (iDeltaIconY > 0) // pointe decale vers la droite.
263
if (iMarginPosition == 1) // top arrow
265
cairo_move_to (pCairoContext, fLineWidth/2, fTipHeight);
266
cairo_rel_curve_to (pCairoContext,
268
(w - fLineWidth)/2 + iDeltaIconX, - (fTipHeight - dh2),
269
(w - fLineWidth)/2 + iDeltaIconX, - fTipHeight);
271
cairo_rel_curve_to (pCairoContext,
273
(w - fLineWidth)/2 - iDeltaIconX, fTipHeight - dh1,
274
(w - fLineWidth)/2 - iDeltaIconX, fTipHeight);
278
cairo_move_to (pCairoContext, fDockOffsetX, fDockOffsetY);
279
cairo_rel_line_to (pCairoContext, fFrameWidth, 0);
280
//\_________________ Coin haut droit.
281
if (iMarginPosition != 2) // not right arrow
282
cairo_arc (pCairoContext,
283
fDockOffsetX + fFrameWidth, fDockOffsetY + fRadius,
288
if (iMarginPosition == 2) // right arrow
290
cairo_rel_curve_to (pCairoContext,
292
fTipHeight - dh2, fFrameHeight/2 + iDeltaIconY,
293
fTipHeight, fFrameHeight/2 + iDeltaIconY);
295
cairo_rel_curve_to (pCairoContext,
297
- (fTipHeight - dh1), fFrameHeight/2 - iDeltaIconY,
298
- fTipHeight, fFrameHeight/2 - iDeltaIconY);
302
cairo_rel_line_to (pCairoContext, 0, (fFrameHeight - fRadius * 2));
303
//\_________________ Coin bas droit.
304
if (iMarginPosition != 0) // not bottom arrow
305
cairo_arc (pCairoContext,
306
fDockOffsetX + fFrameWidth, fDockOffsetY + fFrameHeight - fRadius,
311
if (iMarginPosition == 0) // bottom arrow
313
cairo_rel_curve_to (pCairoContext,
315
- (w - fLineWidth)/2 + iDeltaIconX, fTipHeight - dh1,
316
- (w - fLineWidth)/2 + iDeltaIconX, fTipHeight);
318
cairo_rel_curve_to (pCairoContext,
320
- (w - fLineWidth)/2 - iDeltaIconX, - (fTipHeight - dh2),
321
- (w - fLineWidth)/2 - iDeltaIconX, - fTipHeight);
325
cairo_rel_line_to (pCairoContext, - fFrameWidth, 0);
326
//\_________________ Coin bas gauche.
327
if (iMarginPosition != 3) // not left arrow
328
cairo_arc (pCairoContext,
329
fDockOffsetX, fDockOffsetY + fFrameHeight - fRadius,
334
if (iMarginPosition == 3) // left arrow
336
cairo_rel_curve_to (pCairoContext,
338
- fTipHeight + dh2, - (fFrameHeight/2 + iDeltaIconY),
339
- fTipHeight, -(fFrameHeight/2 + iDeltaIconY));
341
cairo_rel_curve_to (pCairoContext,
343
fTipHeight - dh1, -(fFrameHeight/2 - iDeltaIconY),
344
fTipHeight, - (fFrameHeight/2 - iDeltaIconY));
348
cairo_rel_line_to (pCairoContext, 0, (- fFrameHeight + fRadius * 2));
349
//\_________________ Coin haut gauche.
350
if (iMarginPosition != 1) // not top arrow
351
cairo_arc (pCairoContext,
352
fDockOffsetX, fDockOffsetY + fRadius,
357
// draw the background
358
if (myDialogsParam.bUseDefaultColors)
359
gldi_style_colors_set_bg_color (pCairoContext);
361
cairo_set_source_rgba (pCairoContext, myDialogsParam.fBgColor[0], myDialogsParam.fBgColor[1], myDialogsParam.fBgColor[2], myDialogsParam.fBgColor[3]);
362
cairo_save (pCairoContext);
363
cairo_clip_preserve (pCairoContext);
364
gldi_style_colors_paint_bg_color (pCairoContext, alloc.width);
365
cairo_restore (pCairoContext);
368
if (fLineWidth != 0) // draw the outline with same color as bg, but opaque
370
if (myDialogsParam.bUseDefaultColors)
371
gldi_style_colors_set_line_color (pCairoContext);
373
cairo_set_source_rgba (pCairoContext, myDialogsParam.fLineColor[0], myDialogsParam.fLineColor[1], myDialogsParam.fLineColor[2], myDialogsParam.fLineColor[3]);
374
cairo_stroke_preserve (pCairoContext);
377
cairo_clip (pCairoContext); // clip
380
static void _setup_menu (GtkWidget *pMenu)
382
GldiMenuParams *pParams = g_object_get_data (G_OBJECT(pMenu), "gldi-params");
383
pParams->iRadius = CD_RADIUS;
384
pParams->fAlign = CD_ALIGN;
385
pParams->iArrowHeight = CD_ARROW_HEIGHT;
169
cairo_set_source_rgba (pCairoContext, myConfig.fCurlyLineColor[0], myConfig.fCurlyLineColor[1], myConfig.fCurlyLineColor[2], myConfig.fCurlyLineColor[3]);
170
cairo_set_line_width (pCairoContext, fLineWidth);
171
cairo_stroke (pCairoContext);
388
175
void cd_decorator_register_curly (void)