6b8939ce513f296096cf12190b75c6fa1ea2acff
[ardour.git] / libs / clearlooks-newer / clearlooks_draw_inverted.c
1 /* Clearlooks Inverted 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
32 static void
33 clearlooks_draw_top_left_highlight (cairo_t *cr,
34                                                                         const CairoColor *color,
35                                     const WidgetParameters *params,
36                                     int width, int height, gdouble radius)
37 {
38         CairoColor hilight;
39
40         double light_top = params->ythickness-1,
41                light_bottom = height - params->ythickness - 1,
42                light_left = params->xthickness-1,
43                light_right = width - params->xthickness - 1;
44
45         ge_shade_color (color, 1.3, &hilight);
46         cairo_move_to         (cr, light_left, light_bottom - (int)radius/2);
47
48         ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
49
50         cairo_line_to         (cr, light_right - (int)radius/2, light_top);
51         cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.7);
52         cairo_stroke          (cr);
53 }
54
55 static void
56 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
57 {
58         cairo_pattern_t *pattern;
59
60         CairoColor bottom_shade;
61         ge_shade_color (color, hilight, &bottom_shade);
62
63         pattern = cairo_pattern_create_linear (0, 0, width, height);
64         cairo_pattern_add_color_stop_rgb (pattern, 0, color->r, color->g, color->b);
65         cairo_pattern_add_color_stop_rgb (pattern, 1, bottom_shade.r, bottom_shade.g, bottom_shade.b);
66         
67         cairo_set_source (cr, pattern);
68         cairo_pattern_destroy (pattern);
69 }
70
71 static void
72 clearlooks_inverted_draw_button (cairo_t *cr,
73                         const ClearlooksColors *colors,
74                         const WidgetParameters *params,
75                         int x, int y, int width, int height)
76 {
77         double xoffset = 0, yoffset = 0;
78         double radius = params->radius;
79         const CairoColor *fill = &colors->bg[params->state_type];       
80         const CairoColor *border_disabled = &colors->shade[4];
81         CairoColor border_normal;
82         CairoColor shadow;
83
84         ge_shade_color(&colors->shade[6], 1.05, &border_normal);
85         ge_shade_color (&border_normal, 0.925, &shadow);
86         
87         cairo_save (cr);
88         
89         cairo_translate (cr, x, y);
90         cairo_set_line_width (cr, 1.0);
91
92         if (params->xthickness == 3 || params->ythickness == 3)
93         {
94                 if (params->xthickness == 3)
95                         xoffset = 1;
96                 if (params->ythickness == 3)
97                         yoffset = 1;
98         }
99
100         radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
101
102         if (params->xthickness == 3 || params->ythickness == 3)
103         {
104                 cairo_translate (cr, 0.5, 0.5);
105                 params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
106                 cairo_translate (cr, -0.5, -0.5);
107         }               
108         
109         ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
110                                              width-(xoffset*2)-2,
111                                              height-(yoffset*2)-2,
112                                              radius, params->corners);
113         
114         if (!params->active)
115         {
116                 cairo_pattern_t *pattern;
117
118                 CairoColor top_shade, bottom_shade;
119                 ge_shade_color (fill, 0.95, &top_shade);                
120                 ge_shade_color (fill, 1.05, &bottom_shade);
121                 
122                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
123                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top_shade.r, top_shade.g, top_shade.b);
124                 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bottom_shade.r, bottom_shade.g, bottom_shade.b);
125                 cairo_set_source (cr, pattern);
126                 cairo_fill (cr);
127                 cairo_pattern_destroy (pattern);
128         }
129         else
130         {
131                 cairo_pattern_t *pattern;
132                 
133                 ge_cairo_set_color (cr, fill);
134                 cairo_fill_preserve (cr);
135
136                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
137                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.0);
138                 cairo_pattern_add_color_stop_rgba (pattern, 0.4, shadow.r, shadow.g, shadow.b, 0.0);
139                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.2);
140                 cairo_set_source (cr, pattern);
141                 cairo_fill_preserve (cr);
142                 cairo_pattern_destroy (pattern);
143
144                 pattern = cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
145                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
146                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
147                 cairo_set_source (cr, pattern);
148                 cairo_fill_preserve (cr);
149                 cairo_pattern_destroy (pattern);
150
151                 pattern = cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
152                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
153                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
154                 cairo_set_source (cr, pattern);
155                 cairo_fill (cr);
156                 cairo_pattern_destroy (pattern);
157         }
158
159         /* Drawing the border */
160
161         if (!params->active && params->is_default)
162         {
163                 const CairoColor *l = &colors->shade[4];
164                 const CairoColor *d = &colors->shade[4];
165                 ge_cairo_set_color (cr, l);
166                 ge_cairo_stroke_rectangle (cr, 2.5, 2.5, width-5, height-5);
167
168                 ge_cairo_set_color (cr, d);
169                 ge_cairo_stroke_rectangle (cr, 3.5, 3.5, width-7, height-7);
170         }
171         
172         if (params->disabled)
173                         ge_cairo_set_color (cr, border_disabled);
174         else
175                 if (!params->active)
176                         clearlooks_set_border_gradient (cr, &border_normal, 1.32, 0, height);
177                 else
178                         ge_cairo_set_color (cr, &border_normal);
179         
180         ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
181                                   width-(xoffset*2)-1, height-(yoffset*2)-1,
182                                   radius, params->corners);
183         cairo_stroke (cr);
184         
185         /* Draw the "shadow" */
186         if (!params->active)
187         {
188                 cairo_translate (cr, 0.5, 0.5);
189                 /* Draw right shadow */
190                 cairo_move_to (cr, width-params->xthickness, params->ythickness - 1);
191                 cairo_line_to (cr, width-params->xthickness, height - params->ythickness - 1);
192                 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
193                 cairo_stroke (cr);
194                 
195                 /* Draw topleft shadow */
196                 clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
197         }
198         cairo_restore (cr);
199 }
200
201 static void
202 clearlooks_inverted_draw_progressbar_fill (cairo_t *cr,
203                                   const ClearlooksColors *colors,
204                                   const WidgetParameters *params,
205                                   const ProgressBarParameters *progressbar,
206                                   int x, int y, int width, int height,
207                                   gint offset)
208 {
209         boolean      is_horizontal = progressbar->orientation < 2;
210         double       tile_pos = 0;
211         double       stroke_width;
212         double       radius;
213         int          x_step;
214
215         cairo_pattern_t *pattern;
216         CairoColor       bg_shade;
217         CairoColor       border;
218         CairoColor       shadow;
219         CairoColor       top_shade;
220
221         radius = MAX (0, params->radius - params->xthickness);
222
223         cairo_save (cr);
224
225         if (!is_horizontal)
226                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
227
228         if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
229                 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
230
231         /* Clamp the radius so that the _height_ fits ...  */
232         radius = MIN (radius, height / 2.0);
233
234         stroke_width = height*2;
235         x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
236         
237         cairo_translate (cr, x, y);
238
239         cairo_save (cr);
240         /* This is kind of nasty ... Clip twice from each side in case the length
241          * of the fill is smaller than twice the radius. */
242         ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
243         cairo_clip (cr);
244         ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
245         cairo_clip (cr);
246
247                 
248         ge_shade_color (&colors->spot[1], 1.05, &top_shade);
249
250         /* Draw the background gradient */
251         ge_shade_color (&colors->spot[1], 0.925, &bg_shade);
252         pattern = cairo_pattern_create_linear (0, 0, 0, height);
253         cairo_pattern_add_color_stop_rgb (pattern, 0.0, bg_shade.r, bg_shade.g, bg_shade.b);
254         cairo_pattern_add_color_stop_rgb (pattern, 0.5, top_shade.r, top_shade.g, top_shade.b);
255         cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg_shade.r, bg_shade.g, bg_shade.b);
256         cairo_set_source (cr, pattern);
257         cairo_paint (cr);
258         cairo_pattern_destroy (pattern);
259
260         /* Draw the Strokes */
261         while (tile_pos <= width+x_step)
262         {
263                 cairo_move_to (cr, stroke_width/2-x_step, 0);
264                 cairo_line_to (cr, stroke_width-x_step,   0);
265                 cairo_line_to (cr, stroke_width/2-x_step, height);
266                 cairo_line_to (cr, -x_step, height);
267                 
268                 cairo_translate (cr, stroke_width, 0);
269                 tile_pos += stroke_width;
270         }
271         
272         cairo_set_source_rgba (cr, colors->spot[2].r,
273                                    colors->spot[2].g,
274                                    colors->spot[2].b,
275                                    0.15);
276         
277         cairo_fill (cr);
278         cairo_restore (cr); /* rounded clip region */
279
280         /* inner highlight border
281          * This is again kinda ugly. Draw once from each side, clipping away the other. */
282         cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.5);
283
284         /* left side */
285         cairo_save (cr);
286         cairo_rectangle (cr, 0, 0, width / 2, height);
287         cairo_clip (cr);
288
289         if (progressbar->pulsing)
290                 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
291         else
292                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
293
294         cairo_stroke (cr);
295         cairo_restore (cr); /* clip */
296
297         /* right side */
298         cairo_save (cr);
299         cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
300         cairo_clip (cr);
301
302         if (progressbar->value < 1.0 || progressbar->pulsing)
303                 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
304         else
305                 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
306
307         cairo_stroke (cr);
308         cairo_restore (cr); /* clip */
309
310
311         /* Draw the dark lines and the shadow */
312         cairo_save (cr);
313         /* Again, this weird clip area. */
314         ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
315         cairo_clip (cr);
316         ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
317         cairo_clip (cr);
318
319         border = colors->spot[2];
320         border.a = 0.5;
321         shadow.r = 0.0;
322         shadow.g = 0.0;
323         shadow.b = 0.0;
324         shadow.a = 0.1;
325
326         if (progressbar->pulsing)
327         {
328                 /* At the beginning of the bar. */
329                 cairo_move_to (cr, 0.5 + radius, height + 0.5);
330                 ge_cairo_rounded_corner (cr, 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
331                 ge_cairo_rounded_corner (cr, 0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
332                 ge_cairo_set_color (cr, &border);
333                 cairo_stroke (cr);
334
335                 cairo_move_to (cr, -0.5 + radius, height + 0.5);
336                 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
337                 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
338                 ge_cairo_set_color (cr, &shadow);
339                 cairo_stroke (cr);
340         }
341         if (progressbar->value < 1.0 || progressbar->pulsing)
342         {
343                 /* At the end of the bar. */
344                 cairo_move_to (cr, width - 0.5 - radius, -0.5);
345                 ge_cairo_rounded_corner (cr, width - 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
346                 ge_cairo_rounded_corner (cr, width - 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
347                 ge_cairo_set_color (cr, &border);
348                 cairo_stroke (cr);
349
350                 cairo_move_to (cr, width + 0.5 - radius, -0.5);
351                 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
352                 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
353                 ge_cairo_set_color (cr, &shadow);
354                 cairo_stroke (cr);
355         }
356         
357         cairo_restore (cr);
358
359         cairo_restore (cr); /* rotation, mirroring */
360 }
361
362 static void
363 clearlooks_inverted_draw_menuitem (cairo_t *cr,
364                           const ClearlooksColors          *colors,
365                           const WidgetParameters          *widget,
366                           int x, int y, int width, int height)
367 {
368         const CairoColor *fill = &colors->spot[1];
369         CairoColor fill_shade;
370         CairoColor border = colors->spot[2];
371         cairo_pattern_t *pattern;
372
373         ge_shade_color (&border, 1.05, &border);
374         ge_shade_color (fill, 0.85, &fill_shade);
375         cairo_set_line_width (cr, 1.0);
376
377         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
378
379         pattern = cairo_pattern_create_linear (x, y, x, y + height);
380         cairo_pattern_add_color_stop_rgb (pattern, 0, fill_shade.r, fill_shade.g, fill_shade.b);
381         cairo_pattern_add_color_stop_rgb (pattern, 1.0,   fill->r, fill->g, fill->b);
382
383         cairo_set_source (cr, pattern);
384         cairo_fill_preserve  (cr);
385         cairo_pattern_destroy (pattern);
386
387         ge_cairo_set_color (cr, &border);
388         cairo_stroke (cr);
389 }
390
391 static void
392 clearlooks_inverted_draw_menubaritem (cairo_t *cr,
393                           const ClearlooksColors          *colors,
394                           const WidgetParameters          *widget,
395                           int x, int y, int width, int height)
396 {
397         const CairoColor *fill = &colors->spot[1];
398         CairoColor fill_shade;
399         CairoColor border = colors->spot[2];
400         cairo_pattern_t *pattern;
401         
402         ge_shade_color (&border, 1.05, &border);
403         ge_shade_color (fill, 0.85, &fill_shade);
404         
405         cairo_set_line_width (cr, 1.0);
406         ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
407
408         pattern = cairo_pattern_create_linear (x, y, x, y + height);
409         cairo_pattern_add_color_stop_rgb (pattern, 0, fill_shade.r, fill_shade.g, fill_shade.b);
410         cairo_pattern_add_color_stop_rgb (pattern, 1.0,   fill->r, fill->g, fill->b);
411
412         cairo_set_source (cr, pattern);
413         cairo_fill_preserve  (cr);
414         cairo_pattern_destroy (pattern);
415
416         ge_cairo_set_color (cr, &border);
417         cairo_stroke_preserve (cr);
418 }
419
420 static void
421 clearlooks_inverted_draw_tab (cairo_t *cr,
422                      const ClearlooksColors *colors,
423                      const WidgetParameters *params,
424                      const TabParameters    *tab,
425                      int x, int y, int width, int height)
426 {
427         const CairoColor    *border1       = &colors->shade[6];
428         const CairoColor    *border2       = &colors->shade[5];
429         const CairoColor    *stripe_fill   = &colors->spot[1];
430         const CairoColor    *stripe_border = &colors->spot[2];
431         const CairoColor    *fill;
432         CairoColor           hilight;
433         CairoColor           shadow;
434
435         cairo_pattern_t     *pattern;
436         
437         double               radius;
438         double               strip_size;
439
440         radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
441
442         /* Set clip */
443         cairo_rectangle      (cr, x, y, width, height);
444         cairo_clip           (cr);
445         cairo_new_path       (cr);
446
447         /* Translate and set line width */      
448         cairo_set_line_width (cr, 1.0);
449         cairo_translate      (cr, x+0.5, y+0.5);
450
451
452         /* Make the tabs slightly bigger than they should be, to create a gap */
453         /* And calculate the strip size too, while you're at it */
454         if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
455         {
456                 height += 3.0;
457                 strip_size = 2.0/height; /* 2 pixel high strip */
458                 
459                 if (tab->gap_side == CL_GAP_TOP)
460                         cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
461         }
462         else
463         {
464                 width += 3.0;
465                 strip_size = 2.0/width;
466                 
467                 if (tab->gap_side == CL_GAP_LEFT)
468                         cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
469         }
470         
471         /* Set the fill color */
472         fill = &colors->bg[params->state_type];
473
474         /* Set tab shape */
475         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
476                                     radius, params->corners);
477         
478         /* Draw fill */
479         ge_cairo_set_color (cr, fill);
480         cairo_fill   (cr);
481
482         ge_shade_color (fill, 1.3, &hilight);
483
484         if (params->active)
485         {
486                 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT   ? width-1  : 0,
487                                                         tab->gap_side == CL_GAP_TOP    ? height-2 : 1,
488                                                         tab->gap_side == CL_GAP_RIGHT  ? width    : 0,
489                                                         tab->gap_side == CL_GAP_BOTTOM ? height   : 0 );
490
491                 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
492                 
493                 ge_shade_color (fill, 0.92, &shadow);
494
495                 cairo_pattern_add_color_stop_rgba  (pattern, 0.0,                               hilight.r, hilight.g, hilight.b, 0.4);
496                 cairo_pattern_add_color_stop_rgba  (pattern, 1.0/height,  hilight.r, hilight.g, hilight.b, 0.4);
497                 cairo_pattern_add_color_stop_rgb        (pattern, 1.0/height,   fill->r,fill->g,fill->b);
498                 cairo_pattern_add_color_stop_rgb        (pattern, 1.0,                                  shadow.r,shadow.g,shadow.b);
499                 cairo_set_source (cr, pattern);
500                 cairo_fill (cr);
501                 cairo_pattern_destroy (pattern);
502         }
503         else
504         {
505                 /* Draw shade */
506                 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT   ? width-2  : 0,
507                                                         tab->gap_side == CL_GAP_TOP    ? height-2 : 0,
508                                                         tab->gap_side == CL_GAP_RIGHT  ? width    : 0,
509                                                         tab->gap_side == CL_GAP_BOTTOM ? height   : 0 );
510         
511                 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
512                 
513
514                 cairo_pattern_add_color_stop_rgb  (pattern, 0.0,        stripe_fill->r, stripe_fill->g, stripe_fill->b);
515                 cairo_pattern_add_color_stop_rgb  (pattern, strip_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
516                 cairo_pattern_add_color_stop_rgba (pattern, strip_size, hilight.r, hilight.g, hilight.b, 0.0);
517                 cairo_pattern_add_color_stop_rgba (pattern, 0.8,        hilight.r, hilight.g, hilight.b, 0.0);
518                 cairo_set_source (cr, pattern);
519                 cairo_fill (cr);
520                 cairo_pattern_destroy (pattern);
521         }
522
523         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
524         
525         if (params->active)
526         {
527                 ge_cairo_set_color (cr, border2);       
528                 cairo_stroke (cr);
529         }
530         else
531         {
532                 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT   ? width-2  : 2,
533                                                         tab->gap_side == CL_GAP_TOP    ? height-2 : 2,
534                                                         tab->gap_side == CL_GAP_RIGHT  ? width    : 2,
535                                                         tab->gap_side == CL_GAP_BOTTOM ? height   : 2 );
536                 
537                 cairo_pattern_add_color_stop_rgb (pattern, 0.0,        stripe_border->r, stripe_border->g, stripe_border->b);
538                 cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_border->r, stripe_border->g, stripe_border->b);
539                 cairo_pattern_add_color_stop_rgb (pattern, strip_size, border1->r,       border1->g,       border1->b);
540                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,        border2->r,       border2->g,       border2->b);
541                 cairo_set_source (cr, pattern);
542                 cairo_stroke (cr);
543                 cairo_pattern_destroy (pattern);
544         }
545 }
546
547 static void
548 clearlooks_inverted_draw_slider (cairo_t *cr,
549                         const ClearlooksColors *colors,
550                         const WidgetParameters *params,
551                         int x, int y, int width, int height)
552 {
553         const CairoColor *border = &colors->shade[params->disabled ? 4 : 6];
554         const CairoColor *spot   = &colors->spot[1];
555         const CairoColor *fill   = &colors->shade[2];
556         double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
557
558         cairo_pattern_t *pattern;
559
560         cairo_set_line_width (cr, 1.0); 
561         cairo_translate      (cr, x, y);
562
563         if (params->disabled)
564                 border = &colors->shade[4];
565         else if (params->prelight)
566                 border = &colors->spot[2];
567         else
568                 border = &colors->shade[6];
569
570         /* fill the widget */
571         cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
572
573         /* Fake light */
574         if (!params->disabled)
575         {
576                 const CairoColor *top = &colors->shade[2];
577                 const CairoColor *bot = &colors->shade[0];
578
579                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
580                 cairo_pattern_add_color_stop_rgb (pattern, 0.0,  top->r, top->g, top->b);
581                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,  bot->r, bot->g, bot->b);
582                 cairo_set_source (cr, pattern);
583                 cairo_fill (cr);
584                 cairo_pattern_destroy (pattern);
585         }
586         else
587         {
588                 ge_cairo_set_color (cr, fill);
589                 cairo_rectangle    (cr, 0.5, 0.5, width-2, height-2);
590                 cairo_fill         (cr);
591         }
592
593         /* Set the clip */
594         cairo_save (cr);
595         cairo_rectangle (cr, 0.5, 0.5, 6, height-2);
596         cairo_rectangle (cr, width-7.5, 0.5, 6 , height-2);
597         cairo_clip_preserve (cr);
598
599         cairo_new_path (cr);
600
601         /* Draw the handles */
602         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
603         pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, 0.5+height);
604
605         if (params->prelight)
606         {
607                 CairoColor highlight;
608                 ge_shade_color (spot, 1.5, &highlight);
609                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, spot->r, spot->g, spot->b);
610                 cairo_pattern_add_color_stop_rgb (pattern, 1.0, highlight.r, highlight.g, highlight.b);
611                 cairo_set_source (cr, pattern);
612         }
613         else {
614                 CairoColor hilight;
615                 ge_shade_color (fill, 1.5, &hilight);
616                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
617         }
618
619         cairo_fill (cr);
620         cairo_pattern_destroy (pattern);
621
622         cairo_restore (cr);
623
624         /* Draw the border */
625         ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
626         if (params->prelight || params->disabled)
627                 ge_cairo_set_color (cr, border);
628         else
629                 clearlooks_set_border_gradient (cr, border, 1.2, 0, height);
630         cairo_stroke (cr);
631
632         /* Draw handle lines */
633         if (width > 14)
634         {
635                 cairo_move_to (cr, 6, 0.5);
636                 cairo_line_to (cr, 6, height-1);
637         
638                 cairo_move_to (cr, width-7, 0.5);
639                 cairo_line_to (cr, width-7, height-1);
640         
641                 cairo_set_line_width (cr, 1.0);
642                 cairo_set_source_rgba (cr, border->r,
643                                            border->g,
644                                            border->b,
645                                            0.3);
646                 cairo_stroke (cr);
647         }
648 }
649
650 static void
651 clearlooks_inverted_draw_slider_button (cairo_t *cr,
652                                const ClearlooksColors *colors,
653                                const WidgetParameters *params,
654                                const SliderParameters *slider,
655                                int x, int y, int width, int height)
656 {
657         double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
658         cairo_set_line_width (cr, 1.0);
659         
660         if (!slider->horizontal)
661                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
662         cairo_translate (cr, x+0.5, y+0.5);
663
664         params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
665         params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
666
667         if (width > 24)
668                 params->style_functions->draw_gripdots (cr, colors, 0, 0, width-2, height-2, 3, 3, 0);
669 }
670
671 static void
672 clearlooks_inverted_draw_list_view_header (cairo_t *cr,
673                                   const ClearlooksColors          *colors,
674                                   const WidgetParameters          *params,
675                                   const ListViewHeaderParameters  *header,
676                                   int x, int y, int width, int height)
677 {
678         const CairoColor *fill = &colors->bg[params->state_type];
679         const CairoColor *border = &colors->shade[4];
680         cairo_pattern_t *pattern;
681         CairoColor hilight_header;
682         CairoColor hilight;
683         CairoColor shadow;
684
685         ge_shade_color (border, 1.5, &hilight);
686         ge_shade_color (fill, 1.05, &hilight_header);   
687         ge_shade_color (fill, 0.95, &shadow);   
688
689         cairo_translate (cr, x, y);
690         cairo_set_line_width (cr, 1.0);
691         
692         /* Draw highlight */
693         if (header->order == CL_ORDER_FIRST)
694         {
695                 cairo_move_to (cr, 0.5, height-1);
696                 cairo_line_to (cr, 0.5, 0.5);
697         }
698         else
699                 cairo_move_to (cr, 0.0, 0.5);
700         
701         cairo_line_to (cr, width, 0.5);
702         
703         ge_cairo_set_color (cr, &hilight);
704         cairo_stroke (cr);
705         
706         /* Draw bottom border */
707         cairo_move_to (cr, 0.0, height-0.5);
708         cairo_line_to (cr, width, height-0.5);
709         ge_cairo_set_color (cr, border);
710         cairo_stroke (cr);
711
712         /* Draw bottom shade */ 
713         pattern = cairo_pattern_create_linear (0.0, 0, 0.0, height-1.0);
714         cairo_pattern_add_color_stop_rgb     (pattern, 0.0, shadow.r, shadow.g, shadow.b);
715         cairo_pattern_add_color_stop_rgb     (pattern, 1.0, hilight_header.r, hilight_header.g, hilight_header.b);
716
717         cairo_rectangle       (cr, 0, 1, width, height-2);
718         cairo_set_source      (cr, pattern);
719         cairo_fill            (cr);
720         cairo_pattern_destroy (pattern);
721         
722         /* Draw resize grip */
723         if ((params->ltr && header->order != CL_ORDER_LAST) ||
724             (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
725         {
726                 SeparatorParameters separator;
727                 separator.horizontal = FALSE;
728                 
729                 if (params->ltr)
730                         params->style_functions->draw_separator (cr, colors, params, &separator,
731                                                                  width-1.5, 4.0, 2, height-8.0);
732                 else
733                         params->style_functions->draw_separator (cr, colors, params, &separator,
734                                                                  1.5, 4.0, 2, height-8.0);
735         }
736 }
737
738
739 static void
740 clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
741                                    const ClearlooksColors           *colors,
742                                    const WidgetParameters           *widget,
743                                    const ScrollBarParameters        *scrollbar,
744                                    const ScrollBarStepperParameters *stepper,
745                                    int x, int y, int width, int height)
746 {
747         CairoCorners corners = CR_CORNER_NONE;
748         CairoColor border;
749         CairoColor s1, s2, s3;
750         cairo_pattern_t *pattern;
751         double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
752         
753         ge_shade_color(&colors->shade[6], 1.05, &border);
754
755         if (scrollbar->horizontal)
756         {
757                 if (stepper->stepper == CL_STEPPER_A)
758                         corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
759                 else if (stepper->stepper == CL_STEPPER_D)
760                         corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
761         }
762         else
763         {
764                 if (stepper->stepper == CL_STEPPER_A)
765                         corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
766                 else if (stepper->stepper == CL_STEPPER_D)
767                         corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
768         }
769         
770         cairo_translate (cr, x, y);
771         cairo_set_line_width (cr, 1);
772         
773         ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
774         
775         if (scrollbar->horizontal)
776                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
777         else
778                 pattern = cairo_pattern_create_linear (0, 0, width, 0);
779                                 
780         s1 = colors->bg[widget->state_type];
781         ge_shade_color(&s1, 0.95, &s2);
782         ge_shade_color(&s1, 1.05, &s3);
783         
784         cairo_pattern_add_color_stop_rgb(pattern, 0,    s2.r, s2.g, s2.b);
785         cairo_pattern_add_color_stop_rgb(pattern, 1.0,  s3.r, s3.g, s3.b);
786         cairo_set_source (cr, pattern);
787         cairo_fill (cr);
788         cairo_pattern_destroy (pattern);
789
790         clearlooks_draw_top_left_highlight (cr, &s1, widget, width, height, radius);
791
792         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);  
793         clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
794         cairo_stroke (cr);
795         
796         cairo_translate (cr, 0.5, 0.5);
797 }
798
799 static void
800 clearlooks_inverted_draw_scrollbar_slider (cairo_t *cr,
801                                    const ClearlooksColors          *colors,
802                                    const WidgetParameters          *widget,
803                                    const ScrollBarParameters       *scrollbar,
804                                    int x, int y, int width, int height)
805 {
806         if (scrollbar->junction & CL_JUNCTION_BEGIN)
807         {
808                 if (scrollbar->horizontal)
809                 {
810                         x -= 1;
811                         width += 1;
812                 }
813                 else
814                 {
815                         y -= 1;
816                         height += 1;
817                 }
818         }
819         if (scrollbar->junction & CL_JUNCTION_END)
820         {
821                 if (scrollbar->horizontal)
822                         width += 1;
823                 else
824                         height += 1;
825         }
826         
827         if (!scrollbar->horizontal)
828                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
829
830         cairo_translate (cr, x, y);     
831
832         if (scrollbar->has_color)
833         {
834                 const CairoColor *border = &colors->shade[8];
835                 CairoColor  fill    = scrollbar->color;
836                 CairoColor  hilight;
837                 CairoColor  shade1, shade2, shade3;
838                 cairo_pattern_t *pattern;
839                                 
840                 if (widget->prelight)
841                         ge_shade_color (&fill, 1.1, &fill);
842                         
843                 cairo_set_line_width (cr, 1);
844                 
845                 ge_shade_color (&fill, 1.3, &hilight);
846                 ge_shade_color (&fill, 1.1, &shade1);
847                 ge_shade_color (&fill, 1.05, &shade2);
848                 ge_shade_color (&fill, 0.98, &shade3);
849                 
850                 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
851                 cairo_pattern_add_color_stop_rgb (pattern, 0,    fill.r,  fill.g,  fill.b);
852                 cairo_pattern_add_color_stop_rgb (pattern, 0.5,  shade3.r, shade3.g, shade3.b);
853                 cairo_pattern_add_color_stop_rgb (pattern, 0.5,  shade2.r, shade2.g, shade2.b); 
854                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,  shade1.r, shade1.g, shade1.b);
855                 cairo_rectangle (cr, 1, 1, width-2, height-2);
856                 cairo_set_source (cr, pattern);
857                 cairo_fill (cr);
858                 cairo_pattern_destroy (pattern);
859                 
860                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
861                 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
862         
863                 ge_cairo_set_color (cr, border);
864                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
865         }
866         else
867         {
868                 CairoColor border;
869                 CairoColor s1, s2, s3;
870                 cairo_pattern_t *pattern;
871                 int bar_x, i;
872                 
873                 const CairoColor *dark  = &colors->shade[4];
874                 const CairoColor *light = &colors->shade[0];            
875
876                 ge_shade_color(&colors->shade[6], 1.05, &border);
877
878                 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
879
880                 s1 = colors->bg[widget->state_type];
881                 ge_shade_color(&s1, 0.95, &s2);
882                 ge_shade_color(&s1, 1.05, &s3);
883
884                 cairo_pattern_add_color_stop_rgb(pattern, 0,    s2.r, s2.g, s2.b);
885                 cairo_pattern_add_color_stop_rgb(pattern, 1.0,  s3.r, s3.g, s3.b);
886
887                 cairo_rectangle (cr, 1, 1, width-2, height-2);
888                 cairo_set_source(cr, pattern);
889                 cairo_fill(cr);
890                 cairo_pattern_destroy(pattern);
891                 
892                 clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, 0);
893
894                 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
895                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
896                 
897                 /* draw handles */
898                 cairo_set_line_width (cr, 1);
899                 
900                 bar_x = width/2 - 4;
901                 cairo_translate(cr, 0.5, 0.5);
902                 for (i=0; i<3; i++)
903                 {
904                         cairo_move_to (cr, bar_x, 4);
905                         cairo_line_to (cr, bar_x, height-5);
906                         ge_cairo_set_color (cr, dark);
907                         cairo_stroke (cr);
908                         
909                         cairo_move_to (cr, bar_x+1, 4);
910                         cairo_line_to (cr, bar_x+1, height-5);
911                         ge_cairo_set_color (cr, light);
912                         cairo_stroke (cr);
913                         
914                         bar_x += 3;
915                 }
916         }
917 }
918
919 static void
920 clearlooks_inverted_draw_selected_cell (cairo_t                  *cr,
921                                const ClearlooksColors   *colors,
922                                const WidgetParameters   *params,
923                                int x, int y, int width, int height)
924 {
925         CairoColor upper_color;
926         CairoColor lower_color;
927         CairoColor border;
928         cairo_pattern_t *pattern;
929         cairo_save (cr);
930         
931         cairo_translate (cr, x, y);
932
933         if (params->focus)
934                 upper_color = colors->base[params->state_type];
935         else
936                 upper_color = colors->base[GTK_STATE_ACTIVE];
937
938         ge_shade_color(&upper_color, 0.9, &lower_color);
939
940         pattern = cairo_pattern_create_linear (0, 0, 0, height);
941         cairo_pattern_add_color_stop_rgb (pattern, 0.0, lower_color.r,
942                                                         lower_color.g,
943                                                         lower_color.b);
944         cairo_pattern_add_color_stop_rgb (pattern, 1.0, upper_color.r,
945                                                         upper_color.g,
946                                                         upper_color.b);
947
948
949         cairo_set_source (cr, pattern);
950         cairo_rectangle  (cr, 0, 0, width, height);
951         cairo_fill       (cr);
952         cairo_pattern_destroy (pattern);
953
954         ge_shade_color(&upper_color, 0.8, &border);     
955
956         cairo_move_to  (cr, 0, 0.5);
957         cairo_rel_line_to (cr, width, 0);
958         cairo_move_to  (cr, 0, height-0.5);
959         cairo_rel_line_to (cr, width, 0);
960
961         ge_cairo_set_color (cr, &border);
962         cairo_stroke (cr);
963
964         cairo_restore (cr);
965 }
966
967 void
968 clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions)
969 {
970         functions->draw_button            = clearlooks_inverted_draw_button;
971         functions->draw_slider            = clearlooks_inverted_draw_slider;
972         functions->draw_slider_button     = clearlooks_inverted_draw_slider_button;
973         functions->draw_progressbar_fill  = clearlooks_inverted_draw_progressbar_fill;
974         functions->draw_menuitem          = clearlooks_inverted_draw_menuitem;
975         functions->draw_menubaritem       = clearlooks_inverted_draw_menubaritem;
976         functions->draw_tab               = clearlooks_inverted_draw_tab;
977         functions->draw_list_view_header  = clearlooks_inverted_draw_list_view_header;
978         functions->draw_scrollbar_stepper = clearlooks_inverted_draw_scrollbar_stepper; 
979         functions->draw_scrollbar_slider  = clearlooks_inverted_draw_scrollbar_slider;
980         functions->draw_selected_cell     = clearlooks_inverted_draw_selected_cell;
981 }
982