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);
76 /* This draw_inset implementation only differes in the shades values from the
79 clearlooks_glossy_draw_inset (cairo_t *cr,
80 const CairoColor *bg_color,
81 double x, double y, double width, double height,
82 double radius, uint8 corners)
87 double min = MIN (width, height);
89 line_width = cairo_get_line_width (cr);
91 /* not really sure of shading ratios... we will think */
92 ge_shade_color (bg_color, 0.93, &shadow);
93 ge_shade_color (bg_color, 1.07, &highlight);
98 cairo_move_to (cr, x, y + height);
99 cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
100 cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
101 cairo_line_to (cr, x + width, y);
102 cairo_line_to (cr, x, y);
103 cairo_close_path (cr);
107 ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
108 width - line_width, height - line_width,
111 ge_cairo_set_color (cr, &shadow);
119 cairo_move_to (cr, x, y + height);
120 cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
121 cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
122 cairo_line_to (cr, x + width, y);
123 cairo_line_to (cr, x + width, y + height);
124 cairo_close_path (cr);
128 ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
129 width - line_width, height - line_width,
132 ge_cairo_set_color (cr, &highlight);
139 clearlooks_glossy_draw_light_inset (cairo_t *cr,
140 const CairoColor *bg_color,
141 double x, double y, double w, double h,
142 double radius, uint8 corners)
145 CairoColor highlight;
147 /* not really sure of shading ratios... we will think */
148 ge_shade_color (bg_color, 0.95, &shadow);
149 ge_shade_color (bg_color, 1.05, &highlight);
152 cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
154 if (corners & CR_CORNER_TOPRIGHT)
155 cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.75, G_PI * 2);
157 cairo_line_to (cr, x + w, y);
159 if (corners & CR_CORNER_BOTTOMRIGHT)
160 cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
162 cairo_line_to (cr, x + w, y + h);
164 if (corners & CR_CORNER_BOTTOMLEFT)
165 cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI * 0.75);
167 cairo_line_to (cr, x, y + h);
169 ge_cairo_set_color (cr, &highlight);
173 cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
175 if (corners & CR_CORNER_BOTTOMLEFT)
176 cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.75, G_PI);
178 cairo_line_to (cr, x, y + h);
180 if (corners & CR_CORNER_TOPLEFT)
181 cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 1.5);
183 cairo_line_to (cr, x, y);
185 if (corners & CR_CORNER_TOPRIGHT)
186 cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.5, G_PI * 1.75);
188 cairo_line_to (cr, x + w, y);
190 ge_cairo_set_color (cr, &shadow);
194 /* This function currently assumes that the input is translated by 0.5px! */
196 clearlooks_glossy_draw_highlight_and_shade (cairo_t *cr,
197 const CairoColor *bg_color,
198 const ShadowParameters *params,
199 int width, int height, gdouble radius)
202 CairoColor highlight;
203 uint8 corners = params->corners;
207 /* not really sure of shading ratios... we will think */
208 ge_shade_color (bg_color, 0.8, &shadow);
209 ge_shade_color (bg_color, 1.2, &highlight);
213 /* Top/Left highlight */
214 if (corners & CR_CORNER_BOTTOMLEFT)
215 cairo_move_to (cr, x, y+height-radius);
217 cairo_move_to (cr, x, y+height);
219 ge_cairo_rounded_corner (cr, x, y, radius, corners & CR_CORNER_TOPLEFT);
221 if (corners & CR_CORNER_TOPRIGHT)
222 cairo_line_to (cr, x+width-radius, y);
224 cairo_line_to (cr, x+width, y);
226 if (params->shadow & CL_SHADOW_OUT)
227 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
229 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
233 /* Bottom/Right highlight -- this includes the corners */
234 cairo_move_to (cr, x+width-radius, y); /* topright and by radius to the left */
235 ge_cairo_rounded_corner (cr, x+width, y, radius, corners & CR_CORNER_TOPRIGHT);
236 ge_cairo_rounded_corner (cr, x+width, y+height, radius, corners & CR_CORNER_BOTTOMRIGHT);
237 ge_cairo_rounded_corner (cr, x, y+height, radius, corners & CR_CORNER_BOTTOMLEFT);
239 if (params->shadow & CL_SHADOW_OUT)
240 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
242 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
250 clearlooks_glossy_draw_button (cairo_t *cr,
251 const ClearlooksColors *colors,
252 const WidgetParameters *params,
253 int x, int y, int width, int height)
255 double xoffset = 0, yoffset = 0;
256 CairoColor fill = colors->bg[params->state_type];
257 CairoColor border_normal = colors->shade[6];
258 CairoColor border_disabled = colors->shade[4];
261 cairo_pattern_t *pattern;
264 cairo_translate (cr, x, y);
265 cairo_set_line_width (cr, 1.0);
267 /* Shadows and shadow */
268 if (params->xthickness == 3 || params->ythickness == 3)
270 if (params->xthickness == 3)
272 if (params->ythickness == 3)
276 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0, (height - 2.0 - 2*yoffset) / 2.0));
278 if (params->xthickness == 3 || params->ythickness == 3)
280 /* if (params->enable_shadow && !params->active && !params->disabled) */
281 if (!params->active && (params->prelight || params->enable_shadow))
283 /* shadow becomes a shadow to have 3d prelight buttons :) */
286 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
288 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius+1, params->corners);
289 ge_shade_color (¶ms->parentbg, 0.96, &shadow);
290 ge_cairo_set_color (cr, &shadow);
293 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-2, height-2, radius+1, params->corners);
294 ge_shade_color (¶ms->parentbg, 0.92, &shadow);
295 ge_cairo_set_color (cr, &shadow);
300 if (!(params->disabled))
301 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, params->radius+1, params->corners);
303 /*Draw a lighter inset */
304 clearlooks_glossy_draw_light_inset (cr, ¶ms->parentbg, 0, 0, width, height, params->radius+1, params->corners);
308 clearlooks_draw_glossy_gradient (cr, xoffset+1, yoffset+1,
309 width-(xoffset*2)-2, height-(yoffset*2)-2,
310 &fill, params->disabled, radius, params->corners);
312 /* Pressed button shadow */
316 ge_shade_color (&fill, 0.92, &shadow);
320 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));
322 cairo_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, 3);
324 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+1, yoffset+4);
325 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
326 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
327 cairo_set_source (cr, pattern);
329 cairo_pattern_destroy (pattern);
331 cairo_rectangle (cr, xoffset+1, yoffset+1, 3, height-(yoffset*2)-2);
333 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+4, yoffset+1);
334 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
335 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
336 cairo_set_source (cr, pattern);
338 cairo_pattern_destroy (pattern);
343 /* Default button highlight */
344 if (params->is_default && !params->active && !params->disabled)
346 const CairoColor *shadow = &colors->spot[0];
347 double hh = (height-5)/2.0 + 1;
349 cairo_rectangle (cr, 3.5, 3.5, width-7, height-7);
350 ge_cairo_set_color (cr, shadow);
353 shadow = &colors->spot[0];
354 cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, -hh);
355 cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, hh);
356 ge_cairo_set_color (cr, shadow);
361 shadow = &colors->spot[1];
362 cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, hh);
363 cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, -hh);
364 ge_cairo_set_color (cr, shadow);
369 if (params->is_default || (params->prelight && params->enable_shadow))
370 border_normal = colors->spot[2];
371 /* ge_mix_color (&border_normal, &colors->spot[2], 0.5, &border_normal); */
372 if (params->disabled)
373 ge_cairo_set_color (cr, &border_disabled);
375 clearlooks_set_mixed_color (cr, &border_normal, &fill, 0.2);
376 ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
377 width-(xoffset*2)-1, height-(yoffset*2)-1,
378 radius, params->corners);
384 clearlooks_glossy_draw_progressbar_trough (cairo_t *cr,
385 const ClearlooksColors *colors,
386 const WidgetParameters *params,
387 int x, int y, int width, int height)
389 const CairoColor *border = &colors->shade[6];
391 cairo_pattern_t *pattern;
392 double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
396 cairo_set_line_width (cr, 1.0);
398 /* Create trough box */
399 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
400 ge_cairo_set_color (cr, &colors->shade[2]);
404 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
405 clearlooks_set_mixed_color (cr, border, &colors->shade[2], 0.3);
408 /* clip the corners of the shadows */
409 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
412 ge_shade_color (border, 0.92, &shadow);
415 cairo_rectangle (cr, x+1, y+1, width-2, 4);
416 pattern = cairo_pattern_create_linear (x, y, x, y+4);
417 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
418 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
419 cairo_set_source (cr, pattern);
421 cairo_pattern_destroy (pattern);
424 cairo_rectangle (cr, x+1, y+1, 4, height-2);
425 pattern = cairo_pattern_create_linear (x, y, x+4, y);
426 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
427 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
428 cairo_set_source (cr, pattern);
430 cairo_pattern_destroy (pattern);
436 clearlooks_glossy_draw_progressbar_fill (cairo_t *cr,
437 const ClearlooksColors *colors,
438 const WidgetParameters *params,
439 const ProgressBarParameters *progressbar,
440 int x, int y, int width, int height,
443 boolean is_horizontal = progressbar->orientation < 2;
449 cairo_pattern_t *pattern;
456 radius = MAX (0, params->radius - params->xthickness);
461 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
463 if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
464 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
466 /* Clamp the radius so that the _height_ fits ... */
467 radius = MIN (radius, height / 2.0);
469 stroke_width = height*2;
470 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
472 cairo_translate (cr, x, y);
475 /* This is kind of nasty ... Clip twice from each side in case the length
476 * of the fill is smaller than twice the radius. */
477 ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
479 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
482 /* Draw the background gradient */
483 ge_shade_color (&colors->spot[1], 1.16, &a);
484 ge_shade_color (&colors->spot[1], 1.08, &b);
485 ge_shade_color (&colors->spot[1], 1.08, &e);
486 pattern = cairo_pattern_create_linear (0, 0, 0, height);
487 cairo_pattern_add_color_stop_rgb (pattern, 0.0, a.r, a.g, a.b);
488 cairo_pattern_add_color_stop_rgb (pattern, 0.5, b.r, b.g, b.b);
489 cairo_pattern_add_color_stop_rgb (pattern, 0.5, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);
490 cairo_pattern_add_color_stop_rgb (pattern, 1.0, e.r, e.g, e.b);
491 cairo_set_source (cr, pattern);
493 cairo_pattern_destroy (pattern);
495 /* Draw the Strokes */
496 while (tile_pos <= width+x_step)
498 cairo_move_to (cr, stroke_width/2-x_step, 0);
499 cairo_line_to (cr, stroke_width-x_step, 0);
500 cairo_line_to (cr, stroke_width/2-x_step, height);
501 cairo_line_to (cr, -x_step, height);
503 cairo_translate (cr, stroke_width, 0);
504 tile_pos += stroke_width;
507 cairo_set_source_rgba (cr, colors->spot[2].r,
513 cairo_restore (cr); /* rounded clip region */
515 /* inner highlight border
516 * This is again kinda ugly. Draw once from each side, clipping away the other. */
517 cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.3);
521 cairo_rectangle (cr, 0, 0, width / 2, height);
524 if (progressbar->pulsing)
525 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
527 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
530 cairo_restore (cr); /* clip */
534 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
537 if (progressbar->value < 1.0 || progressbar->pulsing)
538 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
540 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
543 cairo_restore (cr); /* clip */
546 /* Draw the dark lines and the shadow */
548 /* Again, this weird clip area. */
549 ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
551 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
554 border = colors->spot[2];
556 ge_shade_color (&colors->shade[6], 0.92, &shadow);
559 if (progressbar->pulsing)
561 /* At the beginning of the bar. */
562 cairo_move_to (cr, 0.5 + radius, height + 0.5);
563 ge_cairo_rounded_corner (cr, 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
564 ge_cairo_rounded_corner (cr, 0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
565 ge_cairo_set_color (cr, &border);
568 cairo_move_to (cr, -0.5 + radius, height + 0.5);
569 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
570 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
571 ge_cairo_set_color (cr, &shadow);
574 if (progressbar->value < 1.0 || progressbar->pulsing)
576 /* At the end of the bar. */
577 cairo_move_to (cr, width - 0.5 - radius, -0.5);
578 ge_cairo_rounded_corner (cr, width - 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
579 ge_cairo_rounded_corner (cr, width - 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
580 ge_cairo_set_color (cr, &border);
583 cairo_move_to (cr, width + 0.5 - radius, -0.5);
584 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
585 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
586 ge_cairo_set_color (cr, &shadow);
592 cairo_restore (cr); /* rotation, mirroring */
596 clearlooks_glossy_scale_draw_gradient (cairo_t *cr,
597 const CairoColor *c1,
598 const CairoColor *c2,
599 const CairoColor *c3,
600 int x, int y, int width, int height,
603 cairo_pattern_t *pattern;
605 pattern = cairo_pattern_create_linear (0.5, 0.5, horizontal ? 0.5 : width + 1, horizontal ? height + 1 : 0.5);
606 cairo_pattern_add_color_stop_rgb (pattern, 0.0, c1->r, c1->g, c1->b);
607 cairo_pattern_add_color_stop_rgb (pattern, 1.0, c2->r, c2->g, c2->b);
609 cairo_rectangle (cr, x, y, width, height);
610 cairo_set_source (cr, pattern);
612 cairo_pattern_destroy (pattern);
614 clearlooks_set_mixed_color (cr, c3, c1, 0.3);
615 ge_cairo_inner_rectangle (cr, x, y, width, height);
619 #define TROUGH_SIZE 7
621 clearlooks_glossy_draw_scale_trough (cairo_t *cr,
622 const ClearlooksColors *colors,
623 const WidgetParameters *params,
624 const SliderParameters *slider,
625 int x, int y, int width, int height)
627 int trough_width, trough_height;
628 double translate_x, translate_y;
632 if (slider->horizontal)
634 trough_width = width;
635 trough_height = TROUGH_SIZE;
638 translate_y = y + (height/2) - (TROUGH_SIZE/2);
642 trough_width = TROUGH_SIZE;
643 trough_height = height;
645 translate_x = x + (width/2) - (TROUGH_SIZE/2);
649 cairo_set_line_width (cr, 1.0);
650 cairo_translate (cr, translate_x, translate_y);
652 if (!slider->fill_level)
653 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, trough_width, trough_height, 0, 0);
655 if (!slider->lower && !slider->fill_level)
656 clearlooks_glossy_scale_draw_gradient (cr, &colors->shade[3], /* top */
657 &colors->shade[2], /* bottom */
658 &colors->shade[6], /* border */
659 1.0, 1.0, trough_width - 2, trough_height - 2,
662 clearlooks_glossy_scale_draw_gradient (cr, &colors->spot[1], /* top */
663 &colors->spot[0], /* bottom */
664 &colors->spot[2], /* border */
665 1.0, 1.0, trough_width - 2, trough_height - 2,
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;
690 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
693 cairo_rectangle (cr, x, y, width, height);
697 /* Translate and set line width */
698 cairo_set_line_width (cr, 1.0);
699 cairo_translate (cr, x+0.5, y+0.5);
702 /* Make the tabs slightly bigger than they should be, to create a gap */
703 /* And calculate the strip size too, while you're at it */
704 if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
708 strip_size = 2.0/height; /* 2 pixel high strip */
710 if (tab->gap_side == CL_GAP_TOP)
711 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
717 strip_size = 2.0/width;
719 if (tab->gap_side == CL_GAP_LEFT)
720 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
723 /* Set the fill color */
724 fill = &colors->bg[params->state_type];
727 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
728 radius, params->corners);
731 ge_cairo_set_color (cr, fill);
734 ge_shade_color (fill, 1.3, &hilight);
739 ShadowParameters shadow;
741 shadow.shadow = CL_SHADOW_OUT;
742 shadow.corners = params->corners;
744 /* This is the only usage of clearlooks_glossy_draw_highlight_and_shade,
745 * the function assumes currently that the input is translated by 0.5 px. */
746 clearlooks_glossy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow,
753 CairoColor shadow, hilight, f1, f2;
755 switch (tab->gap_side)
758 pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
761 pattern = cairo_pattern_create_linear (0, 1, 0, height);
764 pattern = cairo_pattern_create_linear (width-2, 0, 1, 0);
767 pattern = cairo_pattern_create_linear (1, 0, width-2, 0);
773 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
775 ge_shade_color (fill, 1.06, &shadow);
776 ge_shade_color (fill, 1.18, &hilight);
777 ge_shade_color (fill, 1.12, &f1);
778 ge_shade_color (fill, 1.06, &f2);
780 cairo_pattern_add_color_stop_rgb (pattern, 0.0, hilight.r, hilight.g, hilight.b);
781 cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, hilight.r, hilight.g, hilight.b);
782 cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, f1.r, f1.g, f1.b);
783 cairo_pattern_add_color_stop_rgb (pattern, 0.45, f2.r, f2.g, f2.b);
784 cairo_pattern_add_color_stop_rgb (pattern, 0.45, fill->r, fill->g, fill->b);
785 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r, shadow.g, shadow.b);
786 cairo_set_source (cr, pattern);
788 cairo_pattern_destroy (pattern);
793 switch (tab->gap_side)
796 pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
799 pattern = cairo_pattern_create_linear (0, 0, 0, height);
802 pattern = cairo_pattern_create_linear (width-2, 0, 0, 0);
805 pattern = cairo_pattern_create_linear (0, 0, width, 0);
811 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
814 cairo_pattern_add_color_stop_rgba (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.5);
815 cairo_pattern_add_color_stop_rgba (pattern, 0.8, fill->r, fill->g, fill->b, 0.0);
816 cairo_set_source (cr, pattern);
818 cairo_pattern_destroy (pattern);
821 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
825 ge_cairo_set_color (cr, border);
830 switch (tab->gap_side)
833 pattern = cairo_pattern_create_linear (2, height-2, 2, 2);
836 pattern = cairo_pattern_create_linear (2, 2, 2, height);
839 pattern = cairo_pattern_create_linear (width-2, 2, 2, 2);
842 pattern = cairo_pattern_create_linear (2, 2, width, 2);
848 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
849 cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r, border->g, border->b);
850 cairo_set_source (cr, pattern);
852 cairo_pattern_destroy (pattern);
857 clearlooks_glossy_draw_slider (cairo_t *cr,
858 const ClearlooksColors *colors,
859 const WidgetParameters *params,
860 int x, int y, int width, int height)
862 const CairoColor *border = &colors->shade[7];
865 CairoColor a, b, c, d;
866 cairo_pattern_t *pattern;
868 cairo_set_line_width (cr, 1.0);
869 cairo_translate (cr, x, y);
871 ge_shade_color (&colors->bg[params->state_type], 1.0, &fill);
872 if (params->prelight)
873 ge_shade_color (&fill, 1.1, &fill);
875 ge_shade_color (&fill, 1.25, &hilight);
876 ge_shade_color (&fill, 1.16, &a);
877 ge_shade_color (&fill, 1.08, &b);
878 ge_shade_color (&fill, 1.0, &c);
879 ge_shade_color (&fill, 1.08, &d);
881 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
882 cairo_pattern_add_color_stop_rgb (pattern, 0, a.r, a.g, a.b);
883 cairo_pattern_add_color_stop_rgb (pattern, 0.5, b.r, b.g, b.b);
884 cairo_pattern_add_color_stop_rgb (pattern, 0.5, c.r, c.g, c.b);
885 cairo_pattern_add_color_stop_rgb (pattern, 1.0, d.r, d.g, d.b);
886 cairo_rectangle (cr, 1, 1, width-2, height-2);
887 cairo_set_source (cr, pattern);
889 cairo_pattern_destroy (pattern);
891 clearlooks_set_mixed_color (cr, border, &fill, 0.2);
892 if (params->prelight)
893 ge_cairo_set_color (cr, &colors->spot[2]);
894 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, 2.5, params->corners);
897 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
898 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, 2.0, params->corners);
903 clearlooks_glossy_draw_slider_button (cairo_t *cr,
904 const ClearlooksColors *colors,
905 const WidgetParameters *params,
906 const SliderParameters *slider,
907 int x, int y, int width, int height)
909 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
911 cairo_set_line_width (cr, 1.0);
913 if (!slider->horizontal)
914 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
916 cairo_translate (cr, x, y);
917 params->style_functions->draw_shadow (cr, colors, radius, width, height);
918 params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
922 clearlooks_glossy_draw_scrollbar_stepper (cairo_t *cr,
923 const ClearlooksColors *colors,
924 const WidgetParameters *widget,
925 const ScrollBarParameters *scrollbar,
926 const ScrollBarStepperParameters *stepper,
927 int x, int y, int width, int height)
929 CairoCorners corners = CR_CORNER_NONE;
930 const CairoColor *border = &colors->shade[7];
931 CairoColor fill, s1, s2, s4;
932 cairo_pattern_t *pattern;
933 ShadowParameters shadow;
934 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
936 if (scrollbar->horizontal)
938 if (stepper->stepper == CL_STEPPER_A)
939 corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
940 else if (stepper->stepper == CL_STEPPER_D)
941 corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
945 if (stepper->stepper == CL_STEPPER_A)
946 corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
947 else if (stepper->stepper == CL_STEPPER_D)
948 corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
951 cairo_translate (cr, x, y);
952 cairo_set_line_width (cr, 1);
954 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
956 if (scrollbar->horizontal)
957 pattern = cairo_pattern_create_linear (0, 0, 0, height);
959 pattern = cairo_pattern_create_linear (0, 0, width, 0);
961 fill = colors->bg[widget->state_type];
962 ge_shade_color(&fill, 1.16, &s1);
963 ge_shade_color(&fill, 1.08, &s2);
964 ge_shade_color(&fill, 1.08, &s4);
966 cairo_pattern_add_color_stop_rgb(pattern, 0, s1.r, s1.g, s1.b);
967 cairo_pattern_add_color_stop_rgb(pattern, 0.5, s2.r, s2.g, s2.b);
968 cairo_pattern_add_color_stop_rgb(pattern, 0.5, fill.r, fill.g, fill.b);
969 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
970 cairo_set_source (cr, pattern);
972 cairo_pattern_destroy (pattern);
974 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
975 clearlooks_set_mixed_color (cr, border, &fill, 0.2);
976 if (widget->prelight)
977 ge_cairo_set_color (cr, &colors->spot[2]);
980 shadow.shadow = CL_SHADOW_OUT;
981 shadow.corners = corners;
985 clearlooks_glossy_draw_scrollbar_slider (cairo_t *cr,
986 const ClearlooksColors *colors,
987 const WidgetParameters *widget,
988 const ScrollBarParameters *scrollbar,
989 int x, int y, int width, int height)
991 const CairoColor *border = &colors->shade[7];
992 CairoColor fill = scrollbar->color;
994 CairoColor shade1, shade2, shade3;
995 cairo_pattern_t *pattern;
997 if (scrollbar->junction & CL_JUNCTION_BEGIN)
999 if (scrollbar->horizontal)
1010 if (scrollbar->junction & CL_JUNCTION_END)
1012 if (scrollbar->horizontal)
1018 if (!scrollbar->horizontal)
1019 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1021 cairo_translate (cr, x, y);
1023 if (widget->prelight)
1024 ge_shade_color (&fill, 1.1, &fill);
1026 cairo_set_line_width (cr, 1);
1028 ge_shade_color (&fill, 1.25, &hilight);
1029 ge_shade_color (&fill, 1.16, &shade1);
1030 ge_shade_color (&fill, 1.08, &shade2);
1031 ge_shade_color (&fill, 1.08, &shade3);
1033 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1034 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1035 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1036 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b);
1037 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1038 cairo_rectangle (cr, 1, 1, width-2, height-2);
1039 cairo_set_source (cr, pattern);
1041 cairo_pattern_destroy (pattern);
1043 if (scrollbar->has_color)
1045 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1046 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1049 clearlooks_set_mixed_color (cr, border, &fill, scrollbar->has_color? 0.4 : 0.2);
1050 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1054 clearlooks_glossy_draw_list_view_header (cairo_t *cr,
1055 const ClearlooksColors *colors,
1056 const WidgetParameters *params,
1057 const ListViewHeaderParameters *header,
1058 int x, int y, int width, int height)
1061 CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
1063 const CairoColor *border = &colors->shade[4];
1064 const CairoColor *fill = &colors->bg[params->state_type];
1066 CairoColor shade1, shade2, shade3;
1068 cairo_pattern_t *pattern;
1070 ge_shade_color (fill, 1.2, &hilight);
1071 ge_shade_color (fill, 1.08, &shade1);
1072 ge_shade_color (fill, 1.04, &shade2);
1073 ge_shade_color (fill, 1.04, &shade3);
1075 cairo_translate (cr, x, y);
1076 cairo_set_line_width (cr, 1.0);
1079 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1080 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1081 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1082 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1083 cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, shade3.r, shade3.g, shade3.b);
1084 cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, border->r, border->g, border->b);
1085 cairo_pattern_add_color_stop_rgb (pattern, 1.0, border->r, border->g, border->b);
1087 cairo_set_source (cr, pattern);
1088 cairo_rectangle (cr, 0, 0, width, height);
1091 cairo_pattern_destroy (pattern);
1093 /* Draw highlight */
1094 if (header->order & CL_ORDER_FIRST)
1096 cairo_move_to (cr, 0.5, height-1);
1097 cairo_line_to (cr, 0.5, 0.5);
1100 cairo_move_to (cr, 0.0, 0.5);
1102 cairo_line_to (cr, width, 0.5);
1104 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1107 /* Draw resize grip */
1108 if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
1109 (!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
1111 SeparatorParameters separator;
1112 separator.horizontal = FALSE;
1115 params->style_functions->draw_separator (cr, colors, params, &separator,
1116 width-1.5, 4.0, 2, height-8.0);
1118 params->style_functions->draw_separator (cr, colors, params, &separator,
1119 1.5, 4.0, 2, height-8.0);
1124 clearlooks_glossy_draw_toolbar (cairo_t *cr,
1125 const ClearlooksColors *colors,
1126 const WidgetParameters *widget,
1127 const ToolbarParameters *toolbar,
1128 int x, int y, int width, int height)
1130 const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL];
1131 const CairoColor *dark = &colors->shade[3];
1133 ge_shade_color (fill, 1.1, &light);
1135 cairo_set_line_width (cr, 1.0);
1136 cairo_translate (cr, x, y);
1138 if (toolbar->style == 1) /* Enable Extra features */
1140 cairo_pattern_t *pattern;
1141 CairoColor shade1, shade2, shade3;
1143 ge_shade_color (fill, 1.08, &shade1);
1144 ge_shade_color (fill, 1.04, &shade2);
1145 ge_shade_color (fill, 1.04, &shade3);
1148 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1149 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1150 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1151 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1152 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
1154 cairo_set_source (cr, pattern);
1155 cairo_rectangle (cr, 0, 0, width, height);
1158 cairo_pattern_destroy (pattern);
1162 ge_cairo_set_color (cr, fill);
1165 if (!toolbar->topmost)
1167 /* Draw highlight */
1168 cairo_move_to (cr, 0, 0.5);
1169 cairo_line_to (cr, width-1, 0.5);
1170 ge_cairo_set_color (cr, &light);
1176 cairo_move_to (cr, 0, height-0.5);
1177 cairo_line_to (cr, width-1, height-0.5);
1178 ge_cairo_set_color (cr, dark);
1183 clearlooks_glossy_draw_menuitem (cairo_t *cr,
1184 const ClearlooksColors *colors,
1185 const WidgetParameters *params,
1186 int x, int y, int width, int height)
1188 const CairoColor *fill = &colors->spot[1];
1189 const CairoColor *border = &colors->spot[2];
1190 CairoColor shade1, shade2, shade3;
1191 cairo_pattern_t *pattern;
1193 ge_shade_color (fill, 1.16, &shade1);
1194 ge_shade_color (fill, 1.08, &shade2);
1195 ge_shade_color (fill, 1.08, &shade3);
1196 cairo_set_line_width (cr, 1.0);
1198 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1200 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1201 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1202 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1203 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1204 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1206 cairo_set_source (cr, pattern);
1207 cairo_fill_preserve (cr);
1208 cairo_pattern_destroy (pattern);
1210 ge_cairo_set_color (cr, border);
1215 clearlooks_glossy_draw_menubaritem (cairo_t *cr,
1216 const ClearlooksColors *colors,
1217 const WidgetParameters *params,
1218 int x, int y, int width, int height)
1220 const CairoColor *fill = &colors->spot[1];
1221 const CairoColor *border = &colors->spot[2];
1222 CairoColor shade1, shade2, shade3;
1223 cairo_pattern_t *pattern;
1225 ge_shade_color (fill, 1.16, &shade1);
1226 ge_shade_color (fill, 1.08, &shade2);
1227 ge_shade_color (fill, 1.08, &shade3);
1228 cairo_set_line_width (cr, 1.0);
1230 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1232 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1233 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1234 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1235 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1236 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1238 cairo_set_source (cr, pattern);
1239 cairo_fill_preserve (cr);
1240 cairo_pattern_destroy (pattern);
1242 ge_cairo_set_color (cr, border);
1247 clearlooks_glossy_draw_selected_cell (cairo_t *cr,
1248 const ClearlooksColors *colors,
1249 const WidgetParameters *params,
1250 int x, int y, int width, int height)
1255 color = colors->base[params->state_type];
1257 color = colors->base[GTK_STATE_ACTIVE];
1259 clearlooks_draw_glossy_gradient (cr, x, y, width, height, &color, params->disabled, 0.0, CR_CORNER_NONE);
1264 clearlooks_glossy_draw_radiobutton (cairo_t *cr,
1265 const ClearlooksColors *colors,
1266 const WidgetParameters *widget,
1267 const CheckboxParameters *checkbox,
1268 int x, int y, int width, int height)
1270 const CairoColor *border;
1271 const CairoColor *dot;
1273 CairoColor highlight;
1274 cairo_pattern_t *pt;
1275 gboolean inconsistent;
1276 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1277 gdouble w, h, cx, cy, radius;
1279 w = (gdouble) width;
1280 h = (gdouble) height;
1283 radius = MIN (width, height) / 2.0;
1285 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1286 draw_bullet |= inconsistent;
1288 if (widget->disabled)
1290 border = &colors->shade[5];
1291 dot = &colors->shade[6];
1295 if (widget->prelight)
1296 border = &colors->spot[2];
1298 border = &colors->shade[6];
1299 dot = &colors->text[0];
1302 ge_shade_color (&widget->parentbg, 0.9, &shadow);
1303 ge_shade_color (&widget->parentbg, 1.1, &highlight);
1305 pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
1306 cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
1307 cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
1308 cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
1309 cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
1311 cairo_translate (cr, x, y);
1313 cairo_set_line_width (cr, MAX (1.0, floor (radius/3)));
1314 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2);
1315 cairo_set_source (cr, pt);
1317 cairo_pattern_destroy (pt);
1319 cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
1321 cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
1323 if (!widget->disabled)
1325 if (widget->prelight)
1326 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1328 ge_cairo_set_color (cr, &colors->base[0]);
1329 cairo_fill_preserve (cr);
1332 ge_cairo_set_color (cr, border);
1339 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1340 cairo_set_line_width (cr, ceil (radius * 2 / 3));
1342 cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy));
1343 cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy));
1345 ge_cairo_set_color (cr, dot);
1350 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
1351 ge_cairo_set_color (cr, dot);
1354 cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
1355 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
1362 clearlooks_glossy_draw_checkbox (cairo_t *cr,
1363 const ClearlooksColors *colors,
1364 const WidgetParameters *widget,
1365 const CheckboxParameters *checkbox,
1366 int x, int y, int width, int height)
1368 const CairoColor *border;
1369 const CairoColor *dot;
1370 gboolean inconsistent = FALSE;
1371 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1373 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1374 draw_bullet |= inconsistent;
1376 if (widget->disabled)
1378 border = &colors->shade[5];
1379 dot = &colors->shade[6];
1383 if (widget->prelight)
1384 border = &colors->spot[2];
1386 border = &colors->shade[6];
1387 dot = &colors->text[GTK_STATE_NORMAL];
1390 cairo_translate (cr, x, y);
1391 cairo_set_line_width (cr, 1);
1393 if (widget->xthickness > 2 && widget->ythickness > 2)
1395 widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0,
1396 width, height, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1398 /* Draw the rectangle for the checkbox itself */
1399 ge_cairo_rounded_rectangle (cr, 1.5, 1.5,
1400 width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1404 /* Draw the rectangle for the checkbox itself */
1405 ge_cairo_rounded_rectangle (cr, 0.5, 0.5,
1406 width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1409 if (!widget->disabled)
1411 if (widget->prelight)
1412 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1414 ge_cairo_set_color (cr, &colors->base[0]);
1415 cairo_fill_preserve (cr);
1418 ge_cairo_set_color (cr, border);
1423 if (inconsistent) /* Inconsistent */
1425 cairo_set_line_width (cr, 2.0);
1426 cairo_move_to (cr, 3, height*0.5);
1427 cairo_line_to (cr, width-3, height*0.5);
1431 cairo_set_line_width (cr, 1.7);
1432 cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
1433 cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
1435 cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
1436 0.5 + (width*0.5), (height*0.4),
1437 0.5 + (width*0.70), (height*0.25));
1441 ge_cairo_set_color (cr, dot);
1447 clearlooks_register_style_glossy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
1449 functions->draw_inset = clearlooks_glossy_draw_inset;
1450 functions->draw_button = clearlooks_glossy_draw_button;
1451 functions->draw_progressbar_trough = clearlooks_glossy_draw_progressbar_trough;
1452 functions->draw_progressbar_fill = clearlooks_glossy_draw_progressbar_fill;
1453 functions->draw_scale_trough = clearlooks_glossy_draw_scale_trough;
1454 functions->draw_tab = clearlooks_glossy_draw_tab;
1455 functions->draw_slider = clearlooks_glossy_draw_slider;
1456 functions->draw_slider_button = clearlooks_glossy_draw_slider_button;
1457 functions->draw_scrollbar_stepper = clearlooks_glossy_draw_scrollbar_stepper;
1458 functions->draw_scrollbar_slider = clearlooks_glossy_draw_scrollbar_slider;
1459 functions->draw_list_view_header = clearlooks_glossy_draw_list_view_header;
1460 functions->draw_toolbar = clearlooks_glossy_draw_toolbar;
1461 functions->draw_menuitem = clearlooks_glossy_draw_menuitem;
1462 functions->draw_menubaritem = clearlooks_glossy_draw_menubaritem;
1463 functions->draw_selected_cell = clearlooks_glossy_draw_selected_cell;
1464 functions->draw_checkbox = clearlooks_glossy_draw_checkbox;
1465 functions->draw_radiobutton = clearlooks_glossy_draw_radiobutton;