1 /* Clearlooks Gummy style
2 * Copyright (C) 2007 Andrea Cimitan
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.
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.
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.
19 * Written by Andrea Cimitan <andrea.cimitan@gmail.com>
22 #include "clearlooks_draw.h"
23 #include "clearlooks_style.h"
24 #include "clearlooks_types.h"
27 #include <ge-support.h>
32 #define SHADE_TOP 1.08
33 #define SHADE_CENTER_TOP 1.02
34 #define SHADE_BOTTOM 0.94
37 #define LISTVIEW_SHADE_TOP 1.06
38 #define LISTVIEW_SHADE_CENTER_TOP 1.02
39 #define LISTVIEW_SHADE_BOTTOM 0.96
42 #define TOOLBAR_SHADE_TOP 1.04
43 #define TOOLBAR_SHADE_CENTER_TOP 1.01
44 #define TOOLBAR_SHADE_BOTTOM 0.97
47 clearlooks_draw_gummy_gradient (cairo_t *cr,
48 double x, double y, int width, int height,
49 const CairoColor *color,
50 gboolean disabled, gboolean radius, CairoCorners corners)
53 CairoColor shade1, shade2, shade3;
56 ge_shade_color (color, disabled? 1.04 : SHADE_TOP, &shade1);
57 ge_shade_color (color, disabled? 1.01 : SHADE_CENTER_TOP, &shade2);
58 ge_shade_color (color, disabled? 0.99 : 1.0, &fill);
59 ge_shade_color (color, disabled? 0.96 : SHADE_BOTTOM, &shade3);
61 pt = cairo_pattern_create_linear (x, y, x, y+height);
62 cairo_pattern_add_color_stop_rgb (pt, 0.0, shade1.r, shade1.g, shade1.b);
63 cairo_pattern_add_color_stop_rgb (pt, 0.5, shade2.r, shade2.g, shade2.b);
64 cairo_pattern_add_color_stop_rgb (pt, 0.5, fill.r, fill.g, fill.b);
65 cairo_pattern_add_color_stop_rgb (pt, 1.0, shade3.r, shade3.g, shade3.b);
67 cairo_set_source (cr, pt);
68 ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, corners);
71 cairo_pattern_destroy (pt);
75 clearlooks_set_mixed_color (cairo_t *cr,
76 const CairoColor *color1,
77 const CairoColor *color2,
82 ge_mix_color (color1, color2, mix_factor, &composite);
83 ge_cairo_set_color (cr, &composite);
87 clearlooks_gummy_draw_highlight_and_shade (cairo_t *cr,
88 const CairoColor *bg_color,
89 const ShadowParameters *params,
90 int width, int height, gdouble radius)
94 uint8 corners = params->corners;
98 /* not really sure of shading ratios... we will think */
99 ge_shade_color (bg_color, 0.8, &shadow);
100 ge_shade_color (bg_color, 1.2, &highlight);
104 /* Top/Left highlight */
105 if (corners & CR_CORNER_BOTTOMLEFT)
106 cairo_move_to (cr, x, y+height-radius);
108 cairo_move_to (cr, x, y+height);
110 ge_cairo_rounded_corner (cr, x, y, radius, corners & CR_CORNER_TOPLEFT);
112 if (corners & CR_CORNER_TOPRIGHT)
113 cairo_line_to (cr, x+width-radius, y);
115 cairo_line_to (cr, x+width, y);
117 if (params->shadow & CL_SHADOW_OUT)
118 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
120 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
124 /* Bottom/Right highlight -- this includes the corners */
125 cairo_move_to (cr, x+width-radius, y); /* topright and by radius to the left */
126 ge_cairo_rounded_corner (cr, x+width, y, radius, corners & CR_CORNER_TOPRIGHT);
127 ge_cairo_rounded_corner (cr, x+width, y+height, radius, corners & CR_CORNER_BOTTOMRIGHT);
128 ge_cairo_rounded_corner (cr, x, y+height, radius, corners & CR_CORNER_BOTTOMLEFT);
130 if (params->shadow & CL_SHADOW_OUT)
131 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.5);
133 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
141 clearlooks_gummy_draw_button (cairo_t *cr,
142 const ClearlooksColors *colors,
143 const WidgetParameters *params,
144 int x, int y, int width, int height)
146 double xoffset = 0, yoffset = 0;
147 CairoColor fill = colors->bg[params->state_type];
148 CairoColor border_normal = colors->shade[6];
149 CairoColor border_disabled = colors->shade[4];
152 cairo_pattern_t *pattern;
155 cairo_translate (cr, x, y);
156 cairo_set_line_width (cr, 1.0);
158 if (params->xthickness == 3)
160 if (params->ythickness == 3)
163 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0, (height - 2.0 - 2*yoffset) / 2.0));
165 if (params->xthickness == 3 || params->ythickness == 3)
167 if (params->enable_shadow && !params->active && !params->disabled && !params->is_default)
171 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
173 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius+1, params->corners);
174 ge_shade_color (¶ms->parentbg, 0.97, &shadow);
175 ge_cairo_set_color (cr, &shadow);
178 ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius+1, params->corners);
179 ge_shade_color (¶ms->parentbg, 0.93, &shadow);
180 ge_cairo_set_color (cr, &shadow);
184 if (params->is_default)
186 CairoColor shadow = colors->spot[1];
188 radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0));
190 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius+1, params->corners);
191 clearlooks_set_mixed_color (cr, ¶ms->parentbg, &shadow, 0.5);
195 if (!(params->enable_shadow && !params->active && !params->disabled))
196 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, params->radius+1, params->corners);
199 clearlooks_draw_gummy_gradient (cr, xoffset+1, yoffset+1,
200 width-(xoffset*2)-2, height-(yoffset*2)-2,
201 &fill, params->disabled, radius, params->corners);
203 /* Pressed button shadow */
207 ge_shade_color (&fill, 0.92, &shadow);
211 ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, height, radius,
212 params->corners & (CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMLEFT));
214 cairo_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, 3);
216 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+1, yoffset+4);
217 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
218 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
219 cairo_set_source (cr, pattern);
221 cairo_pattern_destroy (pattern);
223 cairo_rectangle (cr, xoffset+1, yoffset+1, 3, height-(yoffset*2)-2);
225 pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+4, yoffset+1);
226 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58);
227 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
228 cairo_set_source (cr, pattern);
230 cairo_pattern_destroy (pattern);
236 if (params->is_default) /* || (params->prelight && params->enable_shadow)) */
237 border_normal = colors->spot[2];
238 if (params->disabled)
239 ge_cairo_set_color (cr, &border_disabled);
241 clearlooks_set_mixed_color (cr, &border_normal, &fill, 0.2);
242 ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
243 width-(xoffset*2)-1, height-(yoffset*2)-1,
244 radius, params->corners);
249 params->style_functions->draw_top_left_highlight (cr, &fill, params, 1+xoffset, 1+xoffset,
250 width-(1+xoffset)*2, height-(1+xoffset)*2,
251 radius, params->corners);
257 clearlooks_gummy_draw_entry (cairo_t *cr,
258 const ClearlooksColors *colors,
259 const WidgetParameters *params,
260 int x, int y, int width, int height)
262 const CairoColor *base = &colors->base[params->state_type];
263 CairoColor border = colors->shade[params->disabled ? 4 : 6];
264 double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
267 border = colors->spot[2];
271 cairo_translate (cr, x, y);
272 cairo_set_line_width (cr, 1.0);
274 /* Now fill the area we want to be base[NORMAL]. */
275 ge_cairo_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
276 ge_cairo_set_color (cr, base);
279 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, radius+1, params->corners);
281 /* Draw the inner shadow */
284 clearlooks_set_mixed_color (cr, base, &colors->spot[1], 0.5);
285 ge_cairo_inner_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
291 ge_shade_color (&border, 0.92, &shadow);
293 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.09 : 0.18);
295 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
296 cairo_move_to (cr, 2.5, height-radius);
297 cairo_arc (cr, 2.5+MAX(0, radius-1), 2.5+MAX(0, radius-1), MAX(0, radius-1), G_PI, 270*(G_PI/180));
298 cairo_line_to (cr, width-radius, 2.5);
302 ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, params->corners);
303 ge_cairo_set_color (cr, &border);
310 clearlooks_gummy_draw_progressbar_trough (cairo_t *cr,
311 const ClearlooksColors *colors,
312 const WidgetParameters *params,
313 int x, int y, int width, int height)
315 const CairoColor *border = &colors->shade[7];
317 cairo_pattern_t *pattern;
318 double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
322 cairo_set_line_width (cr, 1.0);
324 /* Create trough box */
325 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
326 ge_cairo_set_color (cr, &colors->shade[2]);
330 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
331 clearlooks_set_mixed_color (cr, border, &colors->shade[2], 0.3);
334 /* clip the corners of the shadows */
335 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
338 ge_shade_color (border, 0.92, &shadow);
341 cairo_rectangle (cr, x+1, y+1, width-2, 4);
342 pattern = cairo_pattern_create_linear (x, y, x, y+4);
343 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
344 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
345 cairo_set_source (cr, pattern);
347 cairo_pattern_destroy (pattern);
350 cairo_rectangle (cr, x+1, y+1, 4, height-2);
351 pattern = cairo_pattern_create_linear (x, y, x+4, y);
352 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3);
353 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.);
354 cairo_set_source (cr, pattern);
356 cairo_pattern_destroy (pattern);
362 clearlooks_gummy_draw_progressbar_fill (cairo_t *cr,
363 const ClearlooksColors *colors,
364 const WidgetParameters *params,
365 const ProgressBarParameters *progressbar,
366 int x, int y, int width, int height, gint offset)
368 boolean is_horizontal = progressbar->orientation < 2;
374 cairo_pattern_t *pattern;
375 CairoColor shade1, shade2, shade3;
379 radius = MAX (0, params->radius - params->xthickness);
384 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
386 if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
387 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
389 /* Clamp the radius so that the _height_ fits ... */
390 radius = MIN (radius, height / 2.0);
392 stroke_width = height*2;
393 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
395 cairo_translate (cr, x, y);
398 /* This is kind of nasty ... Clip twice from each side in case the length
399 * of the fill is smaller than twice the radius. */
400 ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
402 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
405 /* Draw the background gradient */
406 ge_shade_color (&colors->spot[1], SHADE_TOP, &shade1);
407 ge_shade_color (&colors->spot[1], SHADE_CENTER_TOP, &shade2);
408 ge_shade_color (&colors->spot[1], SHADE_BOTTOM, &shade3);
409 pattern = cairo_pattern_create_linear (0, 0, 0, height);
410 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
411 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
412 cairo_pattern_add_color_stop_rgb (pattern, 0.5, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);
413 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
414 cairo_set_source (cr, pattern);
416 cairo_pattern_destroy (pattern);
418 /* Draw the strokes */
419 while (tile_pos <= width+x_step)
421 cairo_move_to (cr, stroke_width/2-x_step, 0);
422 cairo_line_to (cr, stroke_width-x_step, 0);
423 cairo_line_to (cr, stroke_width/2-x_step, height);
424 cairo_line_to (cr, -x_step, height);
426 cairo_translate (cr, stroke_width, 0);
427 tile_pos += stroke_width;
430 cairo_set_source_rgba (cr, colors->spot[2].r,
436 cairo_restore (cr); /* rounded clip region */
438 /* inner highlight border
439 * This is again kinda ugly. Draw once from each side, clipping away the other. */
440 cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.2);
444 cairo_rectangle (cr, 0, 0, width / 2, height);
447 if (progressbar->pulsing)
448 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
450 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
453 cairo_restore (cr); /* clip */
457 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
460 if (progressbar->value < 1.0 || progressbar->pulsing)
461 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
463 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
466 cairo_restore (cr); /* clip */
469 /* Draw the dark lines and the shadow */
471 /* Again, this weird clip area. */
472 ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
474 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
477 border = colors->spot[2];
479 ge_shade_color (&colors->shade[7], 0.92, &shadow);
482 if (progressbar->pulsing)
484 /* At the beginning of the bar. */
485 cairo_move_to (cr, 0.5 + radius, height + 0.5);
486 ge_cairo_rounded_corner (cr, 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
487 ge_cairo_rounded_corner (cr, 0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
488 ge_cairo_set_color (cr, &border);
491 cairo_move_to (cr, -0.5 + radius, height + 0.5);
492 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
493 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
494 ge_cairo_set_color (cr, &shadow);
497 if (progressbar->value < 1.0 || progressbar->pulsing)
499 /* At the end of the bar. */
500 cairo_move_to (cr, width - 0.5 - radius, -0.5);
501 ge_cairo_rounded_corner (cr, width - 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
502 ge_cairo_rounded_corner (cr, width - 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
503 ge_cairo_set_color (cr, &border);
506 cairo_move_to (cr, width + 0.5 - radius, -0.5);
507 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
508 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
509 ge_cairo_set_color (cr, &shadow);
515 cairo_restore (cr); /* rotation, mirroring */
519 clearlooks_gummy_scale_draw_gradient (cairo_t *cr,
520 const CairoColor *fill,
521 const CairoColor *border,
522 int x, int y, int width, int height,
523 gboolean horizontal, gboolean in)
525 cairo_pattern_t *pattern;
529 ge_shade_color (fill, in? 0.95 : 1.1, &f1);
530 ge_shade_color (fill, in? 1.05 : 0.9, &f2);
532 pattern = cairo_pattern_create_linear (0.5, 0.5, horizontal ? 0.5 : width + 1.0, horizontal ? height + 1.0 : 0.5);
533 cairo_pattern_add_color_stop_rgba (pattern, 0.0, f1.r, f1.g, f1.b, f1.a);
534 cairo_pattern_add_color_stop_rgba (pattern, 1.0, f2.r, f2.g, f2.b, f2.a);
536 cairo_rectangle (cr, x, y, width, height);
537 cairo_set_source (cr, pattern);
539 cairo_pattern_destroy (pattern);
541 clearlooks_set_mixed_color (cr, border, fill, 0.2);
542 ge_cairo_inner_rectangle (cr, x, y, width, height);
546 #define TROUGH_SIZE 7
548 clearlooks_gummy_draw_scale_trough (cairo_t *cr,
549 const ClearlooksColors *colors,
550 const WidgetParameters *params,
551 const SliderParameters *slider,
552 int x, int y, int width, int height)
554 int trough_width, trough_height;
555 double translate_x, translate_y;
556 CairoColor fill, border;
561 if (slider->horizontal)
563 trough_width = width;
564 trough_height = TROUGH_SIZE;
567 translate_y = y + (height/2) - (TROUGH_SIZE/2);
571 trough_width = TROUGH_SIZE;
572 trough_height = height;
574 translate_x = x + (width/2) - (TROUGH_SIZE/2);
578 cairo_set_line_width (cr, 1.0);
579 cairo_translate (cr, translate_x, translate_y);
581 if (!slider->fill_level)
582 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, trough_width, trough_height, 0, 0);
584 if (!slider->lower && !slider->fill_level)
586 ge_shade_color (¶ms->parentbg, 0.896, &fill);
587 border = colors->shade[6];
590 else if (!slider->fill_level)
592 fill = colors->spot[1];
593 border = colors->spot[2];
598 fill = colors->spot[1];
599 border = colors->spot[2];
607 clearlooks_gummy_scale_draw_gradient (cr,
610 1, 1, trough_width - 2, trough_height - 2,
611 slider->horizontal, in);
617 clearlooks_gummy_draw_tab (cairo_t *cr,
618 const ClearlooksColors *colors,
619 const WidgetParameters *params,
620 const TabParameters *tab,
621 int x, int y, int width, int height)
623 const CairoColor *border = &colors->shade[5];
624 const CairoColor *stripe_fill = &colors->spot[1];
625 const CairoColor *stripe_border = &colors->spot[2];
626 const CairoColor *fill;
628 cairo_pattern_t *pattern = NULL;
631 double stripe_size = 2.0;
632 double stripe_fill_size;
633 double stripe_border_pos;
635 gboolean horizontal = FALSE;
637 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
640 cairo_rectangle (cr, x, y, width, height);
644 /* Translate and set line width */
645 cairo_set_line_width (cr, 1.0);
646 cairo_translate (cr, x+0.5, y+0.5);
648 /* Make the tabs slightly bigger than they should be, to create a gap */
649 /* And calculate the strip size too, while you're at it */
650 if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
652 if (params->ythickness == 3)
656 stripe_fill_size = (tab->gap_side == CL_GAP_TOP ? stripe_size/height : stripe_size/(height-2));
657 stripe_border_pos = (tab->gap_side == CL_GAP_TOP ? (stripe_size+1.0)/height : (stripe_size+1.0)/(height-2));
661 if (tab->gap_side == CL_GAP_TOP)
662 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
666 if (params->xthickness == 3)
670 stripe_fill_size = (tab->gap_side == CL_GAP_LEFT ? stripe_size/width : stripe_size/(width-2));
671 stripe_border_pos = (tab->gap_side == CL_GAP_LEFT ? (stripe_size+1.0)/width : (stripe_size+1.0)/(width-2));
673 if (tab->gap_side == CL_GAP_LEFT)
674 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
677 /* Set the fill color */
678 fill = &colors->bg[params->state_type];
681 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
682 radius, params->corners);
685 ge_cairo_set_color (cr, fill);
691 ShadowParameters shadow;
693 shadow.shadow = CL_SHADOW_OUT;
694 shadow.corners = params->corners;
696 clearlooks_gummy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow,
697 width, height, radius);
703 CairoColor shade1, shade2, shade3;
705 ge_shade_color (fill, 1.15, &hilight);
706 ge_shade_color (fill, SHADE_TOP, &shade1);
707 ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
708 ge_shade_color (fill, SHADE_BOTTOM, &shade3);
710 switch (tab->gap_side)
713 pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
716 pattern = cairo_pattern_create_linear (0, 1, 0, height);
719 pattern = cairo_pattern_create_linear (width-2, 0, 1, 0);
722 pattern = cairo_pattern_create_linear (1, 0, width-2, 0);
726 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
728 cairo_pattern_add_color_stop_rgb (pattern, 0.0, hilight.r, hilight.g, hilight.b);
729 cairo_pattern_add_color_stop_rgb (pattern, 1.0/(horizontal ? height : width), hilight.r, hilight.g, hilight.b);
730 cairo_pattern_add_color_stop_rgb (pattern, 1.0/(horizontal ? height : width), shade1.r, shade1.g, shade1.b);
731 cairo_pattern_add_color_stop_rgb (pattern, 0.45, shade2.r, shade2.g, shade2.b);
732 cairo_pattern_add_color_stop_rgb (pattern, 0.45, fill->r, fill->g, fill->b);
733 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
734 cairo_set_source (cr, pattern);
736 cairo_pattern_destroy (pattern);
742 ge_shade_color (fill, SHADE_TOP, &shade1);
744 switch (tab->gap_side)
747 pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
750 pattern = cairo_pattern_create_linear (0, 0, 0, height);
753 pattern = cairo_pattern_create_linear (width-2, 0, 0, 0);
756 pattern = cairo_pattern_create_linear (0, 0, width, 0);
760 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
762 cairo_pattern_add_color_stop_rgba (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.6);
763 /* cairo_pattern_add_color_stop_rgba (pattern, 1.0/(horizontal ? height : width), stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.34);
764 cairo_pattern_add_color_stop_rgba (pattern, 1.0/(horizontal ? height : width), stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.5); */
765 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
766 cairo_pattern_add_color_stop_rgba (pattern, stripe_fill_size, stripe_border->r, stripe_border->g, stripe_border->b, 0.72);
767 cairo_pattern_add_color_stop_rgba (pattern, stripe_border_pos, stripe_border->r, stripe_border->g, stripe_border->b, 0.72);
768 cairo_pattern_add_color_stop_rgb (pattern, stripe_border_pos, shade1.r, shade1.g, shade1.b);
769 cairo_pattern_add_color_stop_rgba (pattern, 0.8, fill->r, fill->g, fill->b, 0.0);
770 cairo_set_source (cr, pattern);
772 cairo_pattern_destroy (pattern);
775 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
779 ge_cairo_set_color (cr, border);
784 switch (tab->gap_side)
787 pattern = cairo_pattern_create_linear (2, height-2, 2, 2);
790 pattern = cairo_pattern_create_linear (2, 2, 2, height);
793 pattern = cairo_pattern_create_linear (width-2, 2, 2, 2);
796 pattern = cairo_pattern_create_linear (2, 2, width, 2);
800 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
801 cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r, border->g, border->b);
802 cairo_set_source (cr, pattern);
804 cairo_pattern_destroy (pattern);
807 /* In current GTK+ focus and active cannot happen together, but we are robust against it. */
808 if (params->focus && !params->active)
810 CairoColor focus_fill = tab->focus.color;
811 CairoColor fill_shade1, fill_shade2, fill_shade3;
812 CairoColor focus_border;
814 double focus_inset_x = ((tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM) ? 4 : stripe_size + 3);
815 double focus_inset_y = ((tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM) ? stripe_size + 3 : 4);
816 double border_alpha = 0.54;
817 double fill_alpha = 0.17;
819 ge_shade_color (&focus_fill, 0.65, &focus_border);
820 ge_shade_color (&focus_fill, 1.18, &fill_shade1);
821 ge_shade_color (&focus_fill, 1.02, &fill_shade2);
822 ge_shade_color (&focus_fill, 0.84, &fill_shade3);
824 ge_cairo_rounded_rectangle (cr, focus_inset_x, focus_inset_y, width-focus_inset_x*2-1, height-focus_inset_y*2-1, radius-1, CR_CORNER_ALL);
825 pattern = cairo_pattern_create_linear (0, 0, 0, height);
827 cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill_shade1.r, fill_shade1.g, fill_shade1.b, fill_alpha);
828 cairo_pattern_add_color_stop_rgba (pattern, 0.5, fill_shade2.r, fill_shade2.g, fill_shade2.b, fill_alpha);
829 cairo_pattern_add_color_stop_rgba (pattern, 0.5, focus_fill.r, focus_fill.g, focus_fill.b, fill_alpha);
830 cairo_pattern_add_color_stop_rgba (pattern, 1.0, fill_shade3.r, fill_shade3.g, fill_shade3.b, fill_alpha);
831 cairo_set_source (cr, pattern);
832 cairo_fill_preserve (cr);
834 cairo_pattern_destroy (pattern);
836 clearlooks_set_mixed_color (cr, ¶ms->parentbg, &focus_border, border_alpha);
842 clearlooks_gummy_draw_separator (cairo_t *cr,
843 const ClearlooksColors *colors,
844 const WidgetParameters *widget,
845 const SeparatorParameters *separator,
846 int x, int y, int width, int height)
848 CairoColor color = colors->shade[3];
850 ge_shade_color (&color, 1.3, &hilight);
853 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
855 if (separator->horizontal)
857 cairo_set_line_width (cr, 1.0);
858 cairo_translate (cr, x, y+0.5);
860 cairo_move_to (cr, 0.0, 0.0);
861 cairo_line_to (cr, width, 0.0);
862 ge_cairo_set_color (cr, &color);
865 cairo_move_to (cr, 0.0, 1.0);
866 cairo_line_to (cr, width, 1.0);
867 ge_cairo_set_color (cr, &hilight);
872 cairo_set_line_width (cr, 1.0);
873 cairo_translate (cr, x+0.5, y);
875 cairo_move_to (cr, 0.0, 0.0);
876 cairo_line_to (cr, 0.0, height);
877 ge_cairo_set_color (cr, &color);
880 cairo_move_to (cr, 1.0, 0.0);
881 cairo_line_to (cr, 1.0, height);
882 ge_cairo_set_color (cr, &hilight);
890 clearlooks_gummy_draw_slider (cairo_t *cr,
891 const ClearlooksColors *colors,
892 const WidgetParameters *params,
893 int x, int y, int width, int height)
895 const CairoColor *border = &colors->shade[7];
897 CairoColor shade1, shade2, shade3;
898 cairo_pattern_t *pattern;
902 cairo_set_line_width (cr, 1.0);
903 cairo_translate (cr, x, y);
905 ge_shade_color (&colors->bg[params->state_type], 1.0, &fill);
906 if (params->prelight)
907 ge_shade_color (&fill, 1.04, &fill);
909 ge_shade_color (&fill, SHADE_TOP, &shade1);
910 ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
911 ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
913 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
914 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
915 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
916 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b);
917 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
918 cairo_rectangle (cr, 1, 1, width-2, height-2);
919 cairo_set_source (cr, pattern);
921 cairo_pattern_destroy (pattern);
923 clearlooks_set_mixed_color (cr, border, &fill, 0.2);
924 if (params->prelight)
925 ge_cairo_set_color (cr, &colors->spot[2]);
926 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, 2.5, params->corners);
930 shift_x = (width%2 == 0 ? 1 : 0);
931 bar_x = width/2-3+shift_x;
932 cairo_translate (cr, 0.5, 0.5);
933 ge_cairo_set_color (cr, border);
934 for (i=0; i<3-shift_x; i++)
936 cairo_move_to (cr, bar_x, 4);
937 cairo_line_to (cr, bar_x, height-5);
942 params->style_functions->draw_top_left_highlight (cr, &fill, params, 1, 1, width-2, height-2, 2.0, params->corners);
946 clearlooks_gummy_draw_slider_button (cairo_t *cr,
947 const ClearlooksColors *colors,
948 const WidgetParameters *params,
949 const SliderParameters *slider,
950 int x, int y, int width, int height)
952 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
954 cairo_set_line_width (cr, 1.0);
956 if (!slider->horizontal)
957 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
959 cairo_translate (cr, x, y);
961 params->style_functions->draw_shadow (cr, colors, radius, width, height);
962 params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
966 clearlooks_gummy_draw_scrollbar_stepper (cairo_t *cr,
967 const ClearlooksColors *colors,
968 const WidgetParameters *widget,
969 const ScrollBarParameters *scrollbar,
970 const ScrollBarStepperParameters *stepper,
971 int x, int y, int width, int height)
973 CairoCorners corners = CR_CORNER_NONE;
974 const CairoColor *border = &colors->shade[scrollbar->has_color ? 7 : 6];
976 CairoColor shade1, shade2, shade3;
977 cairo_pattern_t *pattern;
978 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
980 if (scrollbar->horizontal)
982 if (stepper->stepper == CL_STEPPER_A)
983 corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
984 else if (stepper->stepper == CL_STEPPER_D)
985 corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
989 if (stepper->stepper == CL_STEPPER_A)
990 corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
991 else if (stepper->stepper == CL_STEPPER_D)
992 corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
995 cairo_translate (cr, x, y);
996 cairo_set_line_width (cr, 1);
998 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
1000 if (scrollbar->horizontal)
1001 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1003 pattern = cairo_pattern_create_linear (0, 0, width, 0);
1005 fill = colors->bg[widget->state_type];
1006 ge_shade_color (&fill, SHADE_TOP, &shade1);
1007 ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
1008 ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
1010 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1011 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1012 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b);
1013 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
1014 cairo_set_source (cr, pattern);
1016 cairo_pattern_destroy (pattern);
1018 widget->style_functions->draw_top_left_highlight (cr, &fill, widget, 1, 1, width - 2, height - 2,
1021 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
1022 clearlooks_set_mixed_color (cr, border, &fill, 0.2);
1027 clearlooks_gummy_draw_scrollbar_slider (cairo_t *cr,
1028 const ClearlooksColors *colors,
1029 const WidgetParameters *widget,
1030 const ScrollBarParameters *scrollbar,
1031 int x, int y, int width, int height)
1033 CairoColor fill = scrollbar->color;
1034 CairoColor border, handles;
1036 CairoColor shade1, shade2, shade3;
1037 cairo_pattern_t *pattern;
1040 gdouble hue_scroll, brightness_scroll, saturation_scroll;
1041 gdouble hue_bg, brightness_bg, saturation_bg;
1043 ge_hsb_from_color (&fill, &hue_scroll, &saturation_scroll, &brightness_scroll);
1044 ge_hsb_from_color (&colors->bg[0], &hue_bg, &saturation_bg, &brightness_bg);
1046 /* Set the right color for border and handles */
1047 if ((fabs(saturation_scroll - saturation_bg) < 0.30) &&
1048 (fabs(brightness_scroll - brightness_bg) < 0.20))
1049 ge_shade_color (&fill, 0.475, &border);
1051 ge_shade_color (&fill, 0.575, &border);
1052 /* The following lines increase contrast when the HUE is between 25 and 195, */
1053 /* fixing a LOT of colorschemes! */
1054 if (scrollbar->has_color && (hue_scroll < 195) && (hue_scroll > 25))
1055 ge_shade_color (&border, 0.85, &border);
1058 ge_mix_color (&border, &fill, scrollbar->has_color? 0.3 : 0.2, &border);
1060 if (scrollbar->junction & CL_JUNCTION_BEGIN)
1062 if (scrollbar->horizontal)
1073 if (scrollbar->junction & CL_JUNCTION_END)
1075 if (scrollbar->horizontal)
1081 if (!scrollbar->horizontal)
1082 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1084 cairo_translate (cr, x, y);
1086 if (widget->prelight)
1087 ge_shade_color (&fill, 1.04, &fill);
1089 cairo_set_line_width (cr, 1);
1091 ge_shade_color (&fill, widget->style_constants->topleft_highlight_shade, &hilight);
1092 ge_shade_color (&fill, SHADE_TOP, &shade1);
1093 ge_shade_color (&fill, SHADE_CENTER_TOP, &shade2);
1094 ge_shade_color (&fill, SHADE_BOTTOM, &shade3);
1096 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1097 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1098 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1099 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b);
1100 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1101 cairo_rectangle (cr, 1, 1, width-2, height-2);
1102 cairo_set_source (cr, pattern);
1104 cairo_pattern_destroy (pattern);
1106 if (scrollbar->has_color)
1108 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.2);
1109 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1113 cairo_move_to (cr, 1.5, height-1.5);
1114 cairo_line_to (cr, 1.5, 1.5);
1115 cairo_line_to (cr, width-1.5, 1.5);
1116 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, widget->style_constants->topleft_highlight_alpha);
1120 ge_cairo_set_color (cr, &border);
1121 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1124 bar_x = width/2 - 4;
1125 cairo_translate(cr, 0.5, 0.5);
1126 ge_cairo_set_color (cr, &handles);
1129 cairo_move_to (cr, bar_x, 5);
1130 cairo_line_to (cr, bar_x, height-6);
1137 clearlooks_gummy_draw_list_view_header (cairo_t *cr,
1138 const ClearlooksColors *colors,
1139 const WidgetParameters *params,
1140 const ListViewHeaderParameters *header,
1141 int x, int y, int width, int height)
1144 CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
1146 const CairoColor *border = &colors->shade[4];
1147 const CairoColor *fill = &colors->bg[params->state_type];
1149 CairoColor shade1, shade2, shade3;
1151 cairo_pattern_t *pattern;
1153 ge_shade_color (fill, 1.11, &hilight);
1154 ge_shade_color (fill, LISTVIEW_SHADE_TOP, &shade1);
1155 ge_shade_color (fill, LISTVIEW_SHADE_CENTER_TOP, &shade2);
1156 ge_shade_color (fill, LISTVIEW_SHADE_BOTTOM, &shade3);
1158 cairo_translate (cr, x, y);
1159 cairo_set_line_width (cr, 1.0);
1162 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1163 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1164 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1165 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1166 cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, shade3.r, shade3.g, shade3.b);
1167 cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, border->r, border->g, border->b);
1168 cairo_pattern_add_color_stop_rgb (pattern, 1.0, border->r, border->g, border->b);
1170 cairo_set_source (cr, pattern);
1171 cairo_rectangle (cr, 0, 0, width, height);
1174 cairo_pattern_destroy (pattern);
1176 /* Draw highlight */
1177 if (header->order & CL_ORDER_FIRST)
1179 cairo_move_to (cr, 0.5, height-1.5);
1180 cairo_line_to (cr, 0.5, 0.5);
1183 cairo_move_to (cr, 0.0, 0.5);
1185 cairo_line_to (cr, width, 0.5);
1187 ge_cairo_set_color (cr, &hilight);
1190 /* Draw resize grip */
1191 if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
1192 (!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
1194 SeparatorParameters separator;
1195 separator.horizontal = FALSE;
1198 params->style_functions->draw_separator (cr, colors, params, &separator,
1199 width-1.5, 4.0, 2, height-8.0);
1201 params->style_functions->draw_separator (cr, colors, params, &separator,
1202 1.5, 4.0, 2, height-8.0);
1207 clearlooks_gummy_draw_toolbar (cairo_t *cr,
1208 const ClearlooksColors *colors,
1209 const WidgetParameters *widget,
1210 const ToolbarParameters *toolbar,
1211 int x, int y, int width, int height)
1213 const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL];
1214 const CairoColor *dark = &colors->shade[3];
1216 ge_shade_color (fill, toolbar->style == 1 ? 1.1 : 1.05, &light);
1218 cairo_set_line_width (cr, 1.0);
1219 cairo_translate (cr, x, y);
1221 if (toolbar->style == 1) /* Enable Extra features */
1223 cairo_pattern_t *pattern;
1224 CairoColor shade1, shade2, shade3;
1226 ge_shade_color (fill, TOOLBAR_SHADE_TOP, &shade1);
1227 ge_shade_color (fill, TOOLBAR_SHADE_CENTER_TOP, &shade2);
1228 ge_shade_color (fill, TOOLBAR_SHADE_BOTTOM, &shade3);
1231 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1232 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b);
1233 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1234 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1235 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b);
1237 cairo_set_source (cr, pattern);
1238 cairo_rectangle (cr, 0, 0, width, height);
1241 cairo_pattern_destroy (pattern);
1245 ge_cairo_set_color (cr, fill);
1249 if (!toolbar->topmost)
1251 /* Draw highlight */
1252 cairo_move_to (cr, 0, 0.5);
1253 cairo_line_to (cr, width-0.5, 0.5);
1254 ge_cairo_set_color (cr, &light);
1259 cairo_move_to (cr, 0, height-0.5);
1260 cairo_line_to (cr, width-0.5, height-0.5);
1261 ge_cairo_set_color (cr, dark);
1266 clearlooks_gummy_draw_menuitem (cairo_t *cr,
1267 const ClearlooksColors *colors,
1268 const WidgetParameters *params,
1269 int x, int y, int width, int height)
1271 const CairoColor *fill = &colors->spot[1];
1272 const CairoColor *border = &colors->spot[2];
1273 CairoColor shade1, shade2, shade3;
1274 cairo_pattern_t *pattern;
1276 ge_shade_color (fill, SHADE_TOP, &shade1);
1277 ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
1278 ge_shade_color (fill, SHADE_BOTTOM, &shade3);
1279 cairo_set_line_width (cr, 1.0);
1281 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1283 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1284 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1285 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1286 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1287 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1289 cairo_set_source (cr, pattern);
1290 cairo_fill_preserve (cr);
1291 cairo_pattern_destroy (pattern);
1293 ge_cairo_set_color (cr, border);
1298 clearlooks_gummy_draw_menubaritem (cairo_t *cr,
1299 const ClearlooksColors *colors,
1300 const WidgetParameters *params,
1301 int x, int y, int width, int height)
1303 const CairoColor *fill = &colors->spot[1];
1304 const CairoColor *border = &colors->spot[2];
1305 CairoColor shade1, shade2, shade3;
1306 cairo_pattern_t *pattern;
1308 ge_shade_color (fill, SHADE_TOP, &shade1);
1309 ge_shade_color (fill, SHADE_CENTER_TOP, &shade2);
1310 ge_shade_color (fill, SHADE_BOTTOM, &shade3);
1311 cairo_set_line_width (cr, 1.0);
1313 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners);
1315 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1316 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1317 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1318 cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b);
1319 cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b);
1321 cairo_set_source (cr, pattern);
1322 cairo_fill_preserve (cr);
1323 cairo_pattern_destroy (pattern);
1325 ge_cairo_set_color (cr, border);
1330 clearlooks_gummy_draw_selected_cell (cairo_t *cr,
1331 const ClearlooksColors *colors,
1332 const WidgetParameters *params,
1333 int x, int y, int width, int height)
1338 color = colors->base[params->state_type];
1340 color = colors->base[GTK_STATE_ACTIVE];
1342 clearlooks_draw_gummy_gradient (cr, x, y, width, height, &color, params->disabled, 0.0, CR_CORNER_NONE);
1346 clearlooks_gummy_draw_statusbar (cairo_t *cr,
1347 const ClearlooksColors *colors,
1348 const WidgetParameters *widget,
1349 int x, int y, int width, int height)
1351 const CairoColor *dark = &colors->shade[3];
1354 ge_shade_color (dark, 1.3, &hilight);
1356 cairo_set_line_width (cr, 1);
1357 cairo_translate (cr, x, y+0.5);
1358 cairo_move_to (cr, 0, 0);
1359 cairo_line_to (cr, width, 0);
1360 ge_cairo_set_color (cr, dark);
1363 cairo_translate (cr, 0, 1);
1364 cairo_move_to (cr, 0, 0);
1365 cairo_line_to (cr, width, 0);
1366 ge_cairo_set_color (cr, &hilight);
1371 clearlooks_gummy_draw_radiobutton (cairo_t *cr,
1372 const ClearlooksColors *colors,
1373 const WidgetParameters *widget,
1374 const CheckboxParameters *checkbox,
1375 int x, int y, int width, int height)
1377 const CairoColor *border;
1378 const CairoColor *dot;
1380 CairoColor highlight;
1381 cairo_pattern_t *pt;
1382 gboolean inconsistent;
1383 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1384 gdouble w, h, cx, cy, radius;
1386 w = (gdouble) width;
1387 h = (gdouble) height;
1390 radius = MIN (width, height) / 2.0;
1392 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1393 draw_bullet |= inconsistent;
1395 if (widget->disabled)
1397 border = &colors->shade[5];
1398 dot = &colors->shade[6];
1402 if (widget->prelight)
1403 border = &colors->spot[2];
1405 border = &colors->shade[6];
1406 dot = &colors->text[0];
1409 ge_shade_color (&widget->parentbg, 0.9, &shadow);
1410 ge_shade_color (&widget->parentbg, 1.1, &highlight);
1412 pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
1413 cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
1414 cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
1415 cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
1416 cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
1418 cairo_translate (cr, x, y);
1420 cairo_set_line_width (cr, MAX (1.0, floor (radius/3)));
1421 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2);
1422 cairo_set_source (cr, pt);
1424 cairo_pattern_destroy (pt);
1426 cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
1428 cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
1430 if (!widget->disabled)
1432 if (widget->prelight)
1433 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1435 ge_cairo_set_color (cr, &colors->base[0]);
1436 cairo_fill_preserve (cr);
1439 ge_cairo_set_color (cr, border);
1446 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1447 cairo_set_line_width (cr, ceil (radius * 2 / 3));
1449 cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy));
1450 cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy));
1452 ge_cairo_set_color (cr, dot);
1457 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
1458 ge_cairo_set_color (cr, dot);
1461 cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
1462 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
1469 clearlooks_gummy_draw_checkbox (cairo_t *cr,
1470 const ClearlooksColors *colors,
1471 const WidgetParameters *widget,
1472 const CheckboxParameters *checkbox,
1473 int x, int y, int width, int height)
1475 const CairoColor *border;
1476 const CairoColor *dot;
1477 gboolean inconsistent = FALSE;
1478 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1480 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1481 draw_bullet |= inconsistent;
1483 if (widget->disabled)
1485 border = &colors->shade[5];
1486 dot = &colors->shade[6];
1490 if (widget->prelight)
1491 border = &colors->spot[2];
1493 border = &colors->shade[6];
1494 dot = &colors->text[GTK_STATE_NORMAL];
1497 cairo_translate (cr, x, y);
1498 cairo_set_line_width (cr, 1);
1500 if (widget->xthickness > 2 && widget->ythickness > 2)
1502 widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0,
1503 width, height, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1505 /* Draw the rectangle for the checkbox itself */
1506 ge_cairo_rounded_rectangle (cr, 1.5, 1.5,
1507 width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1511 /* Draw the rectangle for the checkbox itself */
1512 ge_cairo_rounded_rectangle (cr, 0.5, 0.5,
1513 width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
1516 if (!widget->disabled)
1518 if (widget->prelight)
1519 clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5);
1521 ge_cairo_set_color (cr, &colors->base[0]);
1522 cairo_fill_preserve (cr);
1525 ge_cairo_set_color (cr, border);
1530 if (inconsistent) /* Inconsistent */
1532 cairo_set_line_width (cr, 2.0);
1533 cairo_move_to (cr, 3, height*0.5);
1534 cairo_line_to (cr, width-3, height*0.5);
1538 cairo_set_line_width (cr, 1.7);
1539 cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
1540 cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
1542 cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
1543 0.5 + (width*0.5), (height*0.4),
1544 0.5 + (width*0.70), (height*0.25));
1547 ge_cairo_set_color (cr, dot);
1553 clearlooks_gummy_draw_focus (cairo_t *cr,
1554 const ClearlooksColors *colors,
1555 const WidgetParameters *widget,
1556 const FocusParameters *focus,
1557 int x, int y, int width, int height)
1559 CairoColor fill = focus->color;
1560 CairoColor fill_shade1, fill_shade2, fill_shade3;
1562 CairoColor parentbg = widget->parentbg;
1564 /* Default values */
1565 double xoffset = 1.5;
1566 double yoffset = 1.5;
1567 double radius = widget->radius-1.0;
1568 double border_alpha = 0.64;
1569 double fill_alpha = 0.18;
1570 double shadow_alpha = 0.5;
1571 boolean focus_fill = TRUE;
1572 boolean focus_border = TRUE;
1573 boolean focus_shadow = FALSE;
1575 ge_shade_color (&fill, 0.65, &border);
1576 ge_shade_color (&fill, 1.18, &fill_shade1);
1577 ge_shade_color (&fill, 1.02, &fill_shade2);
1578 ge_shade_color (&fill, 0.84, &fill_shade3);
1580 /* Do some useful things to adjust focus */
1581 switch (focus->type)
1583 case CL_FOCUS_BUTTON:
1584 xoffset = -1.5-(focus->padding);
1585 yoffset = -1.5-(focus->padding);
1589 if (!widget->active)
1590 focus_shadow = TRUE;
1592 case CL_FOCUS_BUTTON_FLAT:
1593 xoffset = -1.5-(focus->padding);
1594 yoffset = -1.5-(focus->padding);
1596 if (widget->active || widget->prelight)
1600 if (!widget->active)
1601 focus_shadow = TRUE;
1604 case CL_FOCUS_LABEL:
1608 case CL_FOCUS_TREEVIEW:
1609 parentbg = colors->base[widget->state_type];
1613 focus_border = FALSE;
1615 case CL_FOCUS_TREEVIEW_DND:
1616 parentbg = colors->base[widget->state_type];
1618 case CL_FOCUS_TREEVIEW_HEADER:
1619 cairo_translate (cr, -1, 0);
1621 case CL_FOCUS_TREEVIEW_ROW:
1622 parentbg = colors->base[widget->state_type];
1623 xoffset = -2.5; /* hack to hide vertical lines */
1625 radius = CLAMP (radius, 0.0, 2.0);
1630 /* In current GTK+ focus and active cannot happen together, but we are robust against it.
1631 * IF the application sets the state to ACTIVE while drawing the tabs focus. */
1632 if (widget->focus && !widget->active)
1635 case CL_FOCUS_SCALE:
1637 case CL_FOCUS_UNKNOWN:
1638 /* Fallback to classic function, dots */
1639 clearlooks_draw_focus (cr, colors, widget, focus, x, y, width, height);
1646 cairo_translate (cr, x, y);
1647 cairo_set_line_width (cr, focus->line_width);
1649 ge_cairo_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, widget->corners);
1653 cairo_pattern_t *pattern;
1655 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1656 cairo_pattern_add_color_stop_rgba (pattern, 0.0, fill_shade1.r, fill_shade1.g, fill_shade1.b, fill_alpha);
1657 cairo_pattern_add_color_stop_rgba (pattern, 0.5, fill_shade2.r, fill_shade2.g, fill_shade2.b, fill_alpha);
1658 cairo_pattern_add_color_stop_rgba (pattern, 0.5, fill.r, fill.g, fill.b, fill_alpha);
1659 cairo_pattern_add_color_stop_rgba (pattern, 1.0, fill_shade3.r, fill_shade3.g, fill_shade3.b, fill_alpha);
1660 cairo_set_source (cr, pattern);
1661 cairo_fill_preserve (cr);
1663 cairo_pattern_destroy (pattern);
1668 clearlooks_set_mixed_color (cr, &parentbg, &border, border_alpha);
1676 ge_cairo_rounded_rectangle (cr, xoffset-1, yoffset-1, width-(xoffset*2)+2, height-(yoffset*2)+2, radius, widget->corners);
1677 clearlooks_set_mixed_color (cr, &parentbg, &fill, shadow_alpha);
1683 clearlooks_register_style_gummy (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
1685 functions->draw_button = clearlooks_gummy_draw_button;
1686 functions->draw_entry = clearlooks_gummy_draw_entry;
1687 functions->draw_progressbar_trough = clearlooks_gummy_draw_progressbar_trough;
1688 functions->draw_progressbar_fill = clearlooks_gummy_draw_progressbar_fill;
1689 functions->draw_scale_trough = clearlooks_gummy_draw_scale_trough;
1690 functions->draw_tab = clearlooks_gummy_draw_tab;
1691 functions->draw_separator = clearlooks_gummy_draw_separator;
1692 functions->draw_slider = clearlooks_gummy_draw_slider;
1693 functions->draw_slider_button = clearlooks_gummy_draw_slider_button;
1694 functions->draw_scrollbar_stepper = clearlooks_gummy_draw_scrollbar_stepper;
1695 functions->draw_scrollbar_slider = clearlooks_gummy_draw_scrollbar_slider;
1696 functions->draw_list_view_header = clearlooks_gummy_draw_list_view_header;
1697 functions->draw_toolbar = clearlooks_gummy_draw_toolbar;
1698 functions->draw_menuitem = clearlooks_gummy_draw_menuitem;
1699 functions->draw_menubaritem = clearlooks_gummy_draw_menubaritem;
1700 functions->draw_selected_cell = clearlooks_gummy_draw_selected_cell;
1701 functions->draw_statusbar = clearlooks_gummy_draw_statusbar;
1702 functions->draw_checkbox = clearlooks_gummy_draw_checkbox;
1703 functions->draw_radiobutton = clearlooks_gummy_draw_radiobutton;
1704 functions->draw_focus = clearlooks_gummy_draw_focus;
1706 constants->topleft_highlight_shade = 1.3;
1707 constants->topleft_highlight_alpha = 0.4;