1 /* Clearlooks Glossy style
2 * Copyright (C) 2006 Benjamin Berg
3 * Copyright (C) 2007 Andrea Cimitan
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.
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.
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.
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.
27 #include "clearlooks_draw.h"
28 #include "clearlooks_style.h"
29 #include "clearlooks_types.h"
32 #include <ge-support.h>
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)
43 CairoColor a, b, c, d;
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);
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);
57 cairo_set_source (cr, pt);
58 ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, corners);
61 cairo_pattern_destroy (pt);
65 clearlooks_set_mixed_color (cairo_t *cr,
66 const CairoColor *color1,
67 const CairoColor *color2,
72 ge_mix_color (color1, color2, mix_factor, &composite);
73 ge_cairo_set_color (cr, &composite);
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)
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);
90 cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
92 if (corners & CR_CORNER_TOPRIGHT)
93 cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.75, G_PI * 2);
95 cairo_line_to (cr, x + w, y);
97 if (corners & CR_CORNER_BOTTOMRIGHT)
98 cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
100 cairo_line_to (cr, x + w, y + h);
102 if (corners & CR_CORNER_BOTTOMLEFT)
103 cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI * 0.75);
105 cairo_line_to (cr, x, y + h);
107 ge_cairo_set_color (cr, &highlight);
111 cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
113 if (corners & CR_CORNER_BOTTOMLEFT)
114 cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.75, M_PI);
116 cairo_line_to (cr, x, y + h);
118 if (corners & CR_CORNER_TOPLEFT)
119 cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
121 cairo_line_to (cr, x, y);
123 if (corners & CR_CORNER_TOPRIGHT)
124 cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, M_PI * 1.75);
126 cairo_line_to (cr, x + w, y);
128 ge_cairo_set_color (cr, &shadow);
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)
139 CairoColor highlight;
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);
146 cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
148 if (corners & CR_CORNER_TOPRIGHT)
149 cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.75, G_PI * 2);
151 cairo_line_to (cr, x + w, y);
153 if (corners & CR_CORNER_BOTTOMRIGHT)
154 cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
156 cairo_line_to (cr, x + w, y + h);
158 if (corners & CR_CORNER_BOTTOMLEFT)
159 cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI * 0.75);
161 cairo_line_to (cr, x, y + h);
163 ge_cairo_set_color (cr, &highlight);
167 cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
169 if (corners & CR_CORNER_BOTTOMLEFT)
170 cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.75, M_PI);
172 cairo_line_to (cr, x, y + h);
174 if (corners & CR_CORNER_TOPLEFT)
175 cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
177 cairo_line_to (cr, x, y);
179 if (corners & CR_CORNER_TOPRIGHT)
180 cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, M_PI * 1.75);
182 cairo_line_to (cr, x + w, y);
184 ge_cairo_set_color (cr, &shadow);
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)
195 CairoColor highlight;
196 uint8 corners = params->corners;
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);
206 /* Top/Left highlight */
207 if (corners & CR_CORNER_BOTTOMLEFT)
208 cairo_move_to (cr, x, y+height-radius);
210 cairo_move_to (cr, x, y+height);
212 ge_cairo_rounded_corner (cr, x, y, radius, corners & CR_CORNER_TOPLEFT);
214 if (corners & CR_CORNER_TOPRIGHT)
215 cairo_line_to (cr, x+width-radius, y);
217 cairo_line_to (cr, x+width, y);
219 if (params->shadow & CL_SHADOW_OUT)
220 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
222 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
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);
232 if (params->shadow & CL_SHADOW_OUT)
233 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
235 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
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)
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];
254 cairo_pattern_t *pattern;
257 cairo_translate (cr, x, y);
258 cairo_set_line_width (cr, 1.0);
260 /* Shadows and Glow */
261 if (params->xthickness == 3 || params->ythickness == 3)
263 if (params->xthickness == 3)
265 if (params->ythickness == 3)
269 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0, (height - 2.0 - 2*yoffset) / 2.0));
271 if (params->xthickness == 3 || params->ythickness == 3)
273 cairo_translate (cr, 0.5, 0.5);
275 /* if (params->enable_glow && !params->active && !params->disabled) */
276 if (params->prelight && params->enable_glow && !params->active)
278 /* Glow becomes a shadow to have 3d prelight buttons :) */
281 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
283 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius+1, params->corners);
284 ge_shade_color (¶ms->parentbg, 0.96, &glow);
285 ge_cairo_set_color (cr, &glow);
288 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius+1, params->corners);
289 ge_shade_color (¶ms->parentbg, 0.92, &glow);
290 ge_cairo_set_color (cr, &glow);
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, ¶ms->parentbg, 0, 0, width-1, height-1, params->radius+1, params->corners);
299 /*Draw a lighter inset */
300 clearlooks_glossy_draw_light_inset (cr, ¶ms->parentbg, 0, 0, width-1, height-1, params->radius+1, params->corners);
301 cairo_translate (cr, -0.5, -0.5);
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);
308 /* Pressed button shadow */
312 ge_shade_color (&fill, 0.92, &shadow);
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));
318 cairo_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, 3);
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);
325 cairo_pattern_destroy (pattern);
327 cairo_rectangle (cr, xoffset+1, yoffset+1, 3, height-(yoffset*2)-2);
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);
334 cairo_pattern_destroy (pattern);
339 /* Default button highlight */
340 if (params->is_default && !params->active && !params->disabled)
342 const CairoColor *glow = &colors->spot[0];
343 double hh = (height-5)/2.0 + 1;
345 cairo_rectangle (cr, 3.5, 3.5, width-7, height-7);
346 ge_cairo_set_color (cr, glow);
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);
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);
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);
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);
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)
385 const CairoColor *border = &colors->shade[6];
387 cairo_pattern_t *pattern;
388 double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
392 cairo_set_line_width (cr, 1.0);
394 /* Fill with bg color */
395 ge_cairo_set_color (cr, &colors->bg[params->state_type]);
397 cairo_rectangle (cr, x, y, width, height);
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]);
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);
410 /* clip the corners of the shadows */
411 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
414 ge_shade_color (border, 0.92, &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);
423 cairo_pattern_destroy (pattern);
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);
432 cairo_pattern_destroy (pattern);
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,
445 boolean is_horizontal = progressbar->orientation < 2;
451 cairo_pattern_t *pattern;
458 radius = MAX (0, params->radius - params->xthickness);
463 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
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);
468 /* Clamp the radius so that the _height_ fits ... */
469 radius = MIN (radius, height / 2.0);
471 stroke_width = height*2;
472 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
474 cairo_translate (cr, x, y);
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);
481 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
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);
495 cairo_pattern_destroy (pattern);
497 /* Draw the Strokes */
498 while (tile_pos <= width+x_step)
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);
505 cairo_translate (cr, stroke_width, 0);
506 tile_pos += stroke_width;
509 cairo_set_source_rgba (cr, colors->spot[2].r,
515 cairo_restore (cr); /* rounded clip region */
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);
523 cairo_rectangle (cr, 0, 0, width / 2, height);
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);
529 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
532 cairo_restore (cr); /* clip */
536 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
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);
542 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
545 cairo_restore (cr); /* clip */
548 /* Draw the dark lines and the shadow */
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);
553 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
556 border = colors->spot[2];
558 ge_shade_color (&colors->shade[6], 0.92, &shadow);
561 if (progressbar->pulsing)
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);
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);
576 if (progressbar->value < 1.0 || progressbar->pulsing)
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);
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);
594 cairo_restore (cr); /* rotation, mirroring */
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,
605 cairo_pattern_t *pattern;
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);
611 cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
612 cairo_set_source (cr, pattern);
614 cairo_pattern_destroy (pattern);
616 clearlooks_set_mixed_color (cr, c3, c1, 0.3);
617 ge_cairo_stroke_rectangle (cr, x, y, width, height);
620 #define TROUGH_SIZE 6
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)
628 int trough_width, trough_height;
629 double translate_x, translate_y;
631 if (slider->horizontal)
633 trough_width = width-3;
634 trough_height = TROUGH_SIZE-2;
636 translate_x = x + 0.5;
637 translate_y = y + 0.5 + (height/2) - (TROUGH_SIZE/2);
641 trough_width = TROUGH_SIZE-2;
642 trough_height = height-3;
644 translate_x = x + 0.5 + (width/2) - (TROUGH_SIZE/2);
645 translate_y = y + 0.5;
648 cairo_set_line_width (cr, 1.0);
649 cairo_translate (cr, translate_x, translate_y);
651 if (!slider->fill_level)
652 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, trough_width+2, trough_height+2, 0, 0);
654 cairo_translate (cr, 1, 1);
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,
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,
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)
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;
684 cairo_pattern_t *pattern;
689 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
692 cairo_rectangle (cr, x, y, width, height);
696 /* Translate and set line width */
697 cairo_set_line_width (cr, 1.0);
698 cairo_translate (cr, x+0.5, y+0.5);
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)
706 strip_size = 2.0/height; /* 2 pixel high strip */
708 if (tab->gap_side == CL_GAP_TOP)
709 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
714 strip_size = 2.0/width;
716 if (tab->gap_side == CL_GAP_LEFT)
717 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
720 /* Set the fill color */
721 fill = &colors->bg[params->state_type];
724 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
725 radius, params->corners);
728 ge_cairo_set_color (cr, fill);
731 ge_shade_color (fill, 1.3, &hilight);
736 ShadowParameters shadow;
738 shadow.shadow = CL_SHADOW_OUT;
739 shadow.corners = params->corners;
741 clearlooks_glossy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow,
748 CairoColor shadow, hilight, f1, f2;
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);
755 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
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);
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);
770 cairo_pattern_destroy (pattern);
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);
780 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
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);
787 cairo_pattern_destroy (pattern);
790 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
794 ge_cairo_set_color (cr, border);
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);
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);
808 cairo_pattern_destroy (pattern);
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)
818 const CairoColor *border = &colors->shade[7];
821 CairoColor a, b, c, d;
822 cairo_pattern_t *pattern;
824 cairo_set_line_width (cr, 1.0);
825 cairo_translate (cr, x, y);
827 cairo_translate (cr, -0.5, -0.5);
829 ge_shade_color (&colors->bg[params->state_type], 1.0, &fill);
830 if (params->prelight)
831 ge_shade_color (&fill, 1.1, &fill);
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);
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);
847 cairo_pattern_destroy (pattern);
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);
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);
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)
867 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
869 cairo_set_line_width (cr, 1.0);
871 if (!slider->horizontal)
872 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
874 cairo_translate (cr, x+0.5, y+0.5);
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);
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)
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));
895 if (scrollbar->horizontal)
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;
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;
910 cairo_translate (cr, x, y);
911 cairo_set_line_width (cr, 1);
913 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
915 if (scrollbar->horizontal)
916 pattern = cairo_pattern_create_linear (0, 0, 0, height);
918 pattern = cairo_pattern_create_linear (0, 0, width, 0);
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);
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);
931 cairo_pattern_destroy (pattern);
933 cairo_translate (cr, 0.5, 0.5);
934 cairo_translate (cr, -0.5, -0.5);
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]);
942 cairo_translate (cr, 0.5, 0.5);
943 shadow.shadow = CL_SHADOW_OUT;
944 shadow.corners = corners;
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)
954 const CairoColor *border = &colors->shade[7];
955 CairoColor fill = scrollbar->color;
957 CairoColor shade1, shade2, shade3;
958 cairo_pattern_t *pattern;
960 if (scrollbar->junction & CL_JUNCTION_BEGIN)
962 if (scrollbar->horizontal)
973 if (scrollbar->junction & CL_JUNCTION_END)
975 if (scrollbar->horizontal)
981 if (!scrollbar->horizontal)
982 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
984 cairo_translate (cr, x, y);
986 if (widget->prelight)
987 ge_shade_color (&fill, 1.1, &fill);
989 cairo_set_line_width (cr, 1);
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);
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);
1004 cairo_pattern_destroy (pattern);
1006 if (scrollbar->has_color)
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);
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);
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)
1024 CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
1026 const CairoColor *border = &colors->shade[4];
1027 const CairoColor *fill = &colors->bg[params->state_type];
1029 CairoColor shade1, shade2, shade3;
1031 cairo_pattern_t *pattern;
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);
1038 cairo_translate (cr, x, y);
1039 cairo_set_line_width (cr, 1.0);
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);
1050 cairo_set_source (cr, pattern);
1051 cairo_rectangle (cr, 0, 0, width, height);
1054 cairo_pattern_destroy (pattern);
1056 /* Draw highlight */
1057 if (header->order == CL_ORDER_FIRST)
1059 cairo_move_to (cr, 0.5, height-1);
1060 cairo_line_to (cr, 0.5, 0.5);
1063 cairo_move_to (cr, 0.0, 0.5);
1065 cairo_line_to (cr, width, 0.5);
1067 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1070 /* Draw resize grip */
1071 if ((params->ltr && header->order != CL_ORDER_LAST) ||
1072 (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
1074 SeparatorParameters separator;
1075 separator.horizontal = FALSE;
1078 params->style_functions->draw_separator (cr, colors, params, &separator,
1079 width-1.5, 4.0, 2, height-8.0);
1081 params->style_functions->draw_separator (cr, colors, params, &separator,
1082 1.5, 4.0, 2, height-8.0);
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)
1093 const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL];
1094 const CairoColor *dark = &colors->shade[3];
1096 ge_shade_color (fill, 1.1, &light);
1098 cairo_set_line_width (cr, 1.0);
1099 cairo_translate (cr, x, y);
1101 if (toolbar->style == 1) /* Enable Extra features */
1103 cairo_pattern_t *pattern;
1104 CairoColor shade1, shade2, shade3;
1106 ge_shade_color (fill, 1.08, &shade1);
1107 ge_shade_color (fill, 1.04, &shade2);
1108 ge_shade_color (fill, 1.04, &shade3);
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);
1117 cairo_set_source (cr, pattern);
1118 cairo_rectangle (cr, 0, 0, width, height);
1121 cairo_pattern_destroy (pattern);
1125 ge_cairo_set_color (cr, fill);
1128 if (!toolbar->topmost)
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);
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);
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)
1151 const CairoColor *fill = &colors->spot[1];
1152 const CairoColor *border = &colors->spot[2];
1153 CairoColor shade1, shade2, shade3;
1154 cairo_pattern_t *pattern;
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);
1161 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
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);
1169 cairo_set_source (cr, pattern);
1170 cairo_fill_preserve (cr);
1171 cairo_pattern_destroy (pattern);
1173 ge_cairo_set_color (cr, border);
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)
1183 const CairoColor *fill = &colors->spot[1];
1184 const CairoColor *border = &colors->spot[2];
1185 CairoColor shade1, shade2, shade3;
1186 cairo_pattern_t *pattern;
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);
1193 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
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);
1201 cairo_set_source (cr, pattern);
1202 cairo_fill_preserve (cr);
1203 cairo_pattern_destroy (pattern);
1205 ge_cairo_set_color (cr, border);
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)
1218 color = colors->base[params->state_type];
1220 color = colors->base[GTK_STATE_ACTIVE];
1222 clearlooks_draw_glossy_gradient (cr, x, y, width, height, &color, params->disabled, 0.0, CR_CORNER_NONE);
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)
1233 const CairoColor *border;
1234 const CairoColor *dot;
1236 CairoColor highlight;
1237 cairo_pattern_t *pt;
1238 gboolean inconsistent;
1239 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1241 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1242 draw_bullet |= inconsistent;
1244 if (widget->disabled)
1246 border = &colors->shade[5];
1247 dot = &colors->shade[6];
1251 if (widget->prelight)
1252 border = &colors->spot[2];
1254 border = &colors->shade[6];
1255 dot = &colors->text[0];
1258 ge_shade_color (&widget->parentbg, 0.9, &shadow);
1259 ge_shade_color (&widget->parentbg, 1.1, &highlight);
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);
1267 cairo_translate (cr, x, y);
1269 cairo_set_line_width (cr, 2);
1270 cairo_arc (cr, 7, 7, 6, 0, G_PI*2);
1271 cairo_set_source (cr, pt);
1273 cairo_pattern_destroy (pt);
1275 cairo_set_line_width (cr, 1);
1277 cairo_arc (cr, 7, 7, 5.5, 0, G_PI*2);
1279 if (!widget->disabled)
1281 if (widget->prelight)
1282 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1284 ge_cairo_set_color (cr, &colors->base[0]);
1285 cairo_fill_preserve (cr);
1288 ge_cairo_set_color (cr, border);
1295 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1296 cairo_set_line_width (cr, 4);
1298 cairo_move_to(cr, 5, 7);
1299 cairo_line_to(cr, 9, 7);
1301 ge_cairo_set_color (cr, dot);
1306 cairo_arc (cr, 7, 7, 3, 0, G_PI*2);
1307 ge_cairo_set_color (cr, dot);
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);
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)
1324 const CairoColor *border;
1325 const CairoColor *dot;
1326 gboolean inconsistent = FALSE;
1327 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1329 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1330 draw_bullet |= inconsistent;
1332 if (widget->disabled)
1334 border = &colors->shade[5];
1335 dot = &colors->shade[6];
1339 if (widget->prelight)
1340 border = &colors->spot[2];
1342 border = &colors->shade[6];
1343 dot = &colors->text[GTK_STATE_NORMAL];
1346 cairo_translate (cr, x, y);
1347 cairo_set_line_width (cr, 1);
1349 if (widget->xthickness > 2 && widget->ythickness > 2)
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);
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);
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);
1365 if (!widget->disabled)
1367 if (widget->prelight)
1368 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1370 ge_cairo_set_color (cr, &colors->base[0]);
1371 cairo_fill_preserve (cr);
1374 ge_cairo_set_color (cr, border);
1379 if (inconsistent) /* Inconsistent */
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);
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));
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));
1397 ge_cairo_set_color (cr, dot);
1403 clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions)
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;