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