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