1 /* Clearlooks Inverted 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>
33 clearlooks_draw_top_left_highlight (cairo_t *cr,
34 const CairoColor *color,
35 const WidgetParameters *params,
36 int width, int height, gdouble radius)
40 double light_top = params->ythickness-1,
41 light_bottom = height - params->ythickness - 1,
42 light_left = params->xthickness-1,
43 light_right = width - params->xthickness - 1;
45 ge_shade_color (color, 1.3, &hilight);
46 cairo_move_to (cr, light_left, light_bottom - (int)radius/2);
48 ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
50 cairo_line_to (cr, light_right - (int)radius/2, light_top);
51 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.7);
56 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
58 cairo_pattern_t *pattern;
60 CairoColor bottom_shade;
61 ge_shade_color (color, hilight, &bottom_shade);
63 pattern = cairo_pattern_create_linear (0, 0, width, height);
64 cairo_pattern_add_color_stop_rgb (pattern, 0, color->r, color->g, color->b);
65 cairo_pattern_add_color_stop_rgb (pattern, 1, bottom_shade.r, bottom_shade.g, bottom_shade.b);
67 cairo_set_source (cr, pattern);
68 cairo_pattern_destroy (pattern);
72 clearlooks_inverted_draw_button (cairo_t *cr,
73 const ClearlooksColors *colors,
74 const WidgetParameters *params,
75 int x, int y, int width, int height)
77 double xoffset = 0, yoffset = 0;
78 double radius = params->radius;
79 const CairoColor *fill = &colors->bg[params->state_type];
80 const CairoColor *border_disabled = &colors->shade[4];
81 CairoColor border_normal;
84 ge_shade_color(&colors->shade[6], 1.05, &border_normal);
85 ge_shade_color (&border_normal, 0.925, &shadow);
89 cairo_translate (cr, x, y);
90 cairo_set_line_width (cr, 1.0);
92 if (params->xthickness == 3 || params->ythickness == 3)
94 if (params->xthickness == 3)
96 if (params->ythickness == 3)
100 radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
102 if (params->xthickness == 3 || params->ythickness == 3)
104 cairo_translate (cr, 0.5, 0.5);
105 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
106 cairo_translate (cr, -0.5, -0.5);
109 ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
111 height-(yoffset*2)-2,
112 radius, params->corners);
116 cairo_pattern_t *pattern;
118 CairoColor top_shade, bottom_shade;
119 ge_shade_color (fill, 0.95, &top_shade);
120 ge_shade_color (fill, 1.05, &bottom_shade);
122 pattern = cairo_pattern_create_linear (0, 0, 0, height);
123 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top_shade.r, top_shade.g, top_shade.b);
124 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bottom_shade.r, bottom_shade.g, bottom_shade.b);
125 cairo_set_source (cr, pattern);
127 cairo_pattern_destroy (pattern);
131 cairo_pattern_t *pattern;
133 ge_cairo_set_color (cr, fill);
134 cairo_fill_preserve (cr);
136 pattern = cairo_pattern_create_linear (0, 0, 0, height);
137 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.0);
138 cairo_pattern_add_color_stop_rgba (pattern, 0.4, shadow.r, shadow.g, shadow.b, 0.0);
139 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.2);
140 cairo_set_source (cr, pattern);
141 cairo_fill_preserve (cr);
142 cairo_pattern_destroy (pattern);
144 pattern = cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
145 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
146 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
147 cairo_set_source (cr, pattern);
148 cairo_fill_preserve (cr);
149 cairo_pattern_destroy (pattern);
151 pattern = cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
152 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
153 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
154 cairo_set_source (cr, pattern);
156 cairo_pattern_destroy (pattern);
159 /* Drawing the border */
161 if (!params->active && params->is_default)
163 const CairoColor *l = &colors->shade[4];
164 const CairoColor *d = &colors->shade[4];
165 ge_cairo_set_color (cr, l);
166 ge_cairo_stroke_rectangle (cr, 2.5, 2.5, width-5, height-5);
168 ge_cairo_set_color (cr, d);
169 ge_cairo_stroke_rectangle (cr, 3.5, 3.5, width-7, height-7);
172 if (params->disabled)
173 ge_cairo_set_color (cr, border_disabled);
176 clearlooks_set_border_gradient (cr, &border_normal, 1.32, 0, height);
178 ge_cairo_set_color (cr, &border_normal);
180 ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
181 width-(xoffset*2)-1, height-(yoffset*2)-1,
182 radius, params->corners);
185 /* Draw the "shadow" */
188 cairo_translate (cr, 0.5, 0.5);
189 /* Draw right shadow */
190 cairo_move_to (cr, width-params->xthickness, params->ythickness - 1);
191 cairo_line_to (cr, width-params->xthickness, height - params->ythickness - 1);
192 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
195 /* Draw topleft shadow */
196 clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
202 clearlooks_inverted_draw_progressbar_fill (cairo_t *cr,
203 const ClearlooksColors *colors,
204 const WidgetParameters *params,
205 const ProgressBarParameters *progressbar,
206 int x, int y, int width, int height,
209 boolean is_horizontal = progressbar->orientation < 2;
215 cairo_pattern_t *pattern;
219 CairoColor top_shade;
221 radius = MAX (0, params->radius - params->xthickness);
226 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
228 if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
229 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
231 /* Clamp the radius so that the _height_ fits ... */
232 radius = MIN (radius, height / 2.0);
234 stroke_width = height*2;
235 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
237 cairo_translate (cr, x, y);
240 /* This is kind of nasty ... Clip twice from each side in case the length
241 * of the fill is smaller than twice the radius. */
242 ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
244 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
248 ge_shade_color (&colors->spot[1], 1.05, &top_shade);
250 /* Draw the background gradient */
251 ge_shade_color (&colors->spot[1], 0.925, &bg_shade);
252 pattern = cairo_pattern_create_linear (0, 0, 0, height);
253 cairo_pattern_add_color_stop_rgb (pattern, 0.0, bg_shade.r, bg_shade.g, bg_shade.b);
254 cairo_pattern_add_color_stop_rgb (pattern, 0.5, top_shade.r, top_shade.g, top_shade.b);
255 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg_shade.r, bg_shade.g, bg_shade.b);
256 cairo_set_source (cr, pattern);
258 cairo_pattern_destroy (pattern);
260 /* Draw the Strokes */
261 while (tile_pos <= width+x_step)
263 cairo_move_to (cr, stroke_width/2-x_step, 0);
264 cairo_line_to (cr, stroke_width-x_step, 0);
265 cairo_line_to (cr, stroke_width/2-x_step, height);
266 cairo_line_to (cr, -x_step, height);
268 cairo_translate (cr, stroke_width, 0);
269 tile_pos += stroke_width;
272 cairo_set_source_rgba (cr, colors->spot[2].r,
278 cairo_restore (cr); /* rounded clip region */
280 /* inner highlight border
281 * This is again kinda ugly. Draw once from each side, clipping away the other. */
282 cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.5);
286 cairo_rectangle (cr, 0, 0, width / 2, height);
289 if (progressbar->pulsing)
290 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
292 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
295 cairo_restore (cr); /* clip */
299 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
302 if (progressbar->value < 1.0 || progressbar->pulsing)
303 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
305 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
308 cairo_restore (cr); /* clip */
311 /* Draw the dark lines and the shadow */
313 /* Again, this weird clip area. */
314 ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
316 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
319 border = colors->spot[2];
326 if (progressbar->pulsing)
328 /* At the beginning of the bar. */
329 cairo_move_to (cr, 0.5 + radius, height + 0.5);
330 ge_cairo_rounded_corner (cr, 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
331 ge_cairo_rounded_corner (cr, 0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
332 ge_cairo_set_color (cr, &border);
335 cairo_move_to (cr, -0.5 + radius, height + 0.5);
336 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
337 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
338 ge_cairo_set_color (cr, &shadow);
341 if (progressbar->value < 1.0 || progressbar->pulsing)
343 /* At the end of the bar. */
344 cairo_move_to (cr, width - 0.5 - radius, -0.5);
345 ge_cairo_rounded_corner (cr, width - 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
346 ge_cairo_rounded_corner (cr, width - 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
347 ge_cairo_set_color (cr, &border);
350 cairo_move_to (cr, width + 0.5 - radius, -0.5);
351 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
352 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
353 ge_cairo_set_color (cr, &shadow);
359 cairo_restore (cr); /* rotation, mirroring */
363 clearlooks_inverted_draw_menuitem (cairo_t *cr,
364 const ClearlooksColors *colors,
365 const WidgetParameters *widget,
366 int x, int y, int width, int height)
368 const CairoColor *fill = &colors->spot[1];
369 CairoColor fill_shade;
370 CairoColor border = colors->spot[2];
371 cairo_pattern_t *pattern;
373 ge_shade_color (&border, 1.05, &border);
374 ge_shade_color (fill, 0.85, &fill_shade);
375 cairo_set_line_width (cr, 1.0);
377 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
379 pattern = cairo_pattern_create_linear (x, y, x, y + height);
380 cairo_pattern_add_color_stop_rgb (pattern, 0, fill_shade.r, fill_shade.g, fill_shade.b);
381 cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill->r, fill->g, fill->b);
383 cairo_set_source (cr, pattern);
384 cairo_fill_preserve (cr);
385 cairo_pattern_destroy (pattern);
387 ge_cairo_set_color (cr, &border);
392 clearlooks_inverted_draw_menubaritem (cairo_t *cr,
393 const ClearlooksColors *colors,
394 const WidgetParameters *widget,
395 int x, int y, int width, int height)
397 const CairoColor *fill = &colors->spot[1];
398 CairoColor fill_shade;
399 CairoColor border = colors->spot[2];
400 cairo_pattern_t *pattern;
402 ge_shade_color (&border, 1.05, &border);
403 ge_shade_color (fill, 0.85, &fill_shade);
405 cairo_set_line_width (cr, 1.0);
406 ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
408 pattern = cairo_pattern_create_linear (x, y, x, y + height);
409 cairo_pattern_add_color_stop_rgb (pattern, 0, fill_shade.r, fill_shade.g, fill_shade.b);
410 cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill->r, fill->g, fill->b);
412 cairo_set_source (cr, pattern);
413 cairo_fill_preserve (cr);
414 cairo_pattern_destroy (pattern);
416 ge_cairo_set_color (cr, &border);
417 cairo_stroke_preserve (cr);
421 clearlooks_inverted_draw_tab (cairo_t *cr,
422 const ClearlooksColors *colors,
423 const WidgetParameters *params,
424 const TabParameters *tab,
425 int x, int y, int width, int height)
427 const CairoColor *border1 = &colors->shade[6];
428 const CairoColor *border2 = &colors->shade[5];
429 const CairoColor *stripe_fill = &colors->spot[1];
430 const CairoColor *stripe_border = &colors->spot[2];
431 const CairoColor *fill;
435 cairo_pattern_t *pattern;
440 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
443 cairo_rectangle (cr, x, y, width, height);
447 /* Translate and set line width */
448 cairo_set_line_width (cr, 1.0);
449 cairo_translate (cr, x+0.5, y+0.5);
452 /* Make the tabs slightly bigger than they should be, to create a gap */
453 /* And calculate the strip size too, while you're at it */
454 if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
457 strip_size = 2.0/height; /* 2 pixel high strip */
459 if (tab->gap_side == CL_GAP_TOP)
460 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
465 strip_size = 2.0/width;
467 if (tab->gap_side == CL_GAP_LEFT)
468 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
471 /* Set the fill color */
472 fill = &colors->bg[params->state_type];
475 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
476 radius, params->corners);
479 ge_cairo_set_color (cr, fill);
482 ge_shade_color (fill, 1.3, &hilight);
486 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-1 : 0,
487 tab->gap_side == CL_GAP_TOP ? height-2 : 1,
488 tab->gap_side == CL_GAP_RIGHT ? width : 0,
489 tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
491 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
493 ge_shade_color (fill, 0.92, &shadow);
495 cairo_pattern_add_color_stop_rgba (pattern, 0.0, hilight.r, hilight.g, hilight.b, 0.4);
496 cairo_pattern_add_color_stop_rgba (pattern, 1.0/height, hilight.r, hilight.g, hilight.b, 0.4);
497 cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, fill->r,fill->g,fill->b);
498 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r,shadow.g,shadow.b);
499 cairo_set_source (cr, pattern);
501 cairo_pattern_destroy (pattern);
506 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 0,
507 tab->gap_side == CL_GAP_TOP ? height-2 : 0,
508 tab->gap_side == CL_GAP_RIGHT ? width : 0,
509 tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
511 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
514 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b);
515 cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
516 cairo_pattern_add_color_stop_rgba (pattern, strip_size, hilight.r, hilight.g, hilight.b, 0.0);
517 cairo_pattern_add_color_stop_rgba (pattern, 0.8, hilight.r, hilight.g, hilight.b, 0.0);
518 cairo_set_source (cr, pattern);
520 cairo_pattern_destroy (pattern);
523 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
527 ge_cairo_set_color (cr, border2);
532 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 2,
533 tab->gap_side == CL_GAP_TOP ? height-2 : 2,
534 tab->gap_side == CL_GAP_RIGHT ? width : 2,
535 tab->gap_side == CL_GAP_BOTTOM ? height : 2 );
537 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
538 cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_border->r, stripe_border->g, stripe_border->b);
539 cairo_pattern_add_color_stop_rgb (pattern, strip_size, border1->r, border1->g, border1->b);
540 cairo_pattern_add_color_stop_rgb (pattern, 1.0, border2->r, border2->g, border2->b);
541 cairo_set_source (cr, pattern);
543 cairo_pattern_destroy (pattern);
548 clearlooks_inverted_draw_slider (cairo_t *cr,
549 const ClearlooksColors *colors,
550 const WidgetParameters *params,
551 int x, int y, int width, int height)
553 const CairoColor *border = &colors->shade[params->disabled ? 4 : 6];
554 const CairoColor *spot = &colors->spot[1];
555 const CairoColor *fill = &colors->shade[2];
556 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
558 cairo_pattern_t *pattern;
560 cairo_set_line_width (cr, 1.0);
561 cairo_translate (cr, x, y);
563 if (params->disabled)
564 border = &colors->shade[4];
565 else if (params->prelight)
566 border = &colors->spot[2];
568 border = &colors->shade[6];
570 /* fill the widget */
571 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
574 if (!params->disabled)
576 const CairoColor *top = &colors->shade[2];
577 const CairoColor *bot = &colors->shade[0];
579 pattern = cairo_pattern_create_linear (0, 0, 0, height);
580 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top->r, top->g, top->b);
581 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bot->r, bot->g, bot->b);
582 cairo_set_source (cr, pattern);
584 cairo_pattern_destroy (pattern);
588 ge_cairo_set_color (cr, fill);
589 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
595 cairo_rectangle (cr, 0.5, 0.5, 6, height-2);
596 cairo_rectangle (cr, width-7.5, 0.5, 6 , height-2);
597 cairo_clip_preserve (cr);
601 /* Draw the handles */
602 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
603 pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, 0.5+height);
605 if (params->prelight)
607 CairoColor highlight;
608 ge_shade_color (spot, 1.5, &highlight);
609 cairo_pattern_add_color_stop_rgb (pattern, 0.0, spot->r, spot->g, spot->b);
610 cairo_pattern_add_color_stop_rgb (pattern, 1.0, highlight.r, highlight.g, highlight.b);
611 cairo_set_source (cr, pattern);
615 ge_shade_color (fill, 1.5, &hilight);
616 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
620 cairo_pattern_destroy (pattern);
624 /* Draw the border */
625 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
626 if (params->prelight || params->disabled)
627 ge_cairo_set_color (cr, border);
629 clearlooks_set_border_gradient (cr, border, 1.2, 0, height);
632 /* Draw handle lines */
635 cairo_move_to (cr, 6, 0.5);
636 cairo_line_to (cr, 6, height-1);
638 cairo_move_to (cr, width-7, 0.5);
639 cairo_line_to (cr, width-7, height-1);
641 cairo_set_line_width (cr, 1.0);
642 cairo_set_source_rgba (cr, border->r,
651 clearlooks_inverted_draw_slider_button (cairo_t *cr,
652 const ClearlooksColors *colors,
653 const WidgetParameters *params,
654 const SliderParameters *slider,
655 int x, int y, int width, int height)
657 double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
658 cairo_set_line_width (cr, 1.0);
660 if (!slider->horizontal)
661 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
662 cairo_translate (cr, x+0.5, y+0.5);
664 params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
665 params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
668 params->style_functions->draw_gripdots (cr, colors, 0, 0, width-2, height-2, 3, 3, 0);
672 clearlooks_inverted_draw_list_view_header (cairo_t *cr,
673 const ClearlooksColors *colors,
674 const WidgetParameters *params,
675 const ListViewHeaderParameters *header,
676 int x, int y, int width, int height)
678 const CairoColor *fill = &colors->bg[params->state_type];
679 const CairoColor *border = &colors->shade[4];
680 cairo_pattern_t *pattern;
681 CairoColor hilight_header;
685 ge_shade_color (border, 1.5, &hilight);
686 ge_shade_color (fill, 1.05, &hilight_header);
687 ge_shade_color (fill, 0.95, &shadow);
689 cairo_translate (cr, x, y);
690 cairo_set_line_width (cr, 1.0);
693 if (header->order == CL_ORDER_FIRST)
695 cairo_move_to (cr, 0.5, height-1);
696 cairo_line_to (cr, 0.5, 0.5);
699 cairo_move_to (cr, 0.0, 0.5);
701 cairo_line_to (cr, width, 0.5);
703 ge_cairo_set_color (cr, &hilight);
706 /* Draw bottom border */
707 cairo_move_to (cr, 0.0, height-0.5);
708 cairo_line_to (cr, width, height-0.5);
709 ge_cairo_set_color (cr, border);
712 /* Draw bottom shade */
713 pattern = cairo_pattern_create_linear (0.0, 0, 0.0, height-1.0);
714 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shadow.r, shadow.g, shadow.b);
715 cairo_pattern_add_color_stop_rgb (pattern, 1.0, hilight_header.r, hilight_header.g, hilight_header.b);
717 cairo_rectangle (cr, 0, 1, width, height-2);
718 cairo_set_source (cr, pattern);
720 cairo_pattern_destroy (pattern);
722 /* Draw resize grip */
723 if ((params->ltr && header->order != CL_ORDER_LAST) ||
724 (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
726 SeparatorParameters separator;
727 separator.horizontal = FALSE;
730 params->style_functions->draw_separator (cr, colors, params, &separator,
731 width-1.5, 4.0, 2, height-8.0);
733 params->style_functions->draw_separator (cr, colors, params, &separator,
734 1.5, 4.0, 2, height-8.0);
740 clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
741 const ClearlooksColors *colors,
742 const WidgetParameters *widget,
743 const ScrollBarParameters *scrollbar,
744 const ScrollBarStepperParameters *stepper,
745 int x, int y, int width, int height)
747 CairoCorners corners = CR_CORNER_NONE;
749 CairoColor s1, s2, s3;
750 cairo_pattern_t *pattern;
751 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
753 ge_shade_color(&colors->shade[6], 1.05, &border);
755 if (scrollbar->horizontal)
757 if (stepper->stepper == CL_STEPPER_A)
758 corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
759 else if (stepper->stepper == CL_STEPPER_D)
760 corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
764 if (stepper->stepper == CL_STEPPER_A)
765 corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
766 else if (stepper->stepper == CL_STEPPER_D)
767 corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
770 cairo_translate (cr, x, y);
771 cairo_set_line_width (cr, 1);
773 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
775 if (scrollbar->horizontal)
776 pattern = cairo_pattern_create_linear (0, 0, 0, height);
778 pattern = cairo_pattern_create_linear (0, 0, width, 0);
780 s1 = colors->bg[widget->state_type];
781 ge_shade_color(&s1, 0.95, &s2);
782 ge_shade_color(&s1, 1.05, &s3);
784 cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
785 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
786 cairo_set_source (cr, pattern);
788 cairo_pattern_destroy (pattern);
790 clearlooks_draw_top_left_highlight (cr, &s1, widget, width, height, radius);
792 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
793 clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
796 cairo_translate (cr, 0.5, 0.5);
800 clearlooks_inverted_draw_scrollbar_slider (cairo_t *cr,
801 const ClearlooksColors *colors,
802 const WidgetParameters *widget,
803 const ScrollBarParameters *scrollbar,
804 int x, int y, int width, int height)
806 if (scrollbar->junction & CL_JUNCTION_BEGIN)
808 if (scrollbar->horizontal)
819 if (scrollbar->junction & CL_JUNCTION_END)
821 if (scrollbar->horizontal)
827 if (!scrollbar->horizontal)
828 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
830 cairo_translate (cr, x, y);
832 if (scrollbar->has_color)
834 const CairoColor *border = &colors->shade[8];
835 CairoColor fill = scrollbar->color;
837 CairoColor shade1, shade2, shade3;
838 cairo_pattern_t *pattern;
840 if (widget->prelight)
841 ge_shade_color (&fill, 1.1, &fill);
843 cairo_set_line_width (cr, 1);
845 ge_shade_color (&fill, 1.3, &hilight);
846 ge_shade_color (&fill, 1.1, &shade1);
847 ge_shade_color (&fill, 1.05, &shade2);
848 ge_shade_color (&fill, 0.98, &shade3);
850 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
851 cairo_pattern_add_color_stop_rgb (pattern, 0, fill.r, fill.g, fill.b);
852 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
853 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
854 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade1.r, shade1.g, shade1.b);
855 cairo_rectangle (cr, 1, 1, width-2, height-2);
856 cairo_set_source (cr, pattern);
858 cairo_pattern_destroy (pattern);
860 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
861 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
863 ge_cairo_set_color (cr, border);
864 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
869 CairoColor s1, s2, s3;
870 cairo_pattern_t *pattern;
873 const CairoColor *dark = &colors->shade[4];
874 const CairoColor *light = &colors->shade[0];
876 ge_shade_color(&colors->shade[6], 1.05, &border);
878 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
880 s1 = colors->bg[widget->state_type];
881 ge_shade_color(&s1, 0.95, &s2);
882 ge_shade_color(&s1, 1.05, &s3);
884 cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
885 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
887 cairo_rectangle (cr, 1, 1, width-2, height-2);
888 cairo_set_source(cr, pattern);
890 cairo_pattern_destroy(pattern);
892 clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, 0);
894 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
895 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
898 cairo_set_line_width (cr, 1);
901 cairo_translate(cr, 0.5, 0.5);
904 cairo_move_to (cr, bar_x, 4);
905 cairo_line_to (cr, bar_x, height-5);
906 ge_cairo_set_color (cr, dark);
909 cairo_move_to (cr, bar_x+1, 4);
910 cairo_line_to (cr, bar_x+1, height-5);
911 ge_cairo_set_color (cr, light);
920 clearlooks_inverted_draw_selected_cell (cairo_t *cr,
921 const ClearlooksColors *colors,
922 const WidgetParameters *params,
923 int x, int y, int width, int height)
925 CairoColor upper_color;
926 CairoColor lower_color;
928 cairo_pattern_t *pattern;
931 cairo_translate (cr, x, y);
934 upper_color = colors->base[params->state_type];
936 upper_color = colors->base[GTK_STATE_ACTIVE];
938 ge_shade_color(&upper_color, 0.9, &lower_color);
940 pattern = cairo_pattern_create_linear (0, 0, 0, height);
941 cairo_pattern_add_color_stop_rgb (pattern, 0.0, lower_color.r,
944 cairo_pattern_add_color_stop_rgb (pattern, 1.0, upper_color.r,
949 cairo_set_source (cr, pattern);
950 cairo_rectangle (cr, 0, 0, width, height);
952 cairo_pattern_destroy (pattern);
954 ge_shade_color(&upper_color, 0.8, &border);
956 cairo_move_to (cr, 0, 0.5);
957 cairo_rel_line_to (cr, width, 0);
958 cairo_move_to (cr, 0, height-0.5);
959 cairo_rel_line_to (cr, width, 0);
961 ge_cairo_set_color (cr, &border);
968 clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions)
970 functions->draw_button = clearlooks_inverted_draw_button;
971 functions->draw_slider = clearlooks_inverted_draw_slider;
972 functions->draw_slider_button = clearlooks_inverted_draw_slider_button;
973 functions->draw_progressbar_fill = clearlooks_inverted_draw_progressbar_fill;
974 functions->draw_menuitem = clearlooks_inverted_draw_menuitem;
975 functions->draw_menubaritem = clearlooks_inverted_draw_menubaritem;
976 functions->draw_tab = clearlooks_inverted_draw_tab;
977 functions->draw_list_view_header = clearlooks_inverted_draw_list_view_header;
978 functions->draw_scrollbar_stepper = clearlooks_inverted_draw_scrollbar_stepper;
979 functions->draw_scrollbar_slider = clearlooks_inverted_draw_scrollbar_slider;
980 functions->draw_selected_cell = clearlooks_inverted_draw_selected_cell;