most of the 2.X->3.0 commit (up to rev 4299) except for gtk2_ardour/editor_canvas...
[ardour.git] / libs / clearlooks-newer / clearlooks_draw_gummy.c
1 /* Clearlooks Gummy style
2  * Copyright (C) 2007 Andrea Cimitan
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Written by Andrea Cimitan <andrea.cimitan@gmail.com>
20  */
21
22 #include "clearlooks_draw.h"
23 #include "clearlooks_style.h"
24 #include "clearlooks_types.h"
25
26 #include "support.h"
27 #include <ge-support.h>
28
29 #include <cairo.h>
30
31 /* Normal shadings */
32 #define SHADE_TOP 1.08
33 #define SHADE_CENTER_TOP 1.02
34 #define SHADE_BOTTOM 0.94
35
36 /* Topleft highlight */
37 #define TOPLEFT_HIGHLIGHT_SHADE 1.3
38 #define TOPLEFT_HIGHLIGHT_ALPHA 0.4
39
40 /* Listview */
41 #define LISTVIEW_SHADE_TOP 1.06
42 #define LISTVIEW_SHADE_CENTER_TOP 1.02
43 #define LISTVIEW_SHADE_BOTTOM 0.96
44
45 /* Toolbar */
46 #define TOOLBAR_SHADE_TOP 1.04
47 #define TOOLBAR_SHADE_CENTER_TOP 1.01
48 #define TOOLBAR_SHADE_BOTTOM 0.97
49
50
51 static void
52 clearlooks_draw_gummy_gradient (cairo_t          *cr,
53                                 double x, double y, int width, int height,
54                                 const CairoColor *color,
55                                 gboolean disabled, gboolean radius, CairoCorners corners)
56 {
57         CairoColor fill;
58         CairoColor shade1, shade2, shade3;
59         cairo_pattern_t *pt;
60
61         ge_shade_color (color, disabled? 1.04 : SHADE_TOP, &shade1);
62         ge_shade_color (color, disabled? 1.01 : SHADE_CENTER_TOP, &shade2);
63         ge_shade_color (color, disabled? 0.99 : 1.0, &fill);
64         ge_shade_color (color, disabled? 0.96 : SHADE_BOTTOM, &shade3);
65
66         pt = cairo_pattern_create_linear (x, y, x, y+height);
67         cairo_pattern_add_color_stop_rgb (pt, 0.0, shade1.r, shade1.g, shade1.b);
68         cairo_pattern_add_color_stop_rgb (pt, 0.5, shade2.r, shade2.g, shade2.b);
69         cairo_pattern_add_color_stop_rgb (pt, 0.5, fill.r, fill.g, fill.b);
70         cairo_pattern_add_color_stop_rgb (pt, 1.0, shade3.r, shade3.g, shade3.b);
71
72         cairo_set_source (cr, pt);
73         ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, corners);
74         cairo_fill (cr);
75
76         cairo_pattern_destroy (pt);
77 }
78
79 static void
80 clearlooks_set_mixed_color (cairo_t          *cr, 
81                             const CairoColor *color1, 
82                             const CairoColor *color2, 
83                             gdouble mix_factor)
84 {
85         CairoColor composite;
86
87         ge_mix_color (color1, color2, mix_factor, &composite);
88         ge_cairo_set_color (cr, &composite);
89 }
90
91 static void
92 clearlooks_gummy_draw_highlight_and_shade (cairo_t                *cr, 
93                                            const CairoColor       *bg_color,
94                                            const ShadowParameters *params,
95                                            int width, int height, gdouble radius)
96 {
97         CairoColor shadow;
98         CairoColor highlight;
99         uint8 corners = params->corners;
100         double x = 1.0;
101         double y = 1.0;
102
103         /* not really sure of shading ratios... we will think */
104         ge_shade_color (bg_color, 0.8, &shadow);
105         ge_shade_color (bg_color, 1.2, &highlight);
106
107         cairo_save (cr);
108
109         /* Top/Left highlight */
110         if (corners & CR_CORNER_BOTTOMLEFT)
111                 cairo_move_to (cr, x, y+height-radius);
112         else
113                 cairo_move_to (cr, x, y+height);
114
115         ge_cairo_rounded_corner (cr, x, y, radius, corners & CR_CORNER_TOPLEFT);
116
117         if (corners & CR_CORNER_TOPRIGHT)
118                 cairo_line_to (cr, x+width-radius, y);
119         else
120                 cairo_line_to (cr, x+width, y);
121
122         if (params->shadow & CL_SHADOW_OUT)
123                 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
124         else
125                 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
126                 
127         cairo_stroke (cr);
128
129         /* Bottom/Right highlight -- this includes the corners */
130         cairo_move_to (cr, x+width-radius, y); /* topright and by radius to the left */
131         ge_cairo_rounded_corner (cr, x+width, y, radius, corners & CR_CORNER_TOPRIGHT);
132         ge_cairo_rounded_corner (cr, x+width, y+height, radius, corners & CR_CORNER_BOTTOMRIGHT);
133         ge_cairo_rounded_corner (cr, x, y+height, radius, corners & CR_CORNER_BOTTOMLEFT);
134
135         if (params->shadow & CL_SHADOW_OUT)
136                 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
137         else
138                 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
139
140         cairo_stroke (cr);
141
142         cairo_restore (cr);
143 }
144
145 static void
146 clearlooks_gummy_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
147                                           const WidgetParameters *params,
148                                           int width, int height, gdouble radius)
149 {
150         CairoColor hilight; 
151
152         double light_top = params->ythickness-1,
153                light_bottom = height - params->ythickness - 1,
154                light_left = params->xthickness-1,
155                light_right = width - params->xthickness - 1;
156
157         ge_shade_color (color, TOPLEFT_HIGHLIGHT_SHADE, &hilight);
158         cairo_move_to (cr, light_left, light_bottom - (int)radius/2);
159
160         ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
161
162         cairo_line_to (cr, light_right - (int)radius/2, light_top);
163         cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, TOPLEFT_HIGHLIGHT_ALPHA);
164         cairo_stroke (cr);
165 }
166
167 static void
168 clearlooks_gummy_draw_button (cairo_t                *cr,
169                               const ClearlooksColors *colors,
170                               const WidgetParameters *params,
171                               int x, int y, int width, int height)
172 {
173         double xoffset = 0, yoffset = 0;
174         CairoColor fill            = colors->bg[params->state_type];
175         CairoColor border_normal   = colors->shade[6];
176         CairoColor border_disabled = colors->shade[4];
177         double radius;
178
179         cairo_pattern_t *pattern;
180
181         cairo_save (cr);
182         cairo_translate (cr, x, y);
183         cairo_set_line_width (cr, 1.0);
184
185         /* Shadows and Glow */
186         if (params->xthickness == 3 || params->ythickness == 3)
187         {
188                 if (params->xthickness == 3)
189                         xoffset = 1;
190                 if (params->ythickness == 3)
191                         yoffset = 1;
192         }
193
194         radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0, (height - 2.0 - 2*yoffset) / 2.0));
195
196         if (params->xthickness == 3 || params->ythickness == 3)
197         {
198                 cairo_translate (cr, 0.5, 0.5);
199
200                 if (params->enable_glow && !params->active && !params->disabled && !params->is_default)
201                 {
202                         CairoColor shadow;
203
204                         radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
205
206                         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius+1, params->corners);
207                         ge_shade_color (&params->parentbg, 0.97, &shadow);
208                         ge_cairo_set_color (cr, &shadow);
209                         cairo_stroke (cr);
210
211                         ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius+1, params->corners);
212                         ge_shade_color (&params->parentbg, 0.93, &shadow);
213                         ge_cairo_set_color (cr, &shadow);
214                         cairo_stroke (cr);
215                 }
216
217                 if (params->is_default)
218                 {
219                         CairoColor shadow = colors->spot[1];
220
221                         radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
222
223                         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius+1, params->corners);
224                         clearlooks_set_mixed_color (cr, &params->parentbg, &shadow, 0.5);
225                         cairo_stroke (cr);
226                 }
227
228                 if (!(params->enable_glow && !params->active && !params->disabled))
229                         params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width-1, height-1, params->radius+1, params->corners);
230                 cairo_translate (cr, -0.5, -0.5);
231         }
232
233         clearlooks_draw_gummy_gradient (cr, xoffset+1, yoffset+1, 
234                                       width-(xoffset*2)-2, height-(yoffset*2)-2, 
235                                       &fill, params->disabled, radius, params->corners);
236
237         /* Pressed button shadow */
238         if (params->active)
239         {
240                 CairoColor shadow;
241                 ge_shade_color (&fill, 0.92, &shadow);
242
243                 cairo_save (cr);
244
245                 ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, height, radius, 
246                                             params->corners & (CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMLEFT));
247                 cairo_clip (cr);
248                 cairo_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, 3);
249
250                 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+1, yoffset+4);
251                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
252                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
253                 cairo_set_source (cr, pattern);
254                 cairo_fill (cr);
255                 cairo_pattern_destroy (pattern);
256
257                 cairo_rectangle (cr, xoffset+1, yoffset+1, 3, height-(yoffset*2)-2);
258
259                 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+4, yoffset+1);
260                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
261                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
262                 cairo_set_source (cr, pattern);
263                 cairo_fill (cr);
264                 cairo_pattern_destroy (pattern);
265
266                 cairo_restore (cr);
267         }
268
269         /* Border */
270         if (params->is_default) /* || (params->prelight && params->enable_glow)) */
271                 border_normal = colors->spot[2];
272         if (params->disabled)
273                 ge_cairo_set_color (cr, &border_disabled);
274         else
275                 clearlooks_set_mixed_color (cr, &border_normal, &fill, 0.2);
276         ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
277                                   width-(xoffset*2)-1, height-(yoffset*2)-1,
278                                   radius, params->corners);
279         cairo_stroke (cr);
280
281         if (!params->active)
282         {
283                 cairo_translate (cr, 0.5, 0.5);
284                 clearlooks_gummy_draw_top_left_highlight (cr, &fill, params, width, height, radius);
285         }
286         cairo_restore (cr);
287 }
288
289 static void
290 clearlooks_gummy_draw_entry (cairo_t                *cr,
291                              const ClearlooksColors *colors,
292                              const WidgetParameters *params,
293                              int x, int y, int width, int height)
294 {
295         const CairoColor *base = &colors->base[params->state_type];
296         CairoColor border = colors->shade[params->disabled ? 4 : 6];
297         double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
298
299         if (params->focus)
300                 border = colors->spot[2];
301
302         cairo_translate (cr, x+0.5, y+0.5);
303         cairo_set_line_width (cr, 1.0);
304
305         /* Fill the background to get the correct corners. */
306         cairo_rectangle (cr, -0.5, -0.5, width, height);
307         ge_cairo_set_color (cr, &params->parentbg);
308         cairo_fill (cr);
309
310         /* Fill with the base color, because it was just cleared above */
311         cairo_rectangle (cr, 1.5, 1.5, width-4, height-4);
312         ge_cairo_set_color (cr, base);
313         cairo_fill (cr);
314
315         params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
316
317         /* Draw the inner shadow */
318         if (params->focus)
319         {
320                 /* ge_cairo_rounded_rectangle (cr, 2, 2, width-5, height-5, RADIUS-1, params->corners); */
321                 ge_cairo_set_color (cr, &colors->spot[0]);
322                 ge_cairo_stroke_rectangle (cr, 2, 2, width-5, height-5);
323         }
324         else
325         {
326                 CairoColor shadow; 
327                 ge_shade_color (&border, 0.92, &shadow);
328
329                 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.09 : 0.18);
330                 /*
331                 cairo_move_to (cr, 2, height-3);
332                 cairo_arc (cr, params->xthickness+RADIUS-1, params->ythickness+RADIUS-1, RADIUS, G_PI, 270*(G_PI/180));
333                 cairo_line_to (cr, width-3, 2);
334                 */
335                 cairo_move_to (cr, 2, height-3);
336                 cairo_line_to (cr, 2, 2);
337                 cairo_line_to (cr, width-3, 2);
338                 cairo_stroke (cr);
339         }
340
341         ge_cairo_rounded_rectangle (cr, 1, 1, width-3, height-3, radius, params->corners);
342         ge_cairo_set_color (cr, &border);
343         cairo_stroke (cr);
344 }
345
346 static void
347 clearlooks_gummy_draw_progressbar_trough (cairo_t                *cr,
348                                           const ClearlooksColors *colors,
349                                           const WidgetParameters *params,
350                                           int x, int y, int width, int height)
351 {
352         const CairoColor *border = &colors->shade[7];
353         CairoColor        shadow;
354         cairo_pattern_t  *pattern;
355         double            radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
356
357         cairo_save (cr);
358
359         cairo_set_line_width (cr, 1.0);
360
361         /* Fill with bg color */
362         ge_cairo_set_color (cr, &colors->bg[params->state_type]);
363
364         cairo_rectangle (cr, x, y, width, height);
365         cairo_fill (cr);
366
367         /* Create trough box */
368         ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
369         ge_cairo_set_color (cr, &colors->shade[2]);
370         cairo_fill (cr);
371
372         /* Draw border */
373         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
374         clearlooks_set_mixed_color (cr, border, &colors->shade[2], 0.3);
375         cairo_stroke (cr);
376
377         /* clip the corners of the shadows */
378         ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
379         cairo_clip (cr);
380
381         ge_shade_color (border, 0.92, &shadow);
382
383         /* Top shadow */
384         cairo_rectangle (cr, x+1, y+1, width-2, 4);
385         pattern = cairo_pattern_create_linear (x, y, x, y+4);
386         cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
387         cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
388         cairo_set_source (cr, pattern);
389         cairo_fill (cr);
390         cairo_pattern_destroy (pattern);
391
392         /* Left shadow */
393         cairo_rectangle (cr, x+1, y+1, 4, height-2);
394         pattern = cairo_pattern_create_linear (x, y, x+4, y);
395         cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
396         cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
397         cairo_set_source (cr, pattern);
398         cairo_fill (cr);
399         cairo_pattern_destroy (pattern);
400
401         cairo_restore (cr);
402 }
403
404 static void
405 clearlooks_gummy_draw_progressbar_fill (cairo_t                     *cr,
406                                         const ClearlooksColors      *colors,
407                                         const WidgetParameters      *params,
408                                         const ProgressBarParameters *progressbar,
409                                         int x, int y, int width, int height, gint offset)
410 {
411         boolean      is_horizontal = progressbar->orientation < 2;
412         double       tile_pos = 0;
413         double       stroke_width;
414         double       radius;
415         int          x_step;
416
417         cairo_pattern_t *pattern;
418         CairoColor       shade1, shade2, shade3;
419         CairoColor       border;
420         CairoColor       shadow;
421
422         radius = MAX (0, params->radius - params->xthickness);
423
424         cairo_save (cr);
425
426         if (!is_horizontal)
427                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
428
429         if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
430                 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
431
432         /* Clamp the radius so that the _height_ fits ... */
433         radius = MIN (radius, height / 2.0);
434
435         stroke_width = height*2;
436         x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
437
438         cairo_translate (cr, x, y);
439
440         cairo_save (cr);
441         /* This is kind of nasty ... Clip twice from each side in case the length
442          * of the fill is smaller than twice the radius. */
443         ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
444         cairo_clip (cr);
445         ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
446         cairo_clip (cr);
447
448         /* Draw the background gradient */
449         ge_shade_color (&colors->spot[1], SHADE_TOP, &shade1);
450         ge_shade_color (&colors->spot[1], SHADE_CENTER_TOP, &shade2);
451         ge_shade_color (&colors->spot[1], SHADE_BOTTOM, &shade3);
452         pattern = cairo_pattern_create_linear (0, 0, 0, height);
453         cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
454         cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
455         cairo_pattern_add_color_stop_rgb (pattern, 0.5, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);
456         cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
457         cairo_set_source (cr, pattern);
458         cairo_paint (cr);
459         cairo_pattern_destroy (pattern);
460
461         /* Draw the Strokes */
462         while (tile_pos <= width+x_step)
463         {
464                 cairo_move_to (cr, stroke_width/2-x_step, 0);
465                 cairo_line_to (cr, stroke_width-x_step,   0);
466                 cairo_line_to (cr, stroke_width/2-x_step, height);
467                 cairo_line_to (cr, -x_step, height);
468                 
469                 cairo_translate (cr, stroke_width, 0);
470                 tile_pos += stroke_width;
471         }
472
473         cairo_set_source_rgba (cr, colors->spot[2].r,
474                                    colors->spot[2].g,
475                                    colors->spot[2].b,
476                                    0.15);
477
478         cairo_fill (cr);
479         cairo_restore (cr); /* rounded clip region */
480
481         /* inner highlight border
482          * This is again kinda ugly. Draw once from each side, clipping away the other. */
483         cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.2);
484
485         /* left side */
486         cairo_save (cr);
487         cairo_rectangle (cr, 0, 0, width / 2, height);
488         cairo_clip (cr);
489
490         if (progressbar->pulsing)
491                 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
492         else
493                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
494
495         cairo_stroke (cr);
496         cairo_restore (cr); /* clip */
497
498         /* right side */
499         cairo_save (cr);
500         cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
501         cairo_clip (cr);
502
503         if (progressbar->value < 1.0 || progressbar->pulsing)
504                 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
505         else
506                 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
507
508         cairo_stroke (cr);
509         cairo_restore (cr); /* clip */
510
511
512         /* Draw the dark lines and the shadow */
513         cairo_save (cr);
514         /* Again, this weird clip area. */
515         ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
516         cairo_clip (cr);
517         ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
518         cairo_clip (cr);
519
520         border = colors->spot[2];
521         border.a = 0.6;
522         ge_shade_color (&colors->shade[7], 0.92, &shadow);
523         shadow.a = 0.2;
524
525         if (progressbar->pulsing)
526         {
527                 /* At the beginning of the bar. */
528                 cairo_move_to (cr, 0.5 + radius, height + 0.5);
529                 ge_cairo_rounded_corner (cr, 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
530                 ge_cairo_rounded_corner (cr, 0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
531                 ge_cairo_set_color (cr, &border);
532                 cairo_stroke (cr);
533
534                 cairo_move_to (cr, -0.5 + radius, height + 0.5);
535                 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
536                 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
537                 ge_cairo_set_color (cr, &shadow);
538                 cairo_stroke (cr);
539         }
540         if (progressbar->value < 1.0 || progressbar->pulsing)
541         {
542                 /* At the end of the bar. */
543                 cairo_move_to (cr, width - 0.5 - radius, -0.5);
544                 ge_cairo_rounded_corner (cr, width - 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
545                 ge_cairo_rounded_corner (cr, width - 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
546                 ge_cairo_set_color (cr, &border);
547                 cairo_stroke (cr);
548
549                 cairo_move_to (cr, width + 0.5 - radius, -0.5);
550                 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
551                 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
552                 ge_cairo_set_color (cr, &shadow);
553                 cairo_stroke (cr);
554         }
555
556         cairo_restore (cr);
557
558         cairo_restore (cr); /* rotation, mirroring */
559 }
560
561 static void
562 clearlooks_gummy_scale_draw_gradient (cairo_t          *cr,
563                                       const CairoColor *fill,
564                                       const CairoColor *border,
565                                       int x, int y, int width, int height,
566                                       gboolean horizontal, gboolean in)
567 {
568         cairo_pattern_t *pattern;
569
570         CairoColor f1, f2;
571
572         ge_shade_color (fill, in? 0.95 : 1.1, &f1);
573         ge_shade_color (fill, in? 1.05 : 0.9, &f2);
574
575         pattern = cairo_pattern_create_linear (0, 0, horizontal ? 0 :  width, horizontal ? height : 0);
576         cairo_pattern_add_color_stop_rgba (pattern, 0.0, f1.r, f1.g, f1.b, f1.a);
577         cairo_pattern_add_color_stop_rgba (pattern, 1.0, f2.r, f2.g, f2.b, f2.a);
578
579         cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
580         cairo_set_source (cr, pattern);
581         cairo_fill (cr);
582         cairo_pattern_destroy (pattern);
583
584         clearlooks_set_mixed_color (cr, border, fill, 0.2);
585         ge_cairo_stroke_rectangle (cr, x, y, width, height);
586 }
587
588 #define TROUGH_SIZE 6
589 static void
590 clearlooks_gummy_draw_scale_trough (cairo_t                *cr,
591                                     const ClearlooksColors *colors,
592                                     const WidgetParameters *params,
593                                     const SliderParameters *slider,
594                                     int x, int y, int width, int height)
595 {
596         int     trough_width, trough_height;
597         double  translate_x, translate_y;
598
599         if (slider->horizontal)
600         {
601                 trough_width  = width-3;
602                 trough_height = TROUGH_SIZE-2;
603
604                 translate_x   = x + 0.5;
605                 translate_y   = y + 0.5 + (height/2) - (TROUGH_SIZE/2);
606         }
607         else
608         {
609                 trough_width  = TROUGH_SIZE-2;
610                 trough_height = height-3;
611
612                 translate_x   = x + 0.5 + (width/2) - (TROUGH_SIZE/2);
613                 translate_y  = y + 0.5;
614         }
615
616         cairo_set_line_width (cr, 1.0);
617         cairo_translate (cr, translate_x, translate_y);
618
619         if (!slider->fill_level)
620                 params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width+2, trough_height+2, 0, 0);
621
622         cairo_translate (cr, 1, 1);
623
624         if (!slider->lower && !slider->fill_level)
625                 clearlooks_gummy_scale_draw_gradient (cr, 
626                                                       &colors->shade[2], /* bottom */
627                                                       &colors->shade[6], /* border */
628                                                       0, 0, trough_width, trough_height,
629                                                       slider->horizontal, TRUE);
630         else if (!slider->fill_level)
631                 clearlooks_gummy_scale_draw_gradient (cr, 
632                                                       &colors->spot[1], /* bottom */
633                                                       &colors->spot[2], /* border */
634                                                       0, 0, trough_width, trough_height,
635                                                       slider->horizontal, FALSE);
636         else {
637                 CairoColor c1 = colors->spot[1];
638                 CairoColor c2 = colors->spot[2];
639
640                 c1.a = 0.25;
641                 c2.a = 0.25;
642
643                 clearlooks_gummy_scale_draw_gradient (cr, 
644                                                       &c1, /* bottom */
645                                                       &c2, /* border */
646                                                       0, 0, trough_width, trough_height,
647                                                       slider->horizontal, FALSE);
648         }
649
650 }
651
652 static void
653 clearlooks_gummy_draw_tab (cairo_t                *cr,
654                            const ClearlooksColors *colors,
655                            const WidgetParameters *params,
656                            const TabParameters    *tab,
657                            int x, int y, int width, int height)
658 {
659
660         const CairoColor    *border        = &colors->shade[5];
661         const CairoColor    *stripe_fill   = &colors->spot[1];
662         const CairoColor    *stripe_border = &colors->spot[2];
663         const CairoColor    *fill;
664
665         cairo_pattern_t     *pattern;
666
667         double               radius;
668         double               strip_size;
669
670         radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
671
672         /* Set clip */
673         cairo_rectangle      (cr, x, y, width, height);
674         cairo_clip           (cr);
675         cairo_new_path       (cr);
676
677         /* Translate and set line width */
678         cairo_set_line_width (cr, 1.0);
679         cairo_translate      (cr, x+0.5, y+0.5);
680
681         /* Make the tabs slightly bigger than they should be, to create a gap */
682         /* And calculate the strip size too, while you're at it */
683         if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
684         {
685                 height += 3.0;
686                 strip_size = 2.0/height; /* 2 pixel high strip */
687
688                 if (tab->gap_side == CL_GAP_TOP)
689                         cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
690         }
691         else
692         {
693                 width += 3.0;
694                 strip_size = 2.0/width;
695
696                 if (tab->gap_side == CL_GAP_LEFT) 
697                         cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
698         }
699
700         /* Set the fill color */
701         fill = &colors->bg[params->state_type];
702
703         /* Set tab shape */
704         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
705                                     radius, params->corners);
706
707         /* Draw fill */
708         ge_cairo_set_color (cr, fill);
709         cairo_fill  (cr);
710
711         /* Draw highlight */
712         if (!params->active)
713         {
714                 ShadowParameters shadow;
715
716                 shadow.shadow  = CL_SHADOW_OUT;
717                 shadow.corners = params->corners;
718
719                 clearlooks_gummy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow,
720                                                      width, height, radius);
721         }
722
723         if (params->active)
724         {
725                 CairoColor hilight;
726                 CairoColor shade1, shade2, shade3;
727
728                 pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT   ? width-1  : 0,
729                                                        tab->gap_side == CL_GAP_TOP    ? height-2 : 1,
730                                                        tab->gap_side == CL_GAP_RIGHT  ? width    : 0,
731                                                        tab->gap_side == CL_GAP_BOTTOM ? height   : 0);
732
733                 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
734
735                 ge_shade_color (fill, 1.14, &hilight);
736                 ge_shade_color (fill, SHADE_TOP, &shade1);
737                 ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
738                 ge_shade_color (fill, SHADE_BOTTOM, &shade3);
739
740                 cairo_pattern_add_color_stop_rgb (pattern, 0.0,        hilight.r, hilight.g, hilight.b);
741                 cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, hilight.r, hilight.g, hilight.b);
742                 cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, shade1.r, shade1.g, shade1.b);
743                 cairo_pattern_add_color_stop_rgb (pattern, 0.45,       shade2.r, shade2.g, shade2.b);
744                 cairo_pattern_add_color_stop_rgb (pattern, 0.45,       fill->r, fill->g, fill->b);
745                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,        shade3.r, shade3.g, shade3.b);
746                 cairo_set_source (cr, pattern);
747                 cairo_fill (cr);
748                 cairo_pattern_destroy (pattern);
749         }
750         else
751         {
752                 /* Draw shade */
753                 pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT   ? width-2  : 0,
754                                                        tab->gap_side == CL_GAP_TOP    ? height-2 : 0,
755                                                        tab->gap_side == CL_GAP_RIGHT  ? width    : 0,
756                                                        tab->gap_side == CL_GAP_BOTTOM ? height   : 0);
757
758                 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
759
760                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.5);
761                 cairo_pattern_add_color_stop_rgba (pattern, 0.8, fill->r, fill->g, fill->b, 0.0);
762                 cairo_set_source (cr, pattern);
763                 cairo_fill (cr);
764                 cairo_pattern_destroy (pattern);
765         }
766
767         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
768
769         if (params->active)
770         {
771                 ge_cairo_set_color (cr, border);
772                 cairo_stroke (cr);
773         }
774         else
775         {
776                 pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT   ? width-2  : 2,
777                                                        tab->gap_side == CL_GAP_TOP    ? height-2 : 2,
778                                                        tab->gap_side == CL_GAP_RIGHT  ? width    : 2,
779                                                        tab->gap_side == CL_GAP_BOTTOM ? height   : 2);
780
781                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
782                 cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r,        border->g,        border->b);
783                 cairo_set_source (cr, pattern);
784                 cairo_stroke (cr);
785                 cairo_pattern_destroy (pattern);
786         }
787 }
788
789 static void
790 clearlooks_gummy_draw_separator (cairo_t                   *cr,
791                                  const ClearlooksColors    *colors,
792                                  const WidgetParameters    *widget,
793                                  const SeparatorParameters *separator,
794                                  int x, int y, int width, int height)
795 {
796         CairoColor color = colors->shade[3];
797         CairoColor hilight;
798         ge_shade_color (&color, 1.3, &hilight);
799
800         cairo_save (cr);
801         cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
802
803         if (separator->horizontal)
804         {
805                 cairo_set_line_width  (cr, 1.0);
806                 cairo_translate       (cr, x, y+0.5);
807
808                 cairo_move_to         (cr, 0.0,   0.0);
809                 cairo_line_to         (cr, width, 0.0);
810                 ge_cairo_set_color    (cr, &color);
811                 cairo_stroke          (cr);
812
813                 cairo_move_to         (cr, 0.0,   1.0);
814                 cairo_line_to         (cr, width, 1.0);
815                 ge_cairo_set_color    (cr, &hilight);
816                 cairo_stroke          (cr);
817         }
818         else
819         {
820                 cairo_set_line_width  (cr, 1.0);
821                 cairo_translate       (cr, x+0.5, y);
822
823                 cairo_move_to         (cr, 0.0, 0.0);
824                 cairo_line_to         (cr, 0.0, height);
825                 ge_cairo_set_color    (cr, &color);
826                 cairo_stroke          (cr);
827
828                 cairo_move_to         (cr, 1.0, 0.0);
829                 cairo_line_to         (cr, 1.0, height);
830                 ge_cairo_set_color    (cr, &hilight);
831                 cairo_stroke          (cr);
832         }
833
834         cairo_restore (cr);
835 }
836
837 static void
838 clearlooks_gummy_draw_slider (cairo_t                *cr,
839                               const ClearlooksColors *colors,
840                               const WidgetParameters *params,
841                               int x, int y, int width, int height)
842 {
843         const CairoColor *border = &colors->shade[7];
844         CairoColor  fill;
845         CairoColor  shade1, shade2, shade3;
846         cairo_pattern_t *pattern;
847         int bar_x, i;
848         int shift_x;
849
850         cairo_set_line_width (cr, 1.0); 
851         cairo_translate      (cr, x, y);
852
853         cairo_translate (cr, -0.5, -0.5);
854
855         ge_shade_color (&colors->bg[params->state_type], 1.0, &fill);
856         if (params->prelight)
857                 ge_shade_color (&fill, 1.04, &fill);
858
859         ge_shade_color (&fill, SHADE_TOP, &shade1);
860         ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
861         ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
862
863         pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
864         cairo_pattern_add_color_stop_rgb(pattern, 0,   shade1.r, shade1.g, shade1.b);
865         cairo_pattern_add_color_stop_rgb(pattern, 0.5, shade2.r, shade2.g, shade2.b);
866         cairo_pattern_add_color_stop_rgb(pattern, 0.5, fill.r, fill.g, fill.b);
867         cairo_pattern_add_color_stop_rgb(pattern, 1.0, shade3.r, shade3.g, shade3.b);
868         cairo_rectangle (cr, 1, 1, width-2, height-2);
869         cairo_set_source (cr, pattern);
870         cairo_fill (cr);
871         cairo_pattern_destroy (pattern);
872
873         clearlooks_set_mixed_color (cr, border, &fill, 0.2);
874         if (params->prelight)
875                 ge_cairo_set_color (cr, &colors->spot[2]);
876         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, 2.5, params->corners);
877         cairo_stroke (cr);
878
879         /* Handle */
880         shift_x = (width%2 == 0 ? 1 : 0);
881         bar_x = width/2-3+shift_x;
882         cairo_translate (cr, 0.5, 0.5);
883         ge_cairo_set_color (cr, border);
884         for (i=0; i<3-shift_x; i++)
885         {
886                 cairo_move_to (cr, bar_x, 4);
887                 cairo_line_to (cr, bar_x, height-5);
888                 bar_x += 3;
889         }
890         cairo_stroke (cr);
891
892         clearlooks_gummy_draw_top_left_highlight (cr, &fill, params, width, height, 2.0);
893 }
894
895 static void
896 clearlooks_gummy_draw_slider_button (cairo_t                *cr,
897                                      const ClearlooksColors *colors,
898                                      const WidgetParameters *params,
899                                      const SliderParameters *slider,
900                                      int x, int y, int width, int height)
901 {
902         double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
903
904         cairo_set_line_width (cr, 1.0);
905
906         if (!slider->horizontal)
907                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
908
909         cairo_translate (cr, x+0.5, y+0.5);
910
911         params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
912         params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
913 }
914
915 static void
916 clearlooks_gummy_draw_scrollbar_stepper (cairo_t                          *cr,
917                                          const ClearlooksColors           *colors,
918                                          const WidgetParameters           *widget,
919                                          const ScrollBarParameters        *scrollbar,
920                                          const ScrollBarStepperParameters *stepper,
921                                          int x, int y, int width, int height)
922 {
923         CairoCorners corners = CR_CORNER_NONE;
924         const CairoColor *border = &colors->shade[scrollbar->has_color ? 7 : 6];
925         CairoColor fill;
926         CairoColor shade1, shade2, shade3;
927         cairo_pattern_t *pattern;
928         ShadowParameters shadow;
929         double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
930
931         if (scrollbar->horizontal)
932         {
933                 if (stepper->stepper == CL_STEPPER_A)
934                         corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
935                 else if (stepper->stepper == CL_STEPPER_D)
936                         corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
937         }
938         else
939         {
940                 if (stepper->stepper == CL_STEPPER_A)
941                         corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
942                 else if (stepper->stepper == CL_STEPPER_D)
943                         corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
944         }
945
946         cairo_translate (cr, x, y);
947         cairo_set_line_width (cr, 1);
948
949         ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
950
951         if (scrollbar->horizontal)
952                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
953         else
954                 pattern = cairo_pattern_create_linear (0, 0, width, 0);
955
956         fill = colors->bg[widget->state_type];
957         ge_shade_color(&fill, SHADE_TOP, &shade1);
958         ge_shade_color(&fill, SHADE_CENTER_TOP, &shade2); 
959         ge_shade_color(&fill, SHADE_BOTTOM, &shade3); 
960
961         cairo_pattern_add_color_stop_rgb(pattern, 0,   shade1.r, shade1.g, shade1.b);
962         cairo_pattern_add_color_stop_rgb(pattern, 0.5, shade2.r, shade2.g, shade2.b);
963         cairo_pattern_add_color_stop_rgb(pattern, 0.5, fill.r, fill.g, fill.b);
964         cairo_pattern_add_color_stop_rgb(pattern, 1.0, shade3.r, shade3.g, shade3.b);
965         cairo_set_source (cr, pattern);
966         cairo_fill (cr);
967         cairo_pattern_destroy (pattern);
968
969         cairo_translate (cr, 0.5, 0.5);
970         clearlooks_gummy_draw_top_left_highlight (cr, &fill, widget, width, height, (stepper->stepper == CL_STEPPER_A) ? radius : 0);
971         cairo_translate (cr, -0.5, -0.5);
972
973         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
974         clearlooks_set_mixed_color (cr, border, &fill, 0.2);
975         cairo_stroke (cr);
976
977         cairo_translate (cr, 0.5, 0.5);
978         shadow.shadow  = CL_SHADOW_OUT;
979         shadow.corners = corners;
980 }
981
982 static void
983 clearlooks_gummy_draw_scrollbar_slider (cairo_t                   *cr,
984                                         const ClearlooksColors    *colors,
985                                         const WidgetParameters    *widget,
986                                         const ScrollBarParameters *scrollbar,
987                                         int x, int y, int width, int height)
988 {
989         CairoColor fill = scrollbar->color;
990         CairoColor border, handles;
991         CairoColor hilight;
992         CairoColor shade1, shade2, shade3;
993         cairo_pattern_t *pattern;
994         int bar_x, i;
995
996         gdouble hue_scroll, brightness_scroll, saturation_scroll;
997         gdouble hue_bg, brightness_bg, saturation_bg;
998
999         ge_hsb_from_color (&fill, &hue_scroll, &saturation_scroll, &brightness_scroll);
1000         ge_hsb_from_color (&colors->bg[0], &hue_bg, &saturation_bg, &brightness_bg);
1001
1002         /* Set the right color for border and handles */
1003         if ((fabs(saturation_scroll - saturation_bg) < 0.30) &&
1004             (fabs(brightness_scroll - brightness_bg) < 0.20))
1005                 ge_shade_color (&fill, 0.475, &border);
1006         else
1007                 ge_shade_color (&fill, 0.575, &border);
1008         /* The following lines increase contrast when the HUE is between 25 and 195, */
1009         /* fixing a LOT of colorschemes! */
1010         if (scrollbar->has_color && (hue_scroll < 195) && (hue_scroll > 25))
1011                 ge_shade_color (&border, 0.85, &border);
1012
1013         handles = border;
1014         ge_mix_color (&border, &fill, scrollbar->has_color? 0.3 : 0.2, &border);
1015
1016         if (scrollbar->junction & CL_JUNCTION_BEGIN)
1017         {
1018                 if (scrollbar->horizontal)
1019                 {
1020                         x -= 1;
1021                         width += 1;
1022                 }
1023                 else
1024                 {
1025                         y -= 1;
1026                         height += 1;
1027                 }
1028         }
1029         if (scrollbar->junction & CL_JUNCTION_END)
1030         {
1031                 if (scrollbar->horizontal)
1032                         width += 1;
1033                 else
1034                         height += 1;
1035         }
1036
1037         if (!scrollbar->horizontal)
1038                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1039
1040         cairo_translate (cr, x, y);
1041
1042         if (widget->prelight)
1043                 ge_shade_color (&fill, 1.04, &fill);
1044
1045         cairo_set_line_width (cr, 1);
1046
1047         ge_shade_color (&fill, TOPLEFT_HIGHLIGHT_SHADE, &hilight);
1048         ge_shade_color (&fill, SHADE_TOP, &shade1);
1049         ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
1050         ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
1051
1052         pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1053         cairo_pattern_add_color_stop_rgb (pattern, 0,   shade1.r, shade1.g, shade1.b);
1054         cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1055         cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r,  fill.g,  fill.b);
1056         cairo_pattern_add_color_stop_rgb (pattern, 1,   shade3.r, shade3.g, shade3.b);
1057         cairo_rectangle (cr, 1, 1, width-2, height-2);
1058         cairo_set_source (cr, pattern);
1059         cairo_fill (cr);
1060         cairo_pattern_destroy (pattern);
1061
1062         if (scrollbar->has_color) 
1063         {
1064                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.2);
1065                 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1066         }
1067         else
1068         {
1069                 cairo_move_to (cr, 1.5, height-1.5);
1070                 cairo_line_to (cr, 1.5, 1.5);
1071                 cairo_line_to (cr, width-1.5, 1.5);
1072                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, TOPLEFT_HIGHLIGHT_ALPHA);
1073                 cairo_stroke(cr);
1074         }
1075
1076         ge_cairo_set_color (cr, &border);
1077         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1078
1079         /* Handle */
1080         bar_x = width/2 - 4;
1081         cairo_translate(cr, 0.5, 0.5);
1082         ge_cairo_set_color (cr, &handles);
1083         for (i=0; i<3; i++)
1084         {
1085                 cairo_move_to (cr, bar_x, 5);
1086                 cairo_line_to (cr, bar_x, height-6);
1087                 bar_x += 3;
1088         }
1089         cairo_stroke (cr);
1090 }
1091
1092 static void
1093 clearlooks_gummy_draw_list_view_header (cairo_t                        *cr,
1094                                         const ClearlooksColors         *colors,
1095                                         const WidgetParameters         *params,
1096                                         const ListViewHeaderParameters *header,
1097                                         int x, int y, int width, int height)
1098 {
1099 /*
1100         CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
1101 */
1102         const CairoColor *border = &colors->shade[4];
1103         const CairoColor *fill   = &colors->bg[params->state_type];
1104         CairoColor hilight;
1105         CairoColor shade1, shade2, shade3;
1106
1107         cairo_pattern_t *pattern;
1108
1109         ge_shade_color (fill, 1.11, &hilight);
1110         ge_shade_color (fill, LISTVIEW_SHADE_TOP, &shade1);
1111         ge_shade_color (fill, LISTVIEW_SHADE_CENTER_TOP, &shade2);
1112         ge_shade_color (fill, LISTVIEW_SHADE_BOTTOM, &shade3);
1113
1114         cairo_translate (cr, x, y);
1115         cairo_set_line_width (cr, 1.0);
1116
1117         /* Draw the fill */
1118         pattern = cairo_pattern_create_linear (0, 0, 0, height);
1119         cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1120         cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1121         cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1122         cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, shade3.r, shade3.g, shade3.b);
1123         cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, border->r, border->g, border->b);
1124         cairo_pattern_add_color_stop_rgb (pattern, 1.0, border->r, border->g, border->b);
1125
1126         cairo_set_source (cr, pattern);
1127         cairo_rectangle (cr, 0, 0, width, height);
1128         cairo_fill (cr);
1129
1130         cairo_pattern_destroy (pattern);
1131
1132         /* Draw highlight */
1133         if (header->order == CL_ORDER_FIRST)
1134         {
1135                 cairo_move_to (cr, 0.5, height-1.5);
1136                 cairo_line_to (cr, 0.5, 0.5);
1137         }
1138         else
1139                 cairo_move_to (cr, 0.0, 0.5);
1140
1141         cairo_line_to (cr, width, 0.5);
1142
1143         ge_cairo_set_color (cr, &hilight);
1144         cairo_stroke (cr);
1145
1146         /* Draw resize grip */
1147         if ((params->ltr && header->order != CL_ORDER_LAST) ||
1148             (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
1149         {
1150                 SeparatorParameters separator;
1151                 separator.horizontal = FALSE;
1152
1153                 if (params->ltr)
1154                         params->style_functions->draw_separator (cr, colors, params, &separator,
1155                                                                  width-1.5, 4.0, 2, height-8.0);
1156                 else
1157                         params->style_functions->draw_separator (cr, colors, params, &separator,
1158                                                                  1.5, 4.0, 2, height-8.0);
1159         }
1160 }
1161
1162 static void
1163 clearlooks_gummy_draw_toolbar (cairo_t                 *cr,
1164                                const ClearlooksColors  *colors,
1165                                const WidgetParameters  *widget,
1166                                const ToolbarParameters *toolbar,
1167                                int x, int y, int width, int height)
1168 {
1169         const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL];
1170         const CairoColor *dark = &colors->shade[3];
1171         CairoColor light;
1172         ge_shade_color (fill, toolbar->style == 1 ? 1.1 : 1.05, &light);
1173
1174         cairo_set_line_width (cr, 1.0);
1175         cairo_translate (cr, x, y);
1176
1177         if (toolbar->style == 1) /* Enable Extra features */
1178         {
1179                 cairo_pattern_t *pattern;
1180                 CairoColor shade1, shade2, shade3;
1181
1182                 ge_shade_color (fill, TOOLBAR_SHADE_TOP, &shade1);
1183                 ge_shade_color (fill, TOOLBAR_SHADE_CENTER_TOP, &shade2);
1184                 ge_shade_color (fill, TOOLBAR_SHADE_BOTTOM, &shade3);
1185
1186                 /* Draw the fill */
1187                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1188                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1189                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1190                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1191                 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
1192
1193                 cairo_set_source (cr, pattern);
1194                 cairo_rectangle (cr, 0, 0, width, height);
1195                 cairo_fill (cr);
1196
1197                 cairo_pattern_destroy (pattern);
1198         }
1199         else /* Flat */
1200         {
1201                 ge_cairo_set_color (cr, fill);
1202                 cairo_paint (cr);
1203         }
1204
1205         if (!toolbar->topmost)
1206         {
1207                 /* Draw highlight */
1208                 cairo_move_to       (cr, 0, 0.5);
1209                 cairo_line_to       (cr, width-1, 0.5);
1210                 ge_cairo_set_color  (cr, &light);
1211                 cairo_stroke        (cr);
1212         }
1213
1214         /* Draw shadow */
1215         cairo_move_to       (cr, 0, height-0.5);
1216         cairo_line_to       (cr, width-1, height-0.5);
1217         ge_cairo_set_color  (cr, dark);
1218         cairo_stroke        (cr);
1219 }
1220
1221 static void
1222 clearlooks_gummy_draw_menuitem (cairo_t                *cr,
1223                                 const ClearlooksColors *colors,
1224                                 const WidgetParameters *params,
1225                                 int x, int y, int width, int height)
1226 {
1227         const CairoColor *fill = &colors->spot[1];
1228         const CairoColor *border = &colors->spot[2];
1229         CairoColor shade1, shade2, shade3;
1230         cairo_pattern_t *pattern;
1231
1232         ge_shade_color (fill, SHADE_TOP, &shade1);
1233         ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
1234         ge_shade_color (fill, SHADE_BOTTOM, &shade3);
1235         cairo_set_line_width (cr, 1.0);
1236
1237         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1238
1239         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1240         cairo_pattern_add_color_stop_rgb (pattern, 0,   shade1.r, shade1.g, shade1.b);
1241         cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1242         cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r,  fill->g,  fill->b);
1243         cairo_pattern_add_color_stop_rgb (pattern, 1,   shade3.r, shade3.g, shade3.b);
1244
1245         cairo_set_source (cr, pattern);
1246         cairo_fill_preserve  (cr);
1247         cairo_pattern_destroy (pattern);
1248
1249         ge_cairo_set_color (cr, border);
1250         cairo_stroke (cr);
1251 }
1252
1253 static void
1254 clearlooks_gummy_draw_menubaritem (cairo_t                *cr,
1255                                    const ClearlooksColors *colors,
1256                                    const WidgetParameters *params,
1257                                    int x, int y, int width, int height)
1258 {
1259         const CairoColor *fill = &colors->spot[1];
1260         const CairoColor *border = &colors->spot[2];
1261         CairoColor shade1, shade2, shade3;
1262         cairo_pattern_t *pattern;
1263
1264         ge_shade_color (fill, SHADE_TOP, &shade1);
1265         ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
1266         ge_shade_color (fill, SHADE_BOTTOM, &shade3);
1267         cairo_set_line_width (cr, 1.0);
1268
1269         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1270
1271         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1272         cairo_pattern_add_color_stop_rgb (pattern, 0,   shade1.r, shade1.g, shade1.b);
1273         cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1274         cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r,  fill->g,  fill->b);
1275         cairo_pattern_add_color_stop_rgb (pattern, 1,   shade3.r, shade3.g, shade3.b);
1276
1277         cairo_set_source (cr, pattern);
1278         cairo_fill_preserve  (cr);
1279         cairo_pattern_destroy (pattern);
1280
1281         ge_cairo_set_color (cr, border);
1282         cairo_stroke (cr);
1283 }
1284
1285 static void
1286 clearlooks_gummy_draw_selected_cell (cairo_t                *cr,
1287                                      const ClearlooksColors *colors,
1288                                      const WidgetParameters *params,
1289                                      int x, int y, int width, int height)
1290 {
1291         CairoColor color;
1292
1293         if (params->focus)
1294                 color = colors->base[params->state_type];
1295         else
1296                 color = colors->base[GTK_STATE_ACTIVE];
1297
1298         clearlooks_draw_gummy_gradient (cr, x, y, width, height, &color, params->disabled, 0.0, CR_CORNER_NONE);
1299 }
1300
1301 static void
1302 clearlooks_gummy_draw_statusbar (cairo_t                *cr,
1303                                  const ClearlooksColors *colors,
1304                                  const WidgetParameters *widget,
1305                                  int x, int y, int width, int height)
1306 {
1307         const CairoColor *dark = &colors->shade[3];
1308         CairoColor hilight;
1309
1310         ge_shade_color (dark, 1.3, &hilight);
1311
1312         cairo_set_line_width  (cr, 1);
1313         cairo_translate       (cr, x, y+0.5);
1314         cairo_move_to         (cr, 0, 0);
1315         cairo_line_to         (cr, width, 0);
1316         ge_cairo_set_color    (cr, dark);
1317         cairo_stroke          (cr);
1318
1319         cairo_translate       (cr, 0, 1);
1320         cairo_move_to         (cr, 0, 0);
1321         cairo_line_to         (cr, width, 0);
1322         ge_cairo_set_color    (cr, &hilight);
1323         cairo_stroke          (cr);
1324 }
1325
1326 static void
1327 clearlooks_gummy_draw_radiobutton (cairo_t                  *cr,
1328                                    const ClearlooksColors   *colors,
1329                                    const WidgetParameters   *widget,
1330                                    const CheckboxParameters *checkbox,
1331                                    int x, int y, int width, int height)
1332 {
1333         const CairoColor *border;
1334         const CairoColor *dot;
1335         CairoColor shadow;
1336         CairoColor highlight;
1337         cairo_pattern_t *pt;
1338         gboolean inconsistent;
1339         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1340
1341         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1342         draw_bullet |= inconsistent;
1343
1344         if (widget->disabled)
1345         {
1346                 border = &colors->shade[5];
1347                 dot    = &colors->shade[6];
1348         }
1349         else
1350         {
1351                 if (widget->prelight)
1352                         border = &colors->spot[2];
1353                 else
1354                         border = &colors->shade[6];
1355                 dot    = &colors->text[0];
1356         }
1357
1358         ge_shade_color (&widget->parentbg, 0.9, &shadow);
1359         ge_shade_color (&widget->parentbg, 1.1, &highlight);
1360
1361         pt = cairo_pattern_create_linear (0, 0, 13, 13);
1362         cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
1363         cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
1364         cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
1365         cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
1366
1367         cairo_translate (cr, x, y);
1368
1369         cairo_set_line_width (cr, 2);
1370         cairo_arc (cr, 7, 7, 6, 0, G_PI*2);
1371         cairo_set_source (cr, pt);
1372         cairo_stroke (cr);
1373         cairo_pattern_destroy (pt);
1374
1375         cairo_set_line_width (cr, 1);
1376
1377         cairo_arc (cr, 7, 7, 5.5, 0, G_PI*2);
1378
1379         if (!widget->disabled)
1380         {
1381                 if (widget->prelight)
1382                         clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1383                 else
1384                         ge_cairo_set_color (cr, &colors->base[0]);
1385                 cairo_fill_preserve (cr);
1386         }
1387
1388         ge_cairo_set_color (cr, border);
1389         cairo_stroke (cr);
1390
1391         if (draw_bullet)
1392         {
1393                 if (inconsistent)
1394                 {
1395                         cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1396                         cairo_set_line_width (cr, 4);
1397
1398                         cairo_move_to(cr, 5, 7);
1399                         cairo_line_to(cr, 9, 7);
1400
1401                         ge_cairo_set_color (cr, dot);
1402                         cairo_stroke (cr);
1403                 }
1404                 else
1405                 {
1406                         cairo_arc (cr, 7, 7, 3, 0, G_PI*2);
1407                         ge_cairo_set_color (cr, dot);
1408                         cairo_fill (cr);
1409
1410                         cairo_arc (cr, 6, 6, 1, 0, G_PI*2);
1411                         cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
1412                         cairo_fill (cr);
1413                 }
1414         }
1415 }
1416
1417 static void
1418 clearlooks_gummy_draw_checkbox (cairo_t                  *cr,
1419                                 const ClearlooksColors   *colors,
1420                                 const WidgetParameters   *widget,
1421                                 const CheckboxParameters *checkbox,
1422                                 int x, int y, int width, int height)
1423 {
1424         const CairoColor *border;
1425         const CairoColor *dot; 
1426         gboolean inconsistent = FALSE;
1427         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1428
1429         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1430         draw_bullet |= inconsistent;
1431
1432         if (widget->disabled)
1433         {
1434                 border = &colors->shade[5];
1435                 dot    = &colors->shade[6];
1436         }
1437         else
1438         {
1439                 if (widget->prelight)
1440                         border = &colors->spot[2];
1441                 else            
1442                         border = &colors->shade[6];
1443                 dot    = &colors->text[GTK_STATE_NORMAL];
1444         }
1445
1446         cairo_translate (cr, x, y);
1447         cairo_set_line_width (cr, 1);
1448
1449         if (widget->xthickness > 2 && widget->ythickness > 2)
1450         {
1451                 widget->style_functions->draw_inset (cr, &widget->parentbg, 0.5, 0.5, 
1452                                   width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1453                 
1454                 /* Draw the rectangle for the checkbox itself */
1455                 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, 
1456                                   width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1457         }
1458         else
1459         {
1460                 /* Draw the rectangle for the checkbox itself */
1461                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, 
1462                                   width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1463         }
1464         
1465         if (!widget->disabled)
1466         {               
1467                 if (widget->prelight)
1468                         clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1469                 else            
1470                         ge_cairo_set_color (cr, &colors->base[0]);
1471                 cairo_fill_preserve (cr);
1472         }
1473
1474         ge_cairo_set_color (cr, border);
1475         cairo_stroke (cr);
1476
1477         if (draw_bullet)
1478         {
1479                 if (inconsistent) /* Inconsistent */
1480                 {
1481                         cairo_set_line_width (cr, 2.0);
1482                         cairo_move_to (cr, 3, height*0.5);
1483                         cairo_line_to (cr, width-3, height*0.5);
1484                 }
1485                 else
1486                 {
1487                         cairo_set_line_width (cr, 1.7);
1488                         cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
1489                         cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
1490
1491                         cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
1492                                             0.5 + (width*0.5), (height*0.4),
1493                                             0.5 + (width*0.70), (height*0.25));
1494
1495                 }
1496
1497                 ge_cairo_set_color (cr, dot);
1498                 cairo_stroke (cr);
1499         }
1500 }
1501
1502 void
1503 clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions)
1504 {
1505         functions->draw_button              = clearlooks_gummy_draw_button;
1506         functions->draw_entry               = clearlooks_gummy_draw_entry;
1507         functions->draw_progressbar_trough  = clearlooks_gummy_draw_progressbar_trough;
1508         functions->draw_progressbar_fill    = clearlooks_gummy_draw_progressbar_fill;
1509         functions->draw_scale_trough        = clearlooks_gummy_draw_scale_trough;
1510         functions->draw_tab                 = clearlooks_gummy_draw_tab;
1511         functions->draw_separator           = clearlooks_gummy_draw_separator;
1512         functions->draw_slider              = clearlooks_gummy_draw_slider;
1513         functions->draw_slider_button       = clearlooks_gummy_draw_slider_button;
1514         functions->draw_scrollbar_stepper   = clearlooks_gummy_draw_scrollbar_stepper;
1515         functions->draw_scrollbar_slider    = clearlooks_gummy_draw_scrollbar_slider;
1516         functions->draw_list_view_header    = clearlooks_gummy_draw_list_view_header;
1517         functions->draw_toolbar             = clearlooks_gummy_draw_toolbar;
1518         functions->draw_menuitem            = clearlooks_gummy_draw_menuitem;
1519         functions->draw_menubaritem         = clearlooks_gummy_draw_menubaritem;
1520         functions->draw_selected_cell       = clearlooks_gummy_draw_selected_cell;
1521         functions->draw_statusbar           = clearlooks_gummy_draw_statusbar;
1522         functions->draw_checkbox            = clearlooks_gummy_draw_checkbox;
1523         functions->draw_radiobutton         = clearlooks_gummy_draw_radiobutton;
1524 }