1 /* Clearlooks Glossy style
2 * Copyright (C) 2006 Benjamin Berg
3 * Copyright (C) 2007 Andrea Cimitan
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Written by Andrea Cimitan <andrea.cimitan@gmail.com>
21 * and Benjamin Berg <benjamin@sipsolutions.net>
22 * Based on code by Richard Stellingwerff <remenic@gmail.com>
23 * and Daniel Borgmann <daniel.borgmann@gmail.com>
24 * from the ubuntulooks engine.
27 #include "clearlooks_draw.h"
28 #include "clearlooks_style.h"
29 #include "clearlooks_types.h"
32 #include <ge-support.h>
37 #define M_PI 3.14159265358979323846
41 clearlooks_draw_glossy_gradient (cairo_t
*cr
,
42 double x
, double y
, int width
, int height
,
43 const CairoColor
*color
,
44 gboolean disabled
, gboolean radius
, CairoCorners corners
)
46 CairoColor a
, b
, c
, d
;
49 ge_shade_color (color
, disabled
? 1.06 : 1.16, &a
);
50 ge_shade_color (color
, disabled
? 1.02 : 1.08, &b
);
51 ge_shade_color (color
, disabled
? 0.98 : 1.00, &c
);
52 ge_shade_color (color
, disabled
? 1.02 : 1.08, &d
);
54 pt
= cairo_pattern_create_linear (x
, y
, x
, y
+height
);
55 cairo_pattern_add_color_stop_rgb (pt
, 0.0, a
.r
, a
.g
, a
.b
);
56 cairo_pattern_add_color_stop_rgb (pt
, 0.5, b
.r
, b
.g
, b
.b
);
57 cairo_pattern_add_color_stop_rgb (pt
, 0.5, c
.r
, c
.g
, c
.b
);
58 cairo_pattern_add_color_stop_rgb (pt
, 1.0, d
.r
, d
.g
, d
.b
);
60 cairo_set_source (cr
, pt
);
61 ge_cairo_rounded_rectangle (cr
, x
, y
, width
, height
, radius
, corners
);
64 cairo_pattern_destroy (pt
);
68 clearlooks_set_mixed_color (cairo_t
*cr
,
69 const CairoColor
*color1
,
70 const CairoColor
*color2
,
75 ge_mix_color (color1
, color2
, mix_factor
, &composite
);
76 ge_cairo_set_color (cr
, &composite
);
80 clearlooks_glossy_draw_inset (cairo_t
*cr
,
81 const CairoColor
*bg_color
,
82 double x
, double y
, double w
, double h
,
83 double radius
, uint8 corners
)
88 /* not really sure of shading ratios... we will think */
89 ge_shade_color (bg_color
, 0.93, &shadow
);
90 ge_shade_color (bg_color
, 1.07, &highlight
);
93 cairo_move_to (cr
, x
+ w
+ (radius
* -0.2928932188), y
- (radius
* -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
95 if (corners
& CR_CORNER_TOPRIGHT
)
96 cairo_arc (cr
, x
+ w
- radius
, y
+ radius
, radius
, G_PI
* 1.75, G_PI
* 2);
98 cairo_line_to (cr
, x
+ w
, y
);
100 if (corners
& CR_CORNER_BOTTOMRIGHT
)
101 cairo_arc (cr
, x
+ w
- radius
, y
+ h
- radius
, radius
, 0, G_PI
* 0.5);
103 cairo_line_to (cr
, x
+ w
, y
+ h
);
105 if (corners
& CR_CORNER_BOTTOMLEFT
)
106 cairo_arc (cr
, x
+ radius
, y
+ h
- radius
, radius
, G_PI
* 0.5, G_PI
* 0.75);
108 cairo_line_to (cr
, x
, y
+ h
);
110 ge_cairo_set_color (cr
, &highlight
);
114 cairo_move_to (cr
, x
+ (radius
* 0.2928932188), y
+ h
+ (radius
* -0.2928932188));
116 if (corners
& CR_CORNER_BOTTOMLEFT
)
117 cairo_arc (cr
, x
+ radius
, y
+ h
- radius
, radius
, M_PI
* 0.75, M_PI
);
119 cairo_line_to (cr
, x
, y
+ h
);
121 if (corners
& CR_CORNER_TOPLEFT
)
122 cairo_arc (cr
, x
+ radius
, y
+ radius
, radius
, M_PI
, M_PI
* 1.5);
124 cairo_line_to (cr
, x
, y
);
126 if (corners
& CR_CORNER_TOPRIGHT
)
127 cairo_arc (cr
, x
+ w
- radius
, y
+ radius
, radius
, M_PI
* 1.5, M_PI
* 1.75);
129 cairo_line_to (cr
, x
+ w
, y
);
131 ge_cairo_set_color (cr
, &shadow
);
136 clearlooks_glossy_draw_light_inset (cairo_t
*cr
,
137 const CairoColor
*bg_color
,
138 double x
, double y
, double w
, double h
,
139 double radius
, uint8 corners
)
142 CairoColor highlight
;
144 /* not really sure of shading ratios... we will think */
145 ge_shade_color (bg_color
, 0.95, &shadow
);
146 ge_shade_color (bg_color
, 1.05, &highlight
);
149 cairo_move_to (cr
, x
+ w
+ (radius
* -0.2928932188), y
- (radius
* -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
151 if (corners
& CR_CORNER_TOPRIGHT
)
152 cairo_arc (cr
, x
+ w
- radius
, y
+ radius
, radius
, G_PI
* 1.75, G_PI
* 2);
154 cairo_line_to (cr
, x
+ w
, y
);
156 if (corners
& CR_CORNER_BOTTOMRIGHT
)
157 cairo_arc (cr
, x
+ w
- radius
, y
+ h
- radius
, radius
, 0, G_PI
* 0.5);
159 cairo_line_to (cr
, x
+ w
, y
+ h
);
161 if (corners
& CR_CORNER_BOTTOMLEFT
)
162 cairo_arc (cr
, x
+ radius
, y
+ h
- radius
, radius
, G_PI
* 0.5, G_PI
* 0.75);
164 cairo_line_to (cr
, x
, y
+ h
);
166 ge_cairo_set_color (cr
, &highlight
);
170 cairo_move_to (cr
, x
+ (radius
* 0.2928932188), y
+ h
+ (radius
* -0.2928932188));
172 if (corners
& CR_CORNER_BOTTOMLEFT
)
173 cairo_arc (cr
, x
+ radius
, y
+ h
- radius
, radius
, M_PI
* 0.75, M_PI
);
175 cairo_line_to (cr
, x
, y
+ h
);
177 if (corners
& CR_CORNER_TOPLEFT
)
178 cairo_arc (cr
, x
+ radius
, y
+ radius
, radius
, M_PI
, M_PI
* 1.5);
180 cairo_line_to (cr
, x
, y
);
182 if (corners
& CR_CORNER_TOPRIGHT
)
183 cairo_arc (cr
, x
+ w
- radius
, y
+ radius
, radius
, M_PI
* 1.5, M_PI
* 1.75);
185 cairo_line_to (cr
, x
+ w
, y
);
187 ge_cairo_set_color (cr
, &shadow
);
192 clearlooks_glossy_draw_highlight_and_shade (cairo_t
*cr
,
193 const CairoColor
*bg_color
,
194 const ShadowParameters
*params
,
195 int width
, int height
, gdouble radius
)
198 CairoColor highlight
;
199 uint8 corners
= params
->corners
;
203 /* not really sure of shading ratios... we will think */
204 ge_shade_color (bg_color
, 0.8, &shadow
);
205 ge_shade_color (bg_color
, 1.2, &highlight
);
209 /* Top/Left highlight */
210 if (corners
& CR_CORNER_BOTTOMLEFT
)
211 cairo_move_to (cr
, x
, y
+height
-radius
);
213 cairo_move_to (cr
, x
, y
+height
);
215 ge_cairo_rounded_corner (cr
, x
, y
, radius
, corners
& CR_CORNER_TOPLEFT
);
217 if (corners
& CR_CORNER_TOPRIGHT
)
218 cairo_line_to (cr
, x
+width
-radius
, y
);
220 cairo_line_to (cr
, x
+width
, y
);
222 if (params
->shadow
& CL_SHADOW_OUT
)
223 cairo_set_source_rgba (cr
, highlight
.r
, highlight
.g
, highlight
.b
, 0.5);
225 cairo_set_source_rgba (cr
, shadow
.r
, shadow
.g
, shadow
.b
, 0.5);
229 /* Bottom/Right highlight -- this includes the corners */
230 cairo_move_to (cr
, x
+width
-radius
, y
); /* topright and by radius to the left */
231 ge_cairo_rounded_corner (cr
, x
+width
, y
, radius
, corners
& CR_CORNER_TOPRIGHT
);
232 ge_cairo_rounded_corner (cr
, x
+width
, y
+height
, radius
, corners
& CR_CORNER_BOTTOMRIGHT
);
233 ge_cairo_rounded_corner (cr
, x
, y
+height
, radius
, corners
& CR_CORNER_BOTTOMLEFT
);
235 if (params
->shadow
& CL_SHADOW_OUT
)
236 cairo_set_source_rgba (cr
, shadow
.r
, shadow
.g
, shadow
.b
, 0.5);
238 cairo_set_source_rgba (cr
, highlight
.r
, highlight
.g
, highlight
.b
, 0.5);
246 clearlooks_glossy_draw_button (cairo_t
*cr
,
247 const ClearlooksColors
*colors
,
248 const WidgetParameters
*params
,
249 int x
, int y
, int width
, int height
)
251 double xoffset
= 0, yoffset
= 0;
252 CairoColor fill
= colors
->bg
[params
->state_type
];
253 CairoColor border_normal
= colors
->shade
[6];
254 CairoColor border_disabled
= colors
->shade
[4];
257 cairo_pattern_t
*pattern
;
260 cairo_translate (cr
, x
, y
);
261 cairo_set_line_width (cr
, 1.0);
263 /* Shadows and Glow */
264 if (params
->xthickness
== 3 || params
->ythickness
== 3)
266 if (params
->xthickness
== 3)
268 if (params
->ythickness
== 3)
272 radius
= MIN (params
->radius
, MIN ((width
- 2.0 - 2*xoffset
) / 2.0, (height
- 2.0 - 2*yoffset
) / 2.0));
274 if (params
->xthickness
== 3 || params
->ythickness
== 3)
276 cairo_translate (cr
, 0.5, 0.5);
278 /* if (params->enable_glow && !params->active && !params->disabled) */
279 if (params
->prelight
&& params
->enable_glow
&& !params
->active
)
281 /* Glow becomes a shadow to have 3d prelight buttons :) */
284 radius
= MIN (params
->radius
, MIN ((width
- 2.0 - 2*xoffset
) / 2.0 - 1.0, (height
- 2.0 - 2*yoffset
) / 2.0 - 1.0));
286 ge_cairo_rounded_rectangle (cr
, 0, 0, width
-1, height
-1, radius
+1, params
->corners
);
287 ge_shade_color (¶ms
->parentbg
, 0.96, &glow
);
288 ge_cairo_set_color (cr
, &glow
);
291 ge_cairo_rounded_rectangle (cr
, 1, 1, width
-2, height
-2, radius
+1, params
->corners
);
292 ge_shade_color (¶ms
->parentbg
, 0.92, &glow
);
293 ge_cairo_set_color (cr
, &glow
);
297 /* if (!(params->enable_glow && !params->active && !params->disabled)) */
298 if (!(params
->prelight
&& params
->enable_glow
&& !params
->active
)) {
299 if (!(params
->disabled
))
300 params
->style_functions
->draw_inset (cr
, ¶ms
->parentbg
, 0, 0, width
-1, height
-1, params
->radius
+1, params
->corners
);
302 /*Draw a lighter inset */
303 clearlooks_glossy_draw_light_inset (cr
, ¶ms
->parentbg
, 0, 0, width
-1, height
-1, params
->radius
+1, params
->corners
);
305 cairo_translate (cr
, -0.5, -0.5);
308 clearlooks_draw_glossy_gradient (cr
, xoffset
+1, yoffset
+1,
309 width
-(xoffset
*2)-2, height
-(yoffset
*2)-2,
310 &fill
, params
->disabled
, radius
, params
->corners
);
312 /* Pressed button shadow */
316 ge_shade_color (&fill
, 0.92, &shadow
);
320 ge_cairo_rounded_rectangle (cr
, xoffset
+1, yoffset
+1, width
-(xoffset
*2)-2, height
, radius
, params
->corners
& (CR_CORNER_TOPLEFT
| CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMLEFT
));
322 cairo_rectangle (cr
, xoffset
+1, yoffset
+1, width
-(xoffset
*2)-2, 3);
324 pattern
= cairo_pattern_create_linear (xoffset
+1, yoffset
+1, xoffset
+1, yoffset
+4);
325 cairo_pattern_add_color_stop_rgba (pattern
, 0.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.58);
326 cairo_pattern_add_color_stop_rgba (pattern
, 1.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.0);
327 cairo_set_source (cr
, pattern
);
329 cairo_pattern_destroy (pattern
);
331 cairo_rectangle (cr
, xoffset
+1, yoffset
+1, 3, height
-(yoffset
*2)-2);
333 pattern
= cairo_pattern_create_linear (xoffset
+1, yoffset
+1, xoffset
+4, yoffset
+1);
334 cairo_pattern_add_color_stop_rgba (pattern
, 0.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.58);
335 cairo_pattern_add_color_stop_rgba (pattern
, 1.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.0);
336 cairo_set_source (cr
, pattern
);
338 cairo_pattern_destroy (pattern
);
343 /* Default button highlight */
344 if (params
->is_default
&& !params
->active
&& !params
->disabled
)
346 const CairoColor
*glow
= &colors
->spot
[0];
347 double hh
= (height
-5)/2.0 + 1;
349 cairo_rectangle (cr
, 3.5, 3.5, width
-7, height
-7);
350 ge_cairo_set_color (cr
, glow
);
353 glow
= &colors
->spot
[0];
354 cairo_move_to (cr
, 2.5, 2.5+hh
); cairo_rel_line_to (cr
, 0, -hh
);
355 cairo_rel_line_to (cr
, width
-5, 0); cairo_rel_line_to (cr
, 0, hh
);
356 ge_cairo_set_color (cr
, glow
);
361 glow
= &colors
->spot
[1];
362 cairo_move_to (cr
, 2.5, 2.5+hh
); cairo_rel_line_to (cr
, 0, hh
);
363 cairo_rel_line_to (cr
, width
-5, 0); cairo_rel_line_to (cr
, 0, -hh
);
364 ge_cairo_set_color (cr
, glow
);
369 if (params
->is_default
|| (params
->prelight
&& params
->enable_glow
))
370 border_normal
= colors
->spot
[2];
371 /* ge_mix_color (&border_normal, &colors->spot[2], 0.5, &border_normal); */
372 if (params
->disabled
)
373 ge_cairo_set_color (cr
, &border_disabled
);
375 clearlooks_set_mixed_color (cr
, &border_normal
, &fill
, 0.2);
376 ge_cairo_rounded_rectangle (cr
, xoffset
+ 0.5, yoffset
+ 0.5,
377 width
-(xoffset
*2)-1, height
-(yoffset
*2)-1,
378 radius
, params
->corners
);
384 clearlooks_glossy_draw_progressbar_trough (cairo_t
*cr
,
385 const ClearlooksColors
*colors
,
386 const WidgetParameters
*params
,
387 int x
, int y
, int width
, int height
)
389 const CairoColor
*border
= &colors
->shade
[6];
391 cairo_pattern_t
*pattern
;
392 double radius
= MIN (params
->radius
, MIN ((height
-2.0) / 2.0, (width
-2.0) / 2.0));
396 cairo_set_line_width (cr
, 1.0);
398 /* Fill with bg color */
399 ge_cairo_set_color (cr
, &colors
->bg
[params
->state_type
]);
401 cairo_rectangle (cr
, x
, y
, width
, height
);
404 /* Create trough box */
405 ge_cairo_rounded_rectangle (cr
, x
+1, y
+1, width
-2, height
-2, radius
, params
->corners
);
406 ge_cairo_set_color (cr
, &colors
->shade
[2]);
410 ge_cairo_rounded_rectangle (cr
, x
+0.5, y
+0.5, width
-1, height
-1, radius
, params
->corners
);
411 clearlooks_set_mixed_color (cr
, border
, &colors
->shade
[2], 0.3);
414 /* clip the corners of the shadows */
415 ge_cairo_rounded_rectangle (cr
, x
+1, y
+1, width
-2, height
-2, radius
, params
->corners
);
418 ge_shade_color (border
, 0.92, &shadow
);
421 cairo_rectangle (cr
, x
+1, y
+1, width
-2, 4);
422 pattern
= cairo_pattern_create_linear (x
, y
, x
, y
+4);
423 cairo_pattern_add_color_stop_rgba (pattern
, 0.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.3);
424 cairo_pattern_add_color_stop_rgba (pattern
, 1.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.);
425 cairo_set_source (cr
, pattern
);
427 cairo_pattern_destroy (pattern
);
430 cairo_rectangle (cr
, x
+1, y
+1, 4, height
-2);
431 pattern
= cairo_pattern_create_linear (x
, y
, x
+4, y
);
432 cairo_pattern_add_color_stop_rgba (pattern
, 0.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.3);
433 cairo_pattern_add_color_stop_rgba (pattern
, 1.0, shadow
.r
, shadow
.g
, shadow
.b
, 0.);
434 cairo_set_source (cr
, pattern
);
436 cairo_pattern_destroy (pattern
);
442 clearlooks_glossy_draw_progressbar_fill (cairo_t
*cr
,
443 const ClearlooksColors
*colors
,
444 const WidgetParameters
*params
,
445 const ProgressBarParameters
*progressbar
,
446 int x
, int y
, int width
, int height
,
449 boolean is_horizontal
= progressbar
->orientation
< 2;
455 cairo_pattern_t
*pattern
;
462 radius
= MAX (0, params
->radius
- params
->xthickness
);
467 ge_cairo_exchange_axis (cr
, &x
, &y
, &width
, &height
);
469 if ((progressbar
->orientation
== CL_ORIENTATION_RIGHT_TO_LEFT
) || (progressbar
->orientation
== CL_ORIENTATION_BOTTOM_TO_TOP
))
470 ge_cairo_mirror (cr
, CR_MIRROR_HORIZONTAL
, &x
, &y
, &width
, &height
);
472 /* Clamp the radius so that the _height_ fits ... */
473 radius
= MIN (radius
, height
/ 2.0);
475 stroke_width
= height
*2;
476 x_step
= (((float)stroke_width
/10)*offset
); /* This looks weird ... */
478 cairo_translate (cr
, x
, y
);
481 /* This is kind of nasty ... Clip twice from each side in case the length
482 * of the fill is smaller than twice the radius. */
483 ge_cairo_rounded_rectangle (cr
, 0, 0, width
+ radius
, height
, radius
, CR_CORNER_TOPLEFT
| CR_CORNER_BOTTOMLEFT
);
485 ge_cairo_rounded_rectangle (cr
, -radius
, 0, width
+ radius
, height
, radius
, CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMRIGHT
);
488 /* Draw the background gradient */
489 ge_shade_color (&colors
->spot
[1], 1.16, &a
);
490 ge_shade_color (&colors
->spot
[1], 1.08, &b
);
491 ge_shade_color (&colors
->spot
[1], 1.08, &e
);
492 pattern
= cairo_pattern_create_linear (0, 0, 0, height
);
493 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, a
.r
, a
.g
, a
.b
);
494 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, b
.r
, b
.g
, b
.b
);
495 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, colors
->spot
[1].r
, colors
->spot
[1].g
, colors
->spot
[1].b
);
496 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, e
.r
, e
.g
, e
.b
);
497 cairo_set_source (cr
, pattern
);
499 cairo_pattern_destroy (pattern
);
501 /* Draw the Strokes */
502 while (tile_pos
<= width
+x_step
)
504 cairo_move_to (cr
, stroke_width
/2-x_step
, 0);
505 cairo_line_to (cr
, stroke_width
-x_step
, 0);
506 cairo_line_to (cr
, stroke_width
/2-x_step
, height
);
507 cairo_line_to (cr
, -x_step
, height
);
509 cairo_translate (cr
, stroke_width
, 0);
510 tile_pos
+= stroke_width
;
513 cairo_set_source_rgba (cr
, colors
->spot
[2].r
,
519 cairo_restore (cr
); /* rounded clip region */
521 /* inner highlight border
522 * This is again kinda ugly. Draw once from each side, clipping away the other. */
523 cairo_set_source_rgba (cr
, colors
->spot
[0].r
, colors
->spot
[0].g
, colors
->spot
[0].b
, 0.3);
527 cairo_rectangle (cr
, 0, 0, width
/ 2, height
);
530 if (progressbar
->pulsing
)
531 ge_cairo_rounded_rectangle (cr
, 1.5, 0.5, width
+ radius
, height
- 1, radius
, CR_CORNER_TOPLEFT
| CR_CORNER_BOTTOMLEFT
);
533 ge_cairo_rounded_rectangle (cr
, 0.5, 0.5, width
+ radius
, height
- 1, radius
, CR_CORNER_TOPLEFT
| CR_CORNER_BOTTOMLEFT
);
536 cairo_restore (cr
); /* clip */
540 cairo_rectangle (cr
, width
/ 2, 0, (width
+1) / 2, height
);
543 if (progressbar
->value
< 1.0 || progressbar
->pulsing
)
544 ge_cairo_rounded_rectangle (cr
, -1.5 - radius
, 0.5, width
+ radius
, height
- 1, radius
, CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMRIGHT
);
546 ge_cairo_rounded_rectangle (cr
, -0.5 - radius
, 0.5, width
+ radius
, height
- 1, radius
, CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMRIGHT
);
549 cairo_restore (cr
); /* clip */
552 /* Draw the dark lines and the shadow */
554 /* Again, this weird clip area. */
555 ge_cairo_rounded_rectangle (cr
, -1.0, 0, width
+ radius
+ 2.0, height
, radius
, CR_CORNER_TOPLEFT
| CR_CORNER_BOTTOMLEFT
);
557 ge_cairo_rounded_rectangle (cr
, -radius
- 1.0, 0, width
+ radius
+ 2.0, height
, radius
, CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMRIGHT
);
560 border
= colors
->spot
[2];
562 ge_shade_color (&colors
->shade
[6], 0.92, &shadow
);
565 if (progressbar
->pulsing
)
567 /* At the beginning of the bar. */
568 cairo_move_to (cr
, 0.5 + radius
, height
+ 0.5);
569 ge_cairo_rounded_corner (cr
, 0.5, height
+ 0.5, radius
+ 1, CR_CORNER_BOTTOMLEFT
);
570 ge_cairo_rounded_corner (cr
, 0.5, -0.5, radius
+ 1, CR_CORNER_TOPLEFT
);
571 ge_cairo_set_color (cr
, &border
);
574 cairo_move_to (cr
, -0.5 + radius
, height
+ 0.5);
575 ge_cairo_rounded_corner (cr
, -0.5, height
+ 0.5, radius
+ 1, CR_CORNER_BOTTOMLEFT
);
576 ge_cairo_rounded_corner (cr
, -0.5, -0.5, radius
+ 1, CR_CORNER_TOPLEFT
);
577 ge_cairo_set_color (cr
, &shadow
);
580 if (progressbar
->value
< 1.0 || progressbar
->pulsing
)
582 /* At the end of the bar. */
583 cairo_move_to (cr
, width
- 0.5 - radius
, -0.5);
584 ge_cairo_rounded_corner (cr
, width
- 0.5, -0.5, radius
+ 1, CR_CORNER_TOPRIGHT
);
585 ge_cairo_rounded_corner (cr
, width
- 0.5, height
+ 0.5, radius
+ 1, CR_CORNER_BOTTOMRIGHT
);
586 ge_cairo_set_color (cr
, &border
);
589 cairo_move_to (cr
, width
+ 0.5 - radius
, -0.5);
590 ge_cairo_rounded_corner (cr
, width
+ 0.5, -0.5, radius
+ 1, CR_CORNER_TOPRIGHT
);
591 ge_cairo_rounded_corner (cr
, width
+ 0.5, height
+ 0.5, radius
+ 1, CR_CORNER_BOTTOMRIGHT
);
592 ge_cairo_set_color (cr
, &shadow
);
598 cairo_restore (cr
); /* rotation, mirroring */
602 clearlooks_glossy_scale_draw_gradient (cairo_t
*cr
,
603 const CairoColor
*c1
,
604 const CairoColor
*c2
,
605 const CairoColor
*c3
,
606 int x
, int y
, int width
, int height
,
609 cairo_pattern_t
*pattern
;
611 pattern
= cairo_pattern_create_linear (0, 0, horizontal
? 0 : width
, horizontal
? height
: 0);
612 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, c1
->r
, c1
->g
, c1
->b
);
613 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, c2
->r
, c2
->g
, c2
->b
);
615 cairo_rectangle (cr
, x
+0.5, y
+0.5, width
-1, height
-1);
616 cairo_set_source (cr
, pattern
);
618 cairo_pattern_destroy (pattern
);
620 clearlooks_set_mixed_color (cr
, c3
, c1
, 0.3);
621 ge_cairo_stroke_rectangle (cr
, x
, y
, width
, height
);
624 #define TROUGH_SIZE 6
626 clearlooks_glossy_draw_scale_trough (cairo_t
*cr
,
627 const ClearlooksColors
*colors
,
628 const WidgetParameters
*params
,
629 const SliderParameters
*slider
,
630 int x
, int y
, int width
, int height
)
632 int trough_width
, trough_height
;
633 double translate_x
, translate_y
;
635 if (slider
->horizontal
)
637 trough_width
= width
-3;
638 trough_height
= TROUGH_SIZE
-2;
640 translate_x
= x
+ 0.5;
641 translate_y
= y
+ 0.5 + (height
/2) - (TROUGH_SIZE
/2);
645 trough_width
= TROUGH_SIZE
-2;
646 trough_height
= height
-3;
648 translate_x
= x
+ 0.5 + (width
/2) - (TROUGH_SIZE
/2);
649 translate_y
= y
+ 0.5;
652 cairo_set_line_width (cr
, 1.0);
653 cairo_translate (cr
, translate_x
, translate_y
);
655 if (!slider
->fill_level
)
656 params
->style_functions
->draw_inset (cr
, ¶ms
->parentbg
, 0, 0, trough_width
+2, trough_height
+2, 0, 0);
658 cairo_translate (cr
, 1, 1);
660 if (!slider
->lower
&& !slider
->fill_level
)
661 clearlooks_glossy_scale_draw_gradient (cr
, &colors
->shade
[3], /* top */
662 &colors
->shade
[2], /* bottom */
663 &colors
->shade
[6], /* border */
664 0, 0, trough_width
, trough_height
,
667 clearlooks_glossy_scale_draw_gradient (cr
, &colors
->spot
[1], /* top */
668 &colors
->spot
[0], /* bottom */
669 &colors
->spot
[2], /* border */
670 0, 0, trough_width
, trough_height
,
675 clearlooks_glossy_draw_tab (cairo_t
*cr
,
676 const ClearlooksColors
*colors
,
677 const WidgetParameters
*params
,
678 const TabParameters
*tab
,
679 int x
, int y
, int width
, int height
)
682 const CairoColor
*border
= &colors
->shade
[5];
683 const CairoColor
*stripe_fill
= &colors
->spot
[1];
684 const CairoColor
*stripe_border
= &colors
->spot
[2];
685 const CairoColor
*fill
;
688 cairo_pattern_t
*pattern
;
693 radius
= MIN (params
->radius
, MIN ((width
- 2.0) / 2.0, (height
- 2.0) / 2.0));
696 cairo_rectangle (cr
, x
, y
, width
, height
);
700 /* Translate and set line width */
701 cairo_set_line_width (cr
, 1.0);
702 cairo_translate (cr
, x
+0.5, y
+0.5);
705 /* Make the tabs slightly bigger than they should be, to create a gap */
706 /* And calculate the strip size too, while you're at it */
707 if (tab
->gap_side
== CL_GAP_TOP
|| tab
->gap_side
== CL_GAP_BOTTOM
)
710 strip_size
= 2.0/height
; /* 2 pixel high strip */
712 if (tab
->gap_side
== CL_GAP_TOP
)
713 cairo_translate (cr
, 0.0, -3.0); /* gap at the other side */
718 strip_size
= 2.0/width
;
720 if (tab
->gap_side
== CL_GAP_LEFT
)
721 cairo_translate (cr
, -3.0, 0.0); /* gap at the other side */
724 /* Set the fill color */
725 fill
= &colors
->bg
[params
->state_type
];
728 ge_cairo_rounded_rectangle (cr
, 0, 0, width
-1, height
-1,
729 radius
, params
->corners
);
732 ge_cairo_set_color (cr
, fill
);
735 ge_shade_color (fill
, 1.3, &hilight
);
740 ShadowParameters shadow
;
742 shadow
.shadow
= CL_SHADOW_OUT
;
743 shadow
.corners
= params
->corners
;
745 clearlooks_glossy_draw_highlight_and_shade (cr
, &colors
->bg
[0], &shadow
,
752 CairoColor shadow
, hilight
, f1
, f2
;
754 pattern
= cairo_pattern_create_linear (tab
->gap_side
== CL_GAP_LEFT
? width
-1 : 0,
755 tab
->gap_side
== CL_GAP_TOP
? height
-2 : 1,
756 tab
->gap_side
== CL_GAP_RIGHT
? width
: 0,
757 tab
->gap_side
== CL_GAP_BOTTOM
? height
: 0);
759 ge_cairo_rounded_rectangle (cr
, 0, 0, width
-1, height
-1, radius
, params
->corners
);
761 ge_shade_color (fill
, 1.06, &shadow
);
762 ge_shade_color (fill
, 1.18, &hilight
);
763 ge_shade_color (fill
, 1.12, &f1
);
764 ge_shade_color (fill
, 1.06, &f2
);
766 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, hilight
.r
, hilight
.g
, hilight
.b
);
767 cairo_pattern_add_color_stop_rgb (pattern
, 1.0/height
, hilight
.r
, hilight
.g
, hilight
.b
);
768 cairo_pattern_add_color_stop_rgb (pattern
, 1.0/height
, f1
.r
, f1
.g
, f1
.b
);
769 cairo_pattern_add_color_stop_rgb (pattern
, 0.45, f2
.r
, f2
.g
, f2
.b
);
770 cairo_pattern_add_color_stop_rgb (pattern
, 0.45, fill
->r
, fill
->g
, fill
->b
);
771 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, shadow
.r
, shadow
.g
, shadow
.b
);
772 cairo_set_source (cr
, pattern
);
774 cairo_pattern_destroy (pattern
);
779 pattern
= cairo_pattern_create_linear (tab
->gap_side
== CL_GAP_LEFT
? width
-2 : 0,
780 tab
->gap_side
== CL_GAP_TOP
? height
-2 : 0,
781 tab
->gap_side
== CL_GAP_RIGHT
? width
: 0,
782 tab
->gap_side
== CL_GAP_BOTTOM
? height
: 0);
784 ge_cairo_rounded_rectangle (cr
, 0, 0, width
-1, height
-1, radius
, params
->corners
);
787 cairo_pattern_add_color_stop_rgba (pattern
, 0.0, stripe_fill
->r
, stripe_fill
->g
, stripe_fill
->b
, 0.5);
788 cairo_pattern_add_color_stop_rgba (pattern
, 0.8, fill
->r
, fill
->g
, fill
->b
, 0.0);
789 cairo_set_source (cr
, pattern
);
791 cairo_pattern_destroy (pattern
);
794 ge_cairo_rounded_rectangle (cr
, 0, 0, width
-1, height
-1, radius
, params
->corners
);
798 ge_cairo_set_color (cr
, border
);
803 pattern
= cairo_pattern_create_linear (tab
->gap_side
== CL_GAP_LEFT
? width
-2 : 2,
804 tab
->gap_side
== CL_GAP_TOP
? height
-2 : 2,
805 tab
->gap_side
== CL_GAP_RIGHT
? width
: 2,
806 tab
->gap_side
== CL_GAP_BOTTOM
? height
: 2);
808 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, stripe_border
->r
, stripe_border
->g
, stripe_border
->b
);
809 cairo_pattern_add_color_stop_rgb (pattern
, 0.8, border
->r
, border
->g
, border
->b
);
810 cairo_set_source (cr
, pattern
);
812 cairo_pattern_destroy (pattern
);
817 clearlooks_glossy_draw_slider (cairo_t
*cr
,
818 const ClearlooksColors
*colors
,
819 const WidgetParameters
*params
,
820 int x
, int y
, int width
, int height
)
822 const CairoColor
*border
= &colors
->shade
[7];
825 CairoColor a
, b
, c
, d
;
826 cairo_pattern_t
*pattern
;
828 cairo_set_line_width (cr
, 1.0);
829 cairo_translate (cr
, x
, y
);
831 cairo_translate (cr
, -0.5, -0.5);
833 ge_shade_color (&colors
->bg
[params
->state_type
], 1.0, &fill
);
834 if (params
->prelight
)
835 ge_shade_color (&fill
, 1.1, &fill
);
837 ge_shade_color (&fill
, 1.25, &hilight
);
838 ge_shade_color (&fill
, 1.16, &a
);
839 ge_shade_color (&fill
, 1.08, &b
);
840 ge_shade_color (&fill
, 1.0, &c
);
841 ge_shade_color (&fill
, 1.08, &d
);
843 pattern
= cairo_pattern_create_linear (1, 1, 1, height
-2);
844 cairo_pattern_add_color_stop_rgb (pattern
, 0, a
.r
, a
.g
, a
.b
);
845 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, b
.r
, b
.g
, b
.b
);
846 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, c
.r
, c
.g
, c
.b
);
847 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, d
.r
, d
.g
, d
.b
);
848 cairo_rectangle (cr
, 1, 1, width
-2, height
-2);
849 cairo_set_source (cr
, pattern
);
851 cairo_pattern_destroy (pattern
);
853 clearlooks_set_mixed_color (cr
, border
, &fill
, 0.2);
854 if (params
->prelight
)
855 ge_cairo_set_color (cr
, &colors
->spot
[2]);
856 ge_cairo_rounded_rectangle (cr
, 0.5, 0.5, width
-1, height
-1, 2.5, params
->corners
);
859 cairo_set_source_rgba (cr
, hilight
.r
, hilight
.g
, hilight
.b
, 0.5);
860 ge_cairo_rounded_rectangle (cr
, 1.5, 1.5, width
-3, height
-3, 2.0, params
->corners
);
865 clearlooks_glossy_draw_slider_button (cairo_t
*cr
,
866 const ClearlooksColors
*colors
,
867 const WidgetParameters
*params
,
868 const SliderParameters
*slider
,
869 int x
, int y
, int width
, int height
)
871 double radius
= MIN (params
->radius
, MIN ((width
- 1.0) / 2.0, (height
- 1.0) / 2.0));
873 cairo_set_line_width (cr
, 1.0);
875 if (!slider
->horizontal
)
876 ge_cairo_exchange_axis (cr
, &x
, &y
, &width
, &height
);
878 cairo_translate (cr
, x
+0.5, y
+0.5);
880 params
->style_functions
->draw_shadow (cr
, colors
, radius
, width
-1, height
-1);
881 params
->style_functions
->draw_slider (cr
, colors
, params
, 1, 1, width
-2, height
-2);
885 clearlooks_glossy_draw_scrollbar_stepper (cairo_t
*cr
,
886 const ClearlooksColors
*colors
,
887 const WidgetParameters
*widget
,
888 const ScrollBarParameters
*scrollbar
,
889 const ScrollBarStepperParameters
*stepper
,
890 int x
, int y
, int width
, int height
)
892 CairoCorners corners
= CR_CORNER_NONE
;
893 const CairoColor
*border
= &colors
->shade
[7];
894 CairoColor fill
, s1
, s2
, s4
;
895 cairo_pattern_t
*pattern
;
896 ShadowParameters shadow
;
897 double radius
= MIN (widget
->radius
, MIN ((width
- 2.0) / 2.0, (height
- 2.0) / 2.0));
899 if (scrollbar
->horizontal
)
901 if (stepper
->stepper
== CL_STEPPER_A
)
902 corners
= CR_CORNER_TOPLEFT
| CR_CORNER_BOTTOMLEFT
;
903 else if (stepper
->stepper
== CL_STEPPER_D
)
904 corners
= CR_CORNER_TOPRIGHT
| CR_CORNER_BOTTOMRIGHT
;
908 if (stepper
->stepper
== CL_STEPPER_A
)
909 corners
= CR_CORNER_TOPLEFT
| CR_CORNER_TOPRIGHT
;
910 else if (stepper
->stepper
== CL_STEPPER_D
)
911 corners
= CR_CORNER_BOTTOMLEFT
| CR_CORNER_BOTTOMRIGHT
;
914 cairo_translate (cr
, x
, y
);
915 cairo_set_line_width (cr
, 1);
917 ge_cairo_rounded_rectangle (cr
, 1, 1, width
-2, height
-2, radius
, corners
);
919 if (scrollbar
->horizontal
)
920 pattern
= cairo_pattern_create_linear (0, 0, 0, height
);
922 pattern
= cairo_pattern_create_linear (0, 0, width
, 0);
924 fill
= colors
->bg
[widget
->state_type
];
925 ge_shade_color(&fill
, 1.16, &s1
);
926 ge_shade_color(&fill
, 1.08, &s2
);
927 ge_shade_color(&fill
, 1.08, &s4
);
929 cairo_pattern_add_color_stop_rgb(pattern
, 0, s1
.r
, s1
.g
, s1
.b
);
930 cairo_pattern_add_color_stop_rgb(pattern
, 0.5, s2
.r
, s2
.g
, s2
.b
);
931 cairo_pattern_add_color_stop_rgb(pattern
, 0.5, fill
.r
, fill
.g
, fill
.b
);
932 cairo_pattern_add_color_stop_rgb(pattern
, 1.0, s4
.r
, s4
.g
, s4
.b
);
933 cairo_set_source (cr
, pattern
);
935 cairo_pattern_destroy (pattern
);
937 cairo_translate (cr
, 0.5, 0.5);
938 cairo_translate (cr
, -0.5, -0.5);
940 ge_cairo_rounded_rectangle (cr
, 0.5, 0.5, width
-1, height
-1, radius
, corners
);
941 clearlooks_set_mixed_color (cr
, border
, &fill
, 0.2);
942 if (widget
->prelight
)
943 ge_cairo_set_color (cr
, &colors
->spot
[2]);
946 cairo_translate (cr
, 0.5, 0.5);
947 shadow
.shadow
= CL_SHADOW_OUT
;
948 shadow
.corners
= corners
;
952 clearlooks_glossy_draw_scrollbar_slider (cairo_t
*cr
,
953 const ClearlooksColors
*colors
,
954 const WidgetParameters
*widget
,
955 const ScrollBarParameters
*scrollbar
,
956 int x
, int y
, int width
, int height
)
958 const CairoColor
*border
= &colors
->shade
[7];
959 CairoColor fill
= scrollbar
->color
;
961 CairoColor shade1
, shade2
, shade3
;
962 cairo_pattern_t
*pattern
;
964 if (scrollbar
->junction
& CL_JUNCTION_BEGIN
)
966 if (scrollbar
->horizontal
)
977 if (scrollbar
->junction
& CL_JUNCTION_END
)
979 if (scrollbar
->horizontal
)
985 if (!scrollbar
->horizontal
)
986 ge_cairo_exchange_axis (cr
, &x
, &y
, &width
, &height
);
988 cairo_translate (cr
, x
, y
);
990 if (widget
->prelight
)
991 ge_shade_color (&fill
, 1.1, &fill
);
993 cairo_set_line_width (cr
, 1);
995 ge_shade_color (&fill
, 1.25, &hilight
);
996 ge_shade_color (&fill
, 1.16, &shade1
);
997 ge_shade_color (&fill
, 1.08, &shade2
);
998 ge_shade_color (&fill
, 1.08, &shade3
);
1000 pattern
= cairo_pattern_create_linear (1, 1, 1, height
-2);
1001 cairo_pattern_add_color_stop_rgb (pattern
, 0, shade1
.r
, shade1
.g
, shade1
.b
);
1002 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, shade2
.r
, shade2
.g
, shade2
.b
);
1003 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, fill
.r
, fill
.g
, fill
.b
);
1004 cairo_pattern_add_color_stop_rgb (pattern
, 1, shade3
.r
, shade3
.g
, shade3
.b
);
1005 cairo_rectangle (cr
, 1, 1, width
-2, height
-2);
1006 cairo_set_source (cr
, pattern
);
1008 cairo_pattern_destroy (pattern
);
1010 if (scrollbar
->has_color
)
1012 cairo_set_source_rgba (cr
, hilight
.r
, hilight
.g
, hilight
.b
, 0.5);
1013 ge_cairo_stroke_rectangle (cr
, 1.5, 1.5, width
-3, height
-3);
1016 clearlooks_set_mixed_color (cr
, border
, &fill
, scrollbar
->has_color
? 0.4 : 0.2);
1017 ge_cairo_stroke_rectangle (cr
, 0.5, 0.5, width
-1, height
-1);
1021 clearlooks_glossy_draw_list_view_header (cairo_t
*cr
,
1022 const ClearlooksColors
*colors
,
1023 const WidgetParameters
*params
,
1024 const ListViewHeaderParameters
*header
,
1025 int x
, int y
, int width
, int height
)
1028 CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
1030 const CairoColor
*border
= &colors
->shade
[4];
1031 const CairoColor
*fill
= &colors
->bg
[params
->state_type
];
1033 CairoColor shade1
, shade2
, shade3
;
1035 cairo_pattern_t
*pattern
;
1037 ge_shade_color (fill
, 1.2, &hilight
);
1038 ge_shade_color (fill
, 1.08, &shade1
);
1039 ge_shade_color (fill
, 1.04, &shade2
);
1040 ge_shade_color (fill
, 1.04, &shade3
);
1042 cairo_translate (cr
, x
, y
);
1043 cairo_set_line_width (cr
, 1.0);
1046 pattern
= cairo_pattern_create_linear (0, 0, 0, height
);
1047 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, shade1
.r
, shade1
.g
, shade1
.b
);
1048 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, shade2
.r
, shade2
.g
, shade2
.b
);
1049 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, fill
->r
, fill
->g
, fill
->b
);
1050 cairo_pattern_add_color_stop_rgb (pattern
, 1.0-1.0/height
, shade3
.r
, shade3
.g
, shade3
.b
);
1051 cairo_pattern_add_color_stop_rgb (pattern
, 1.0-1.0/height
, border
->r
, border
->g
, border
->b
);
1052 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, border
->r
, border
->g
, border
->b
);
1054 cairo_set_source (cr
, pattern
);
1055 cairo_rectangle (cr
, 0, 0, width
, height
);
1058 cairo_pattern_destroy (pattern
);
1060 /* Draw highlight */
1061 if (header
->order
== CL_ORDER_FIRST
)
1063 cairo_move_to (cr
, 0.5, height
-1);
1064 cairo_line_to (cr
, 0.5, 0.5);
1067 cairo_move_to (cr
, 0.0, 0.5);
1069 cairo_line_to (cr
, width
, 0.5);
1071 cairo_set_source_rgba (cr
, hilight
.r
, hilight
.g
, hilight
.b
, 0.5);
1074 /* Draw resize grip */
1075 if ((params
->ltr
&& header
->order
!= CL_ORDER_LAST
) ||
1076 (!params
->ltr
&& header
->order
!= CL_ORDER_FIRST
) || header
->resizable
)
1078 SeparatorParameters separator
;
1079 separator
.horizontal
= FALSE
;
1082 params
->style_functions
->draw_separator (cr
, colors
, params
, &separator
,
1083 width
-1.5, 4.0, 2, height
-8.0);
1085 params
->style_functions
->draw_separator (cr
, colors
, params
, &separator
,
1086 1.5, 4.0, 2, height
-8.0);
1091 clearlooks_glossy_draw_toolbar (cairo_t
*cr
,
1092 const ClearlooksColors
*colors
,
1093 const WidgetParameters
*widget
,
1094 const ToolbarParameters
*toolbar
,
1095 int x
, int y
, int width
, int height
)
1101 const CairoColor
*fill
= &colors
->bg
[GTK_STATE_NORMAL
];
1102 const CairoColor
*dark
= &colors
->shade
[3];
1104 ge_shade_color (fill
, 1.1, &light
);
1106 cairo_set_line_width (cr
, 1.0);
1107 cairo_translate (cr
, x
, y
);
1109 if (toolbar
->style
== 1) /* Enable Extra features */
1111 cairo_pattern_t
*pattern
;
1112 CairoColor shade1
, shade2
, shade3
;
1114 ge_shade_color (fill
, 1.08, &shade1
);
1115 ge_shade_color (fill
, 1.04, &shade2
);
1116 ge_shade_color (fill
, 1.04, &shade3
);
1119 pattern
= cairo_pattern_create_linear (0, 0, 0, height
);
1120 cairo_pattern_add_color_stop_rgb (pattern
, 0.0, shade1
.r
, shade1
.g
, shade1
.b
);
1121 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, shade2
.r
, shade2
.g
, shade2
.b
);
1122 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, fill
->r
, fill
->g
, fill
->b
);
1123 cairo_pattern_add_color_stop_rgb (pattern
, 1.0, shade3
.r
, shade3
.g
, shade3
.b
);
1125 cairo_set_source (cr
, pattern
);
1126 cairo_rectangle (cr
, 0, 0, width
, height
);
1129 cairo_pattern_destroy (pattern
);
1133 ge_cairo_set_color (cr
, fill
);
1136 if (!toolbar
->topmost
)
1138 /* Draw highlight */
1139 cairo_move_to (cr
, 0, 0.5);
1140 cairo_line_to (cr
, width
-1, 0.5);
1141 ge_cairo_set_color (cr
, &light
);
1147 cairo_move_to (cr
, 0, height
-0.5);
1148 cairo_line_to (cr
, width
-1, height
-0.5);
1149 ge_cairo_set_color (cr
, dark
);
1154 clearlooks_glossy_draw_menuitem (cairo_t
*cr
,
1155 const ClearlooksColors
*colors
,
1156 const WidgetParameters
*params
,
1157 int x
, int y
, int width
, int height
)
1159 const CairoColor
*fill
= &colors
->spot
[1];
1160 const CairoColor
*border
= &colors
->spot
[2];
1161 CairoColor shade1
, shade2
, shade3
;
1162 cairo_pattern_t
*pattern
;
1164 ge_shade_color (fill
, 1.16, &shade1
);
1165 ge_shade_color (fill
, 1.08, &shade2
);
1166 ge_shade_color (fill
, 1.08, &shade3
);
1167 cairo_set_line_width (cr
, 1.0);
1169 ge_cairo_rounded_rectangle (cr
, x
+0.5, y
+0.5, width
- 1, height
- 1, params
->radius
, params
->corners
);
1171 pattern
= cairo_pattern_create_linear (x
, y
, x
, y
+ height
);
1172 cairo_pattern_add_color_stop_rgb (pattern
, 0, shade1
.r
, shade1
.g
, shade1
.b
);
1173 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, shade2
.r
, shade2
.g
, shade2
.b
);
1174 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, fill
->r
, fill
->g
, fill
->b
);
1175 cairo_pattern_add_color_stop_rgb (pattern
, 1, shade3
.r
, shade3
.g
, shade3
.b
);
1177 cairo_set_source (cr
, pattern
);
1178 cairo_fill_preserve (cr
);
1179 cairo_pattern_destroy (pattern
);
1181 ge_cairo_set_color (cr
, border
);
1186 clearlooks_glossy_draw_menubaritem (cairo_t
*cr
,
1187 const ClearlooksColors
*colors
,
1188 const WidgetParameters
*params
,
1189 int x
, int y
, int width
, int height
)
1191 const CairoColor
*fill
= &colors
->spot
[1];
1192 const CairoColor
*border
= &colors
->spot
[2];
1193 CairoColor shade1
, shade2
, shade3
;
1194 cairo_pattern_t
*pattern
;
1196 ge_shade_color (fill
, 1.16, &shade1
);
1197 ge_shade_color (fill
, 1.08, &shade2
);
1198 ge_shade_color (fill
, 1.08, &shade3
);
1199 cairo_set_line_width (cr
, 1.0);
1201 ge_cairo_rounded_rectangle (cr
, x
+0.5, y
+0.5, width
- 1, height
- 1, params
->radius
, params
->corners
);
1203 pattern
= cairo_pattern_create_linear (x
, y
, x
, y
+ height
);
1204 cairo_pattern_add_color_stop_rgb (pattern
, 0, shade1
.r
, shade1
.g
, shade1
.b
);
1205 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, shade2
.r
, shade2
.g
, shade2
.b
);
1206 cairo_pattern_add_color_stop_rgb (pattern
, 0.5, fill
->r
, fill
->g
, fill
->b
);
1207 cairo_pattern_add_color_stop_rgb (pattern
, 1, shade3
.r
, shade3
.g
, shade3
.b
);
1209 cairo_set_source (cr
, pattern
);
1210 cairo_fill_preserve (cr
);
1211 cairo_pattern_destroy (pattern
);
1213 ge_cairo_set_color (cr
, border
);
1218 clearlooks_glossy_draw_selected_cell (cairo_t
*cr
,
1219 const ClearlooksColors
*colors
,
1220 const WidgetParameters
*params
,
1221 int x
, int y
, int width
, int height
)
1226 color
= colors
->base
[params
->state_type
];
1228 color
= colors
->base
[GTK_STATE_ACTIVE
];
1230 clearlooks_draw_glossy_gradient (cr
, x
, y
, width
, height
, &color
, params
->disabled
, 0.0, CR_CORNER_NONE
);
1235 clearlooks_glossy_draw_radiobutton (cairo_t
*cr
,
1236 const ClearlooksColors
*colors
,
1237 const WidgetParameters
*widget
,
1238 const CheckboxParameters
*checkbox
,
1239 int x
, int y
, int width
, int height
)
1244 const CairoColor
*border
;
1245 const CairoColor
*dot
;
1247 CairoColor highlight
;
1248 cairo_pattern_t
*pt
;
1249 gboolean inconsistent
;
1250 gboolean draw_bullet
= (checkbox
->shadow_type
== GTK_SHADOW_IN
);
1252 inconsistent
= (checkbox
->shadow_type
== GTK_SHADOW_ETCHED_IN
);
1253 draw_bullet
|= inconsistent
;
1255 if (widget
->disabled
)
1257 border
= &colors
->shade
[5];
1258 dot
= &colors
->shade
[6];
1262 if (widget
->prelight
)
1263 border
= &colors
->spot
[2];
1265 border
= &colors
->shade
[6];
1266 dot
= &colors
->text
[0];
1269 ge_shade_color (&widget
->parentbg
, 0.9, &shadow
);
1270 ge_shade_color (&widget
->parentbg
, 1.1, &highlight
);
1272 pt
= cairo_pattern_create_linear (0, 0, 13, 13);
1273 cairo_pattern_add_color_stop_rgb (pt
, 0.0, shadow
.r
, shadow
.b
, shadow
.g
);
1274 cairo_pattern_add_color_stop_rgba (pt
, 0.5, shadow
.r
, shadow
.b
, shadow
.g
, 0.5);
1275 cairo_pattern_add_color_stop_rgba (pt
, 0.5, highlight
.r
, highlight
.g
, highlight
.b
, 0.5);
1276 cairo_pattern_add_color_stop_rgb (pt
, 1.0, highlight
.r
, highlight
.g
, highlight
.b
);
1278 cairo_translate (cr
, x
, y
);
1280 cairo_set_line_width (cr
, 2);
1281 cairo_arc (cr
, 7, 7, 6, 0, G_PI
*2);
1282 cairo_set_source (cr
, pt
);
1284 cairo_pattern_destroy (pt
);
1286 cairo_set_line_width (cr
, 1);
1288 cairo_arc (cr
, 7, 7, 5.5, 0, G_PI
*2);
1290 if (!widget
->disabled
)
1292 if (widget
->prelight
)
1293 clearlooks_set_mixed_color (cr
, &colors
->base
[0], &colors
->spot
[1], 0.5);
1295 ge_cairo_set_color (cr
, &colors
->base
[0]);
1296 cairo_fill_preserve (cr
);
1299 ge_cairo_set_color (cr
, border
);
1306 cairo_set_line_cap(cr
, CAIRO_LINE_CAP_ROUND
);
1307 cairo_set_line_width (cr
, 4);
1309 cairo_move_to(cr
, 5, 7);
1310 cairo_line_to(cr
, 9, 7);
1312 ge_cairo_set_color (cr
, dot
);
1317 cairo_arc (cr
, 7, 7, 3, 0, G_PI
*2);
1318 ge_cairo_set_color (cr
, dot
);
1321 cairo_arc (cr
, 6, 6, 1, 0, G_PI
*2);
1322 cairo_set_source_rgba (cr
, highlight
.r
, highlight
.g
, highlight
.b
, 0.5);
1329 clearlooks_glossy_draw_checkbox (cairo_t
*cr
,
1330 const ClearlooksColors
*colors
,
1331 const WidgetParameters
*widget
,
1332 const CheckboxParameters
*checkbox
,
1333 int x
, int y
, int width
, int height
)
1335 const CairoColor
*border
;
1336 const CairoColor
*dot
;
1337 gboolean inconsistent
= FALSE
;
1338 gboolean draw_bullet
= (checkbox
->shadow_type
== GTK_SHADOW_IN
);
1340 inconsistent
= (checkbox
->shadow_type
== GTK_SHADOW_ETCHED_IN
);
1341 draw_bullet
|= inconsistent
;
1343 if (widget
->disabled
)
1345 border
= &colors
->shade
[5];
1346 dot
= &colors
->shade
[6];
1350 if (widget
->prelight
)
1351 border
= &colors
->spot
[2];
1353 border
= &colors
->shade
[6];
1354 dot
= &colors
->text
[GTK_STATE_NORMAL
];
1357 cairo_translate (cr
, x
, y
);
1358 cairo_set_line_width (cr
, 1);
1360 if (widget
->xthickness
> 2 && widget
->ythickness
> 2)
1362 widget
->style_functions
->draw_inset (cr
, &widget
->parentbg
, 0.5, 0.5,
1363 width
-1, height
-1, (widget
->radius
> 0)? 1 : 0, CR_CORNER_ALL
);
1365 /* Draw the rectangle for the checkbox itself */
1366 ge_cairo_rounded_rectangle (cr
, 1.5, 1.5,
1367 width
-3, height
-3, (widget
->radius
> 0)? 1 : 0, CR_CORNER_ALL
);
1371 /* Draw the rectangle for the checkbox itself */
1372 ge_cairo_rounded_rectangle (cr
, 0.5, 0.5,
1373 width
-1, height
-1, (widget
->radius
> 0)? 1 : 0, CR_CORNER_ALL
);
1376 if (!widget
->disabled
)
1378 if (widget
->prelight
)
1379 clearlooks_set_mixed_color (cr
, &colors
->base
[0], &colors
->spot
[1], 0.5);
1381 ge_cairo_set_color (cr
, &colors
->base
[0]);
1382 cairo_fill_preserve (cr
);
1385 ge_cairo_set_color (cr
, border
);
1390 if (inconsistent
) /* Inconsistent */
1392 cairo_set_line_width (cr
, 2.0);
1393 cairo_move_to (cr
, 3, height
*0.5);
1394 cairo_line_to (cr
, width
-3, height
*0.5);
1398 cairo_set_line_width (cr
, 1.7);
1399 cairo_move_to (cr
, 0.5 + (width
*0.2), (height
*0.5));
1400 cairo_line_to (cr
, 0.5 + (width
*0.4), (height
*0.7));
1402 cairo_curve_to (cr
, 0.5 + (width
*0.4), (height
*0.7),
1403 0.5 + (width
*0.5), (height
*0.4),
1404 0.5 + (width
*0.70), (height
*0.25));
1408 ge_cairo_set_color (cr
, dot
);
1414 clearlooks_register_style_glossy (ClearlooksStyleFunctions
*functions
)
1416 functions
->draw_inset
= clearlooks_glossy_draw_inset
;
1417 functions
->draw_button
= clearlooks_glossy_draw_button
;
1418 functions
->draw_progressbar_trough
= clearlooks_glossy_draw_progressbar_trough
;
1419 functions
->draw_progressbar_fill
= clearlooks_glossy_draw_progressbar_fill
;
1420 functions
->draw_scale_trough
= clearlooks_glossy_draw_scale_trough
;
1421 functions
->draw_tab
= clearlooks_glossy_draw_tab
;
1422 functions
->draw_slider
= clearlooks_glossy_draw_slider
;
1423 functions
->draw_slider_button
= clearlooks_glossy_draw_slider_button
;
1424 functions
->draw_scrollbar_stepper
= clearlooks_glossy_draw_scrollbar_stepper
;
1425 functions
->draw_scrollbar_slider
= clearlooks_glossy_draw_scrollbar_slider
;
1426 functions
->draw_list_view_header
= clearlooks_glossy_draw_list_view_header
;
1427 functions
->draw_toolbar
= clearlooks_glossy_draw_toolbar
;
1428 functions
->draw_menuitem
= clearlooks_glossy_draw_menuitem
;
1429 functions
->draw_menubaritem
= clearlooks_glossy_draw_menubaritem
;
1430 functions
->draw_selected_cell
= clearlooks_glossy_draw_selected_cell
;
1431 functions
->draw_checkbox
= clearlooks_glossy_draw_checkbox
;
1432 functions
->draw_radiobutton
= clearlooks_glossy_draw_radiobutton
;