Fix angle bracket project-local include paths.
[ardour2.git] / libs / clearlooks-newer / clearlooks_draw_inverted.c
blob2e8ee3bcd76e54c8b2d23a263ee9fd14abea0aa2
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"
26 #include "support.h"
27 #include <ge-support.h>
29 #include <cairo.h>
32 static void
33 clearlooks_draw_top_left_highlight (cairo_t *cr,
34 const CairoColor *color,
35 const WidgetParameters *params,
36 int width, int height, gdouble radius)
38 CairoColor hilight;
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);
52 cairo_stroke (cr);
55 static void
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);
71 static void
72 clearlooks_inverted_draw_button (cairo_t *cr,
73 const ClearlooksColors *colors,
74 const WidgetParameters *params,
75 int x, int y, int width, int height)
77 double xoffset = 0, yoffset = 0;
78 double radius = params->radius;
79 const CairoColor *fill = &colors->bg[params->state_type];
80 const CairoColor *border_disabled = &colors->shade[4];
81 CairoColor border_normal;
82 CairoColor shadow;
84 ge_shade_color(&colors->shade[6], 1.05, &border_normal);
85 ge_shade_color (&border_normal, 0.925, &shadow);
87 cairo_save (cr);
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)
95 xoffset = 1;
96 if (params->ythickness == 3)
97 yoffset = 1;
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, &params->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,
110 width-(xoffset*2)-2,
111 height-(yoffset*2)-2,
112 radius, params->corners);
114 if (!params->active)
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);
126 cairo_fill (cr);
127 cairo_pattern_destroy (pattern);
129 else
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);
155 cairo_fill (cr);
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);
174 else
175 if (!params->active)
176 clearlooks_set_border_gradient (cr, &border_normal, 1.32, 0, height);
177 else
178 ge_cairo_set_color (cr, &border_normal);
180 ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5,
181 width-(xoffset*2)-1, height-(yoffset*2)-1,
182 radius, params->corners);
183 cairo_stroke (cr);
185 /* Draw the "shadow" */
186 if (!params->active)
188 cairo_translate (cr, 0.5, 0.5);
189 /* Draw right shadow */
190 cairo_move_to (cr, width-params->xthickness, params->ythickness - 1);
191 cairo_line_to (cr, width-params->xthickness, height - params->ythickness - 1);
192 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
193 cairo_stroke (cr);
195 /* Draw topleft shadow */
196 clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
198 cairo_restore (cr);
201 static void
202 clearlooks_inverted_draw_progressbar_fill (cairo_t *cr,
203 const ClearlooksColors *colors,
204 const WidgetParameters *params,
205 const ProgressBarParameters *progressbar,
206 int x, int y, int width, int height,
207 gint offset)
209 boolean is_horizontal = progressbar->orientation < 2;
210 double tile_pos = 0;
211 double stroke_width;
212 double radius;
213 int x_step;
215 cairo_pattern_t *pattern;
216 CairoColor bg_shade;
217 CairoColor border;
218 CairoColor shadow;
219 CairoColor top_shade;
221 radius = MAX (0, params->radius - params->xthickness);
223 cairo_save (cr);
225 if (!is_horizontal)
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);
239 cairo_save (cr);
240 /* This is kind of nasty ... Clip twice from each side in case the length
241 * of the fill is smaller than twice the radius. */
242 ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
243 cairo_clip (cr);
244 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
245 cairo_clip (cr);
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);
257 cairo_paint (cr);
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,
273 colors->spot[2].g,
274 colors->spot[2].b,
275 0.15);
277 cairo_fill (cr);
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);
284 /* left side */
285 cairo_save (cr);
286 cairo_rectangle (cr, 0, 0, width / 2, height);
287 cairo_clip (cr);
289 if (progressbar->pulsing)
290 ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
291 else
292 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
294 cairo_stroke (cr);
295 cairo_restore (cr); /* clip */
297 /* right side */
298 cairo_save (cr);
299 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
300 cairo_clip (cr);
302 if (progressbar->value < 1.0 || progressbar->pulsing)
303 ge_cairo_rounded_rectangle (cr, -1.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
304 else
305 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
307 cairo_stroke (cr);
308 cairo_restore (cr); /* clip */
311 /* Draw the dark lines and the shadow */
312 cairo_save (cr);
313 /* Again, this weird clip area. */
314 ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
315 cairo_clip (cr);
316 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
317 cairo_clip (cr);
319 border = colors->spot[2];
320 border.a = 0.5;
321 shadow.r = 0.0;
322 shadow.g = 0.0;
323 shadow.b = 0.0;
324 shadow.a = 0.1;
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);
333 cairo_stroke (cr);
335 cairo_move_to (cr, -0.5 + radius, height + 0.5);
336 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
337 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
338 ge_cairo_set_color (cr, &shadow);
339 cairo_stroke (cr);
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);
348 cairo_stroke (cr);
350 cairo_move_to (cr, width + 0.5 - radius, -0.5);
351 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
352 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
353 ge_cairo_set_color (cr, &shadow);
354 cairo_stroke (cr);
357 cairo_restore (cr);
359 cairo_restore (cr); /* rotation, mirroring */
362 static void
363 clearlooks_inverted_draw_menuitem (cairo_t *cr,
364 const ClearlooksColors *colors,
365 const WidgetParameters *widget,
366 int x, int y, int width, int height)
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);
388 cairo_stroke (cr);
391 static void
392 clearlooks_inverted_draw_menubaritem (cairo_t *cr,
393 const ClearlooksColors *colors,
394 const WidgetParameters *widget,
395 int x, int y, int width, int height)
397 CairoColor *fill = (CairoColor*)&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);
420 static void
421 clearlooks_inverted_draw_tab (cairo_t *cr,
422 const ClearlooksColors *colors,
423 const WidgetParameters *params,
424 const TabParameters *tab,
425 int x, int y, int width, int height)
427 const CairoColor *border1 = &colors->shade[6];
428 const CairoColor *border2 = &colors->shade[5];
429 const CairoColor *stripe_fill = &colors->spot[1];
430 const CairoColor *stripe_border = &colors->spot[2];
431 const CairoColor *fill;
432 CairoColor hilight;
433 CairoColor shadow;
435 cairo_pattern_t *pattern;
437 double radius;
438 double strip_size;
440 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
442 /* Set clip */
443 cairo_rectangle (cr, x, y, width, height);
444 cairo_clip (cr);
445 cairo_new_path (cr);
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)
456 height += 3.0;
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 */
462 else
464 width += 3.0;
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];
474 /* Set tab shape */
475 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
476 radius, params->corners);
478 /* Draw fill */
479 ge_cairo_set_color (cr, fill);
480 cairo_fill (cr);
482 ge_shade_color (fill, 1.3, &hilight);
484 /* Draw highlight */
485 if (!params->active)
487 ShadowParameters shadow;
489 shadow.shadow = CL_SHADOW_OUT;
490 shadow.corners = params->corners;
492 clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
493 width,
494 height, radius);*/
497 if (params->active)
499 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-1 : 0,
500 tab->gap_side == CL_GAP_TOP ? height-2 : 1,
501 tab->gap_side == CL_GAP_RIGHT ? width : 0,
502 tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
504 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
506 ge_shade_color (fill, 0.92, &shadow);
508 cairo_pattern_add_color_stop_rgba (pattern, 0.0, hilight.r, hilight.g, hilight.b, 0.4);
509 cairo_pattern_add_color_stop_rgba (pattern, 1.0/height, hilight.r, hilight.g, hilight.b, 0.4);
510 cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, fill->r,fill->g,fill->b);
511 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r,shadow.g,shadow.b);
512 cairo_set_source (cr, pattern);
513 cairo_fill (cr);
514 cairo_pattern_destroy (pattern);
516 else
518 /* Draw shade */
519 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 0,
520 tab->gap_side == CL_GAP_TOP ? height-2 : 0,
521 tab->gap_side == CL_GAP_RIGHT ? width : 0,
522 tab->gap_side == CL_GAP_BOTTOM ? height : 0 );
524 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
527 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b);
528 cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
529 cairo_pattern_add_color_stop_rgba (pattern, strip_size, hilight.r, hilight.g, hilight.b, 0.0);
530 cairo_pattern_add_color_stop_rgba (pattern, 0.8, hilight.r, hilight.g, hilight.b, 0.0);
531 cairo_set_source (cr, pattern);
532 cairo_fill (cr);
533 cairo_pattern_destroy (pattern);
536 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
538 if (params->active)
540 ge_cairo_set_color (cr, border2);
541 cairo_stroke (cr);
543 else
545 pattern = cairo_pattern_create_linear ( tab->gap_side == CL_GAP_LEFT ? width-2 : 2,
546 tab->gap_side == CL_GAP_TOP ? height-2 : 2,
547 tab->gap_side == CL_GAP_RIGHT ? width : 2,
548 tab->gap_side == CL_GAP_BOTTOM ? height : 2 );
550 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
551 cairo_pattern_add_color_stop_rgb (pattern, strip_size, stripe_border->r, stripe_border->g, stripe_border->b);
552 cairo_pattern_add_color_stop_rgb (pattern, strip_size, border1->r, border1->g, border1->b);
553 cairo_pattern_add_color_stop_rgb (pattern, 1.0, border2->r, border2->g, border2->b);
554 cairo_set_source (cr, pattern);
555 cairo_stroke (cr);
556 cairo_pattern_destroy (pattern);
560 static void
561 clearlooks_inverted_draw_slider (cairo_t *cr,
562 const ClearlooksColors *colors,
563 const WidgetParameters *params,
564 int x, int y, int width, int height)
566 const CairoColor *border = &colors->shade[params->disabled ? 4 : 6];
567 const CairoColor *spot = &colors->spot[1];
568 const CairoColor *fill = &colors->shade[2];
569 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
571 cairo_pattern_t *pattern;
573 cairo_set_line_width (cr, 1.0);
574 cairo_translate (cr, x, y);
576 if (params->disabled)
577 border = &colors->shade[4];
578 else if (params->prelight)
579 border = &colors->spot[2];
580 else
581 border = &colors->shade[6];
583 /* fill the widget */
584 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
586 /* Fake light */
587 if (!params->disabled)
589 const CairoColor *top = &colors->shade[2];
590 const CairoColor *bot = &colors->shade[0];
592 pattern = cairo_pattern_create_linear (0, 0, 0, height);
593 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top->r, top->g, top->b);
594 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bot->r, bot->g, bot->b);
595 cairo_set_source (cr, pattern);
596 cairo_fill (cr);
597 cairo_pattern_destroy (pattern);
599 else
601 ge_cairo_set_color (cr, fill);
602 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
603 cairo_fill (cr);
606 /* Set the clip */
607 cairo_save (cr);
608 cairo_rectangle (cr, 0.5, 0.5, 6, height-2);
609 cairo_rectangle (cr, width-7.5, 0.5, 6 , height-2);
610 cairo_clip_preserve (cr);
612 cairo_new_path (cr);
614 /* Draw the handles */
615 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
616 pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, 0.5+height);
618 if (params->prelight)
620 CairoColor highlight;
621 ge_shade_color (spot, 1.5, &highlight);
622 cairo_pattern_add_color_stop_rgb (pattern, 0.0, spot->r, spot->g, spot->b);
623 cairo_pattern_add_color_stop_rgb (pattern, 1.0, highlight.r, highlight.g, highlight.b);
624 cairo_set_source (cr, pattern);
626 else {
627 CairoColor hilight;
628 ge_shade_color (fill, 1.5, &hilight);
629 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
632 cairo_fill (cr);
633 cairo_pattern_destroy (pattern);
635 cairo_restore (cr);
637 /* Draw the border */
638 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
639 if (params->prelight || params->disabled)
640 ge_cairo_set_color (cr, border);
641 else
642 clearlooks_set_border_gradient (cr, border, 1.2, 0, height);
643 cairo_stroke (cr);
645 /* Draw handle lines */
646 if (width > 14)
648 cairo_move_to (cr, 6, 0.5);
649 cairo_line_to (cr, 6, height-1);
651 cairo_move_to (cr, width-7, 0.5);
652 cairo_line_to (cr, width-7, height-1);
654 cairo_set_line_width (cr, 1.0);
655 cairo_set_source_rgba (cr, border->r,
656 border->g,
657 border->b,
658 0.3);
659 cairo_stroke (cr);
663 static void
664 clearlooks_inverted_draw_slider_button (cairo_t *cr,
665 const ClearlooksColors *colors,
666 const WidgetParameters *params,
667 const SliderParameters *slider,
668 int x, int y, int width, int height)
670 double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
671 cairo_set_line_width (cr, 1.0);
673 if (!slider->horizontal)
674 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
675 cairo_translate (cr, x+0.5, y+0.5);
677 params->style_functions->draw_shadow (cr, colors, radius, width-1, height-1);
678 params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
680 if (width > 24)
681 params->style_functions->draw_gripdots (cr, colors, 0, 0, width-2, height-2, 3, 3, 0);
684 static void
685 clearlooks_inverted_draw_list_view_header (cairo_t *cr,
686 const ClearlooksColors *colors,
687 const WidgetParameters *params,
688 const ListViewHeaderParameters *header,
689 int x, int y, int width, int height)
691 const CairoColor *fill = &colors->bg[params->state_type];
692 const CairoColor *border = &colors->shade[4];
693 cairo_pattern_t *pattern;
694 CairoColor hilight_header;
695 CairoColor hilight;
696 CairoColor shadow;
698 ge_shade_color (border, 1.5, &hilight);
699 ge_shade_color (fill, 1.05, &hilight_header);
700 ge_shade_color (fill, 0.95, &shadow);
702 cairo_translate (cr, x, y);
703 cairo_set_line_width (cr, 1.0);
705 /* Draw highlight */
706 if (header->order == CL_ORDER_FIRST)
708 cairo_move_to (cr, 0.5, height-1);
709 cairo_line_to (cr, 0.5, 0.5);
711 else
712 cairo_move_to (cr, 0.0, 0.5);
714 cairo_line_to (cr, width, 0.5);
716 ge_cairo_set_color (cr, &hilight);
717 cairo_stroke (cr);
719 /* Draw bottom border */
720 cairo_move_to (cr, 0.0, height-0.5);
721 cairo_line_to (cr, width, height-0.5);
722 ge_cairo_set_color (cr, border);
723 cairo_stroke (cr);
725 /* Draw bottom shade */
726 pattern = cairo_pattern_create_linear (0.0, 0, 0.0, height-1.0);
727 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shadow.r, shadow.g, shadow.b);
728 cairo_pattern_add_color_stop_rgb (pattern, 1.0, hilight_header.r, hilight_header.g, hilight_header.b);
730 cairo_rectangle (cr, 0, 1, width, height-2);
731 cairo_set_source (cr, pattern);
732 cairo_fill (cr);
733 cairo_pattern_destroy (pattern);
735 /* Draw resize grip */
736 if ((params->ltr && header->order != CL_ORDER_LAST) ||
737 (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
739 SeparatorParameters separator;
740 separator.horizontal = FALSE;
742 if (params->ltr)
743 params->style_functions->draw_separator (cr, colors, params, &separator,
744 width-1.5, 4.0, 2, height-8.0);
745 else
746 params->style_functions->draw_separator (cr, colors, params, &separator,
747 1.5, 4.0, 2, height-8.0);
752 static void
753 clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
754 const ClearlooksColors *colors,
755 const WidgetParameters *widget,
756 const ScrollBarParameters *scrollbar,
757 const ScrollBarStepperParameters *stepper,
758 int x, int y, int width, int height)
760 CairoCorners corners = CR_CORNER_NONE;
761 CairoColor border;
762 CairoColor s1, s2, s3;
763 cairo_pattern_t *pattern;
764 ShadowParameters shadow;
765 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
767 ge_shade_color(&colors->shade[6], 1.05, &border);
769 if (scrollbar->horizontal)
771 if (stepper->stepper == CL_STEPPER_A)
772 corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
773 else if (stepper->stepper == CL_STEPPER_D)
774 corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
776 else
778 if (stepper->stepper == CL_STEPPER_A)
779 corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
780 else if (stepper->stepper == CL_STEPPER_D)
781 corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
784 cairo_translate (cr, x, y);
785 cairo_set_line_width (cr, 1);
787 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
789 if (scrollbar->horizontal)
790 pattern = cairo_pattern_create_linear (0, 0, 0, height);
791 else
792 pattern = cairo_pattern_create_linear (0, 0, width, 0);
794 s1 = colors->bg[widget->state_type];
795 ge_shade_color(&s1, 0.95, &s2);
796 ge_shade_color(&s1, 1.05, &s3);
798 cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
799 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
800 cairo_set_source (cr, pattern);
801 cairo_fill (cr);
802 cairo_pattern_destroy (pattern);
804 clearlooks_draw_top_left_highlight (cr, &s1, widget, width, height, radius);
806 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
807 clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
808 cairo_stroke (cr);
810 cairo_translate (cr, 0.5, 0.5);
811 shadow.shadow = CL_SHADOW_OUT;
812 shadow.corners = corners;
814 clearlooks_draw_highlight_and_shade (cr, &shadow,
815 width,
816 height, params->radius);*/
819 static void
820 clearlooks_inverted_draw_scrollbar_slider (cairo_t *cr,
821 const ClearlooksColors *colors,
822 const WidgetParameters *widget,
823 const ScrollBarParameters *scrollbar,
824 int x, int y, int width, int height)
826 if (scrollbar->junction & CL_JUNCTION_BEGIN)
828 if (scrollbar->horizontal)
830 x -= 1;
831 width += 1;
833 else
835 y -= 1;
836 height += 1;
839 if (scrollbar->junction & CL_JUNCTION_END)
841 if (scrollbar->horizontal)
842 width += 1;
843 else
844 height += 1;
847 if (!scrollbar->horizontal)
848 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
850 cairo_translate (cr, x, y);
852 if (scrollbar->has_color)
854 const CairoColor *border = &colors->shade[8];
855 CairoColor fill = scrollbar->color;
856 CairoColor hilight;
857 CairoColor shade1, shade2, shade3;
858 cairo_pattern_t *pattern;
860 if (widget->prelight)
861 ge_shade_color (&fill, 1.1, &fill);
863 cairo_set_line_width (cr, 1);
865 ge_shade_color (&fill, 1.3, &hilight);
866 ge_shade_color (&fill, 1.1, &shade1);
867 ge_shade_color (&fill, 1.05, &shade2);
868 ge_shade_color (&fill, 0.98, &shade3);
870 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
871 cairo_pattern_add_color_stop_rgb (pattern, 0, fill.r, fill.g, fill.b);
872 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
873 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
874 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade1.r, shade1.g, shade1.b);
875 cairo_rectangle (cr, 1, 1, width-2, height-2);
876 cairo_set_source (cr, pattern);
877 cairo_fill (cr);
878 cairo_pattern_destroy (pattern);
880 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
881 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
883 ge_cairo_set_color (cr, border);
884 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
886 else
888 CairoColor border;
889 CairoColor s1, s2, s3;
890 cairo_pattern_t *pattern;
891 int bar_x, i;
893 const CairoColor *dark = &colors->shade[4];
894 const CairoColor *light = &colors->shade[0];
896 ge_shade_color(&colors->shade[6], 1.05, &border);
898 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
900 s1 = colors->bg[widget->state_type];
901 ge_shade_color(&s1, 0.95, &s2);
902 ge_shade_color(&s1, 1.05, &s3);
904 cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
905 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
907 cairo_rectangle (cr, 1, 1, width-2, height-2);
908 cairo_set_source(cr, pattern);
909 cairo_fill(cr);
910 cairo_pattern_destroy(pattern);
912 clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, 0);
914 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
915 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
917 /* draw handles */
918 cairo_set_line_width (cr, 1);
920 bar_x = width/2 - 4;
921 cairo_translate(cr, 0.5, 0.5);
922 for (i=0; i<3; i++)
924 cairo_move_to (cr, bar_x, 4);
925 cairo_line_to (cr, bar_x, height-5);
926 ge_cairo_set_color (cr, dark);
927 cairo_stroke (cr);
929 cairo_move_to (cr, bar_x+1, 4);
930 cairo_line_to (cr, bar_x+1, height-5);
931 ge_cairo_set_color (cr, light);
932 cairo_stroke (cr);
934 bar_x += 3;
939 static void
940 clearlooks_inverted_draw_selected_cell (cairo_t *cr,
941 const ClearlooksColors *colors,
942 const WidgetParameters *params,
943 int x, int y, int width, int height)
945 CairoColor upper_color;
946 CairoColor lower_color;
947 CairoColor border;
948 cairo_pattern_t *pattern;
949 cairo_save (cr);
951 cairo_translate (cr, x, y);
953 if (params->focus)
954 upper_color = colors->base[params->state_type];
955 else
956 upper_color = colors->base[GTK_STATE_ACTIVE];
958 ge_shade_color(&upper_color, 0.9, &lower_color);
960 pattern = cairo_pattern_create_linear (0, 0, 0, height);
961 cairo_pattern_add_color_stop_rgb (pattern, 0.0, lower_color.r,
962 lower_color.g,
963 lower_color.b);
964 cairo_pattern_add_color_stop_rgb (pattern, 1.0, upper_color.r,
965 upper_color.g,
966 upper_color.b);
969 cairo_set_source (cr, pattern);
970 cairo_rectangle (cr, 0, 0, width, height);
971 cairo_fill (cr);
972 cairo_pattern_destroy (pattern);
974 ge_shade_color(&upper_color, 0.8, &border);
976 cairo_move_to (cr, 0, 0.5);
977 cairo_rel_line_to (cr, width, 0);
978 cairo_move_to (cr, 0, height-0.5);
979 cairo_rel_line_to (cr, width, 0);
981 ge_cairo_set_color (cr, &border);
982 cairo_stroke (cr);
984 cairo_restore (cr);
987 void
988 clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions)
990 functions->draw_button = clearlooks_inverted_draw_button;
991 functions->draw_slider = clearlooks_inverted_draw_slider;
992 functions->draw_slider_button = clearlooks_inverted_draw_slider_button;
993 functions->draw_progressbar_fill = clearlooks_inverted_draw_progressbar_fill;
994 functions->draw_menuitem = clearlooks_inverted_draw_menuitem;
995 functions->draw_menubaritem = clearlooks_inverted_draw_menubaritem;
996 functions->draw_tab = clearlooks_inverted_draw_tab;
997 functions->draw_list_view_header = clearlooks_inverted_draw_list_view_header;
998 functions->draw_scrollbar_stepper = clearlooks_inverted_draw_scrollbar_stepper;
999 functions->draw_scrollbar_slider = clearlooks_inverted_draw_scrollbar_slider;
1000 functions->draw_selected_cell = clearlooks_inverted_draw_selected_cell;