1 /* Murrine theme engine
2 * Copyright (C) 2006-2007-2008-2009 Andrea Cimitan
3 *
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.
8 *
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.
13 *
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.
18 *
19 */
20
21 #include <cairo.h>
22
23 #include "murrine_draw.h"
24 #include "murrine_style.h"
25 #include "murrine_types.h"
26 #include "support.h"
27 #include "cairo-support.h"
28 #include "raico-blur.h"
29
30 static void
murrine_draw_inset(cairo_t * cr,const MurrineRGB * bg_color,double x,double y,double w,double h,double radius,uint8 corners)31 murrine_draw_inset (cairo_t *cr,
32 const MurrineRGB *bg_color,
33 double x, double y, double w, double h,
34 double radius, uint8 corners)
35 {
36 MurrineRGB highlight, shadow;
37 radius = MIN (radius, MIN (w/2.0, h/2.0));
38
39 murrine_shade (bg_color, 1.15, &highlight);
40 murrine_shade (bg_color, 0.4, &shadow);
41
42 /* highlight */
43 cairo_move_to (cr, x+w+(radius*-0.2928932188), y-(radius*-0.2928932188));
44
45 if (corners & MRN_CORNER_TOPRIGHT)
46 cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.75, M_PI*2);
47 else
48 cairo_line_to (cr, x+w, y);
49
50 if (corners & MRN_CORNER_BOTTOMRIGHT)
51 cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI*0.5);
52 else
53 cairo_line_to (cr, x+w, y+h);
54
55 if (corners & MRN_CORNER_BOTTOMLEFT)
56 cairo_arc (cr, x+radius, y+h-radius, radius, M_PI*0.5, M_PI*0.75);
57 else
58 cairo_line_to (cr, x, y+h);
59
60 murrine_set_color_rgba (cr, &highlight, 0.48);
61 cairo_stroke (cr);
62
63 /* shadow */
64 cairo_move_to (cr, x+(radius*0.2928932188), y+h+(radius*-0.2928932188));
65
66 if (corners & MRN_CORNER_BOTTOMLEFT)
67 cairo_arc (cr, x+radius, y+h-radius, radius, M_PI*0.75, M_PI);
68 else
69 cairo_line_to (cr, x, y+h);
70
71 if (corners & MRN_CORNER_TOPLEFT)
72 cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5);
73 else
74 cairo_line_to (cr, x, y);
75
76 if (corners & MRN_CORNER_TOPRIGHT)
77 cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*1.75);
78 else
79 cairo_line_to (cr, x+w, y);
80
81 murrine_set_color_rgba (cr, &shadow, 0.12);
82 cairo_stroke (cr);
83 }
84
85 static void
murrine_draw_highlight_and_shade(cairo_t * cr,const MurrineColors * colors,const ShadowParameters * widget,int width,int height,int radius)86 murrine_draw_highlight_and_shade (cairo_t *cr,
87 const MurrineColors *colors,
88 const ShadowParameters *widget,
89 int width, int height, int radius)
90 {
91 MurrineRGB highlight;
92 MurrineRGB shadow;
93 uint8 corners = widget->corners;
94 double x = 1.0;
95 double y = 1.0;
96 width -= 3;
97 height -= 3;
98 radius = MIN (radius, MIN ((double)width/2.0, (double)height/2.0));
99
100 if (radius < 0)
101 radius = 0;
102
103 murrine_shade (&colors->bg[0], 1.15, &highlight);
104 murrine_shade (&colors->bg[0], 0.4, &shadow);
105
106 cairo_save (cr);
107
108 /* Top/Left highlight */
109 if (corners & MRN_CORNER_BOTTOMLEFT)
110 cairo_move_to (cr, x, y+height-radius);
111 else
112 cairo_move_to (cr, x, y+height);
113
114 murrine_rounded_corner (cr, x, y, radius, corners & MRN_CORNER_TOPLEFT);
115
116 if (corners & MRN_CORNER_TOPRIGHT)
117 cairo_line_to (cr, x+width-radius, y);
118 else
119 cairo_line_to (cr, x+width, y);
120
121 if (widget->shadow & MRN_SHADOW_OUT)
122 murrine_set_color_rgba (cr, &highlight, 0.5);
123 else
124 murrine_set_color_rgba (cr, &shadow, 0.13);
125
126 cairo_stroke (cr);
127
128 /* Bottom/Right highlight -- this includes the corners */
129 cairo_move_to (cr, x+width-radius, y); /* topright and by radius to the left */
130 murrine_rounded_corner (cr, x+width, y, radius, corners & MRN_CORNER_TOPRIGHT);
131 murrine_rounded_corner (cr, x+width, y+height, radius, corners & MRN_CORNER_BOTTOMRIGHT);
132 murrine_rounded_corner (cr, x, y+height, radius, corners & MRN_CORNER_BOTTOMLEFT);
133
134 if (widget->shadow & MRN_SHADOW_OUT)
135 murrine_set_color_rgba (cr, &shadow, 0.13);
136 else
137 murrine_set_color_rgba (cr, &highlight, 0.5);
138
139 cairo_stroke (cr);
140
141 cairo_restore (cr);
142 }
143
144 static void
murrine_rgba_draw_button(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ButtonParameters * button,int x,int y,int width,int height,boolean horizontal)145 murrine_rgba_draw_button (cairo_t *cr,
146 const MurrineColors *colors,
147 const WidgetParameters *widget,
148 const ButtonParameters *button,
149 int x, int y, int width, int height,
150 boolean horizontal)
151 {
152 double os = (widget->xthickness > 2 && widget->ythickness > 2) ? 1.0 : 0.0;
153 double glow_shade_new = widget->glow_shade;
154 double highlight_shade_new = widget->highlight_shade;
155 double lightborder_shade_new = widget->lightborder_shade;
156 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
157 MurrineRGB border;
158 MurrineRGB fill = colors->bg[widget->state_type];
159
160 murrine_get_fill_color (&fill, &mrn_gradient_new);
161
162 if (widget->disabled)
163 {
164 mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
165 mrn_gradient_new.border_shades[0] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[0], 2.0);
166 mrn_gradient_new.border_shades[1] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[1], 2.0);
167 glow_shade_new = murrine_get_decreased_shade (widget->glow_shade, 2.0);
168 highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
169 lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
170 murrine_shade (&fill, murrine_get_contrast(0.5, widget->contrast), &border);
171 }
172 else
173 murrine_shade (&fill, murrine_get_contrast(0.38, widget->contrast), &border);
174
175 /* Default button */
176 if (widget->is_default)
177 {
178 murrine_shade (&border, murrine_get_contrast(0.8, widget->contrast), &border);
179
180 if (button->has_default_button_color)
181 {
182 mrn_gradient_new.has_border_colors = FALSE;
183 mrn_gradient_new.has_gradient_colors = FALSE;
184 murrine_mix_color (&fill, &button->default_button_color, 0.8, &fill);
185 }
186 else
187 murrine_mix_color (&fill, &colors->spot[1], 0.2, &fill);
188
189
190 if (mrn_gradient_new.has_border_colors)
191 {
192 murrine_shade (&mrn_gradient_new.border_colors[0], 0.8, &mrn_gradient_new.border_colors[0]);
193 murrine_shade (&mrn_gradient_new.border_colors[1], 0.8, &mrn_gradient_new.border_colors[1]);
194 }
195 }
196
197 if (!horizontal)
198 murrine_exchange_axis (cr, &x, &y, &width, &height);
199
200 cairo_translate (cr, x, y);
201
202 if (!widget->active && !widget->disabled && widget->reliefstyle > 1 && os > 0.5)
203 {
204 if (widget->reliefstyle == 5)
205 murrine_draw_shadow (cr, &widget->parentbg,
206 0.5, 0.5, width-1, height-1,
207 widget->roundness+1, widget->corners,
208 widget->reliefstyle,
209 mrn_gradient_new, 0.5);
210 else
211 {
212 murrine_draw_shadow (cr, &border,
213 os-0.5, os-0.5, width-(os*2)+1, height-(os*2)+1,
214 widget->roundness+1, widget->corners,
215 widget->reliefstyle,
216 mrn_gradient_new, 0.08);
217 }
218 }
219 else if (widget->reliefstyle != 0 && os > 0.5)
220 {
221 mrn_gradient_new = murrine_get_inverted_border_shades (mrn_gradient_new);
222 murrine_draw_inset (cr, &widget->parentbg, os-0.5, os-0.5,
223 width-(os*2)+1, height-(os*2)+1,
224 widget->roundness+1, widget->corners);
225 }
226
227 murrine_mix_color (&border, &widget->parentbg, 0.2, &border);
228 murrine_mix_color (&border, &fill, 0.25, &border);
229
230 cairo_save (cr);
231
232 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
233
234 murrine_rounded_rectangle_closed (cr, os+1, os+1, width-(os*2)-2, height-(os*2)-2, widget->roundness-1, widget->corners);
235 cairo_clip_preserve (cr);
236
237 murrine_draw_glaze (cr, &fill,
238 glow_shade_new, highlight_shade_new, !widget->active ? lightborder_shade_new : 1.0,
239 mrn_gradient_new, widget,
240 os+1, os+1, width-(os*2)-2, height-(os*2)-2,
241 widget->roundness-1, widget->corners, horizontal);
242
243 cairo_restore (cr);
244
245 /* Draw pressed button shadow */
246 if (widget->active)
247 {
248 cairo_pattern_t *pat;
249 MurrineRGB shadow;
250
251 murrine_shade (&fill, 0.94, &shadow);
252
253 cairo_save (cr);
254
255 murrine_rounded_rectangle_closed (cr, os+1, os+1, width-(os*2)-2, height-(os*2)-2, widget->roundness-1,
256 widget->corners & (MRN_CORNER_TOPLEFT | MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMLEFT));
257 cairo_clip (cr);
258
259 cairo_rectangle (cr, os+1, os+1, width-(os*2)-2, 3);
260 pat = cairo_pattern_create_linear (os+1, os+1, os+1, os+4);
261 murrine_pattern_add_color_stop_rgba (pat, 0.0, &shadow, 0.58);
262 murrine_pattern_add_color_stop_rgba (pat, 1.0, &shadow, 0.0);
263 cairo_set_source (cr, pat);
264 cairo_fill (cr);
265 cairo_pattern_destroy (pat);
266
267 cairo_rectangle (cr, os+1, os+1, 3, height-(os*2)-2);
268 pat = cairo_pattern_create_linear (os+1, os+1, os+4, os+1);
269 murrine_pattern_add_color_stop_rgba (pat, 0.0, &shadow, 0.58);
270 murrine_pattern_add_color_stop_rgba (pat, 1.0, &shadow, 0.0);
271 cairo_set_source (cr, pat);
272 cairo_fill (cr);
273 cairo_pattern_destroy (pat);
274
275 cairo_restore (cr);
276 }
277
278 murrine_draw_border (cr, &border,
279 os+0.5, os+0.5, width-(os*2)-1, height-(os*2)-1,
280 widget->roundness, widget->corners,
281 mrn_gradient_new, 1.0);
282 }
283
284 static void
murrine_rgba_draw_entry(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const FocusParameters * focus,int x,int y,int width,int height)285 murrine_rgba_draw_entry (cairo_t *cr,
286 const MurrineColors *colors,
287 const WidgetParameters *widget,
288 const FocusParameters *focus,
289 int x, int y, int width, int height)
290 {
291 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
292 const MurrineRGB *base = &colors->base[widget->state_type];
293 MurrineRGB border = colors->shade[widget->disabled ? 4 : 5];
294 int radius = CLAMP (widget->roundness, 0, 3);
295
296 murrine_shade (&border, 0.92, &border);
297
298 if (widget->focus)
299 border = focus->color;
300
301 cairo_translate (cr, x+0.5, y+0.5);
302
303 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
304
305 /* Fill the entry's base color */
306 cairo_rectangle (cr, 1.5, 1.5, width-4, height-4);
307 murrine_set_color_rgba (cr, base, ENTRY_OPACITY);
308 cairo_fill (cr);
309
310 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
311
312 if (widget->reliefstyle != 0)
313 murrine_draw_inset (cr, &widget->parentbg, 0, 0, width-1, height-1, radius+1, widget->corners);
314
315 /* Draw the focused border */
316 if (widget->focus)
317 {
318 MurrineRGB focus_shadow;
319 murrine_shade (&border, 1.54, &focus_shadow);
320
321 cairo_rectangle (cr, 2, 2, width-5, height-5);
322 murrine_set_color_rgba (cr, &focus_shadow, 0.5);
323 cairo_stroke(cr);
324 }
325 else if (widget->mrn_gradient.gradients)
326 {
327 MurrineRGB highlight;
328 murrine_shade (base, 1.15, &highlight);
329
330 cairo_move_to (cr, 2, height-3);
331 cairo_line_to (cr, 2, 2);
332 cairo_line_to (cr, width-3, 2);
333
334 murrine_set_color_rgba (cr, &highlight, widget->disabled ? 0.3 : 0.6);
335 cairo_stroke (cr);
336 }
337
338 mrn_gradient_new = murrine_get_inverted_border_shades (mrn_gradient_new);
339
340 /* Draw border */
341 murrine_draw_border (cr, &border,
342 1, 1, width-3, height-3,
343 radius, widget->corners,
344 mrn_gradient_new, 1.0);
345 }
346
347 static void
murrine_scale_draw_gradient(cairo_t * cr,const MurrineRGB * c1,const MurrineRGB * c2,double lightborder_shade,int lightborderstyle,int roundness,uint8 corners,int x,int y,int width,int height,boolean horizontal)348 murrine_scale_draw_gradient (cairo_t *cr,
349 const MurrineRGB *c1,
350 const MurrineRGB *c2,
351 double lightborder_shade,
352 int lightborderstyle,
353 int roundness, uint8 corners,
354 int x, int y, int width, int height,
355 boolean horizontal)
356 {
357 murrine_set_color_rgb (cr, c1);
358 murrine_rounded_rectangle_closed (cr, x, y, width, height, roundness, corners);
359 cairo_fill (cr);
360
361 if (lightborder_shade != 1.0)
362 {
363 cairo_pattern_t *pat;
364 double fill_pos = horizontal ? 1.0-1.0/(double)(height-2) :
365 1.0-1.0/(double)(width-2);
366 MurrineRGB lightborder;
367 murrine_shade (c1, lightborder_shade, &lightborder);
368
369 roundness < 2 ? cairo_rectangle (cr, x, y, width, height) :
370 clearlooks_rounded_rectangle (cr, x+1, y+1, width-2, height-2, roundness-1, corners);
371 pat = cairo_pattern_create_linear (x+1, y+1, horizontal ? x+1 : width+x+1, horizontal ? height+y+1 : y+1);
372
373 murrine_pattern_add_color_stop_rgba (pat, 0.00, &lightborder, 0.75);
374 murrine_pattern_add_color_stop_rgba (pat, fill_pos, &lightborder, 0.75);
375 murrine_pattern_add_color_stop_rgba (pat, fill_pos, &lightborder, 0.0);
376 murrine_pattern_add_color_stop_rgba (pat, 1.00, &lightborder, 0.0);
377
378 cairo_set_source (cr, pat);
379 cairo_pattern_destroy (pat);
380
381 cairo_stroke (cr);
382 }
383
384 murrine_set_color_rgb (cr, c2);
385 murrine_rounded_rectangle (cr, x, y, width, height, roundness, corners);
386 cairo_stroke (cr);
387 }
388
389 static void
murrine_scale_draw_trough(cairo_t * cr,const MurrineRGB * c1,const MurrineRGB * c2,MurrineGradients mrn_gradient,int roundness,uint8 corners,int x,int y,int width,int height,boolean horizontal)390 murrine_scale_draw_trough (cairo_t *cr,
391 const MurrineRGB *c1,
392 const MurrineRGB *c2,
393 MurrineGradients mrn_gradient,
394 int roundness, uint8 corners,
395 int x, int y, int width, int height,
396 boolean horizontal)
397 {
398 murrine_draw_trough (cr, c1, x, y, width, height, roundness, corners, mrn_gradient, 1.0, horizontal);
399 murrine_draw_trough_border (cr, c2, x, y, width, height, roundness, corners, mrn_gradient, 1.0, horizontal);
400 }
401
402 #define TROUGH_SIZE 6
403 static void
murrine_rgba_draw_scale_trough(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const SliderParameters * slider,int x,int y,int width,int height)404 murrine_rgba_draw_scale_trough (cairo_t *cr,
405 const MurrineColors *colors,
406 const WidgetParameters *widget,
407 const SliderParameters *slider,
408 int x, int y, int width, int height)
409 {
410 int trough_width, trough_height;
411 double translate_x, translate_y;
412
413 cairo_save (cr);
414
415 if (slider->horizontal)
416 {
417 trough_width = width;
418 trough_height = TROUGH_SIZE;
419
420 translate_x = x;
421 translate_y = y+(height/2)-(TROUGH_SIZE/2);
422 }
423 else
424 {
425 trough_width = TROUGH_SIZE;
426 trough_height = height;
427
428 translate_x = x+(width/2)-(TROUGH_SIZE/2);
429 translate_y = y;
430 }
431
432 cairo_translate (cr, translate_x+0.5, translate_y+0.5);
433
434 if (!slider->fill_level && widget->reliefstyle != 0)
435 murrine_draw_inset (cr, &widget->parentbg, 0, 0, trough_width, trough_height, widget->roundness, widget->corners);
436
437 if (!slider->lower && !slider->fill_level)
438 {
439 MurrineRGB fill, border;
440 murrine_shade (&colors->bg[GTK_STATE_ACTIVE], 1.0, &fill);
441 murrine_shade (&colors->bg[GTK_STATE_ACTIVE], murrine_get_contrast(0.82, widget->contrast), &border);
442
443 murrine_scale_draw_trough (cr, &fill, &border, widget->mrn_gradient,
444 widget->roundness, widget->corners,
445 1.0, 1.0, trough_width-2, trough_height-2,
446 slider->horizontal);
447 }
448 else
449 {
450 MurrineRGB fill, border;
451 murrine_mix_color (&colors->bg[GTK_STATE_SELECTED], &widget->parentbg, widget->disabled ? 0.25 : 0.0, &fill);
452 murrine_shade (&fill, murrine_get_contrast(0.65, widget->contrast), &border);
453
454 murrine_scale_draw_gradient (cr, &fill, &border,
455 widget->disabled ? 1.0 : widget->lightborder_shade,
456 widget->lightborderstyle,
457 widget->roundness, widget->corners,
458 1.0, 1.0, trough_width-2, trough_height-2,
459 slider->horizontal);
460 }
461
462 cairo_restore (cr);
463 }
464
465 static void
murrine_draw_slider_path(cairo_t * cr,int x,int y,int width,int height,int roundness)466 murrine_draw_slider_path (cairo_t *cr,
467 int x, int y, int width, int height,
468 int roundness)
469 {
470 int radius = MIN (roundness, MIN (width/2.0, height/2.0));
471
472 cairo_move_to (cr, x+radius, y);
473 cairo_arc (cr, x+width-radius, y+radius, radius, M_PI*1.5, M_PI*2);
474 cairo_line_to (cr, x+width, y+height-width/2.0);
475 cairo_line_to (cr, x+width/2.0, y+height);
476 cairo_line_to (cr, x, y+height-width/2.0);
477 cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5);
478 }
479
480 static void
murrine_rgba_draw_slider(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const SliderParameters * slider,int x,int y,int width,int height)481 murrine_rgba_draw_slider (cairo_t *cr,
482 const MurrineColors *colors,
483 const WidgetParameters *widget,
484 const SliderParameters *slider,
485 int x, int y, int width, int height)
486 {
487 int os = (widget->xthickness > 2 && widget->ythickness > 2) ? 1 : 0;
488 double glow_shade_new = widget->glow_shade;
489 double highlight_shade_new = widget->highlight_shade;
490 double lightborder_shade_new = widget->lightborder_shade;
491 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
492 MurrineRGB border;
493 MurrineRGB fill = colors->bg[widget->state_type];
494
495 murrine_get_fill_color (&fill, &mrn_gradient_new);
496
497 if (widget->disabled)
498 {
499 mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
500 mrn_gradient_new.border_shades[0] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[0], 2.0);
501 mrn_gradient_new.border_shades[1] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[1], 2.0);
502 glow_shade_new = murrine_get_decreased_shade (widget->glow_shade, 2.0);
503 highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
504 lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
505 murrine_shade (&fill, murrine_get_contrast(0.5, widget->contrast), &border);
506 }
507 else
508 murrine_shade (&fill, murrine_get_contrast(0.38, widget->contrast), &border);
509
510 if (!slider->horizontal)
511 murrine_exchange_axis (cr, &x, &y, &width, &height);
512
513 cairo_save (cr);
514
515 cairo_translate (cr, x+0.5, y+0.5);
516
517 if (!widget->active && !widget->disabled && widget->reliefstyle > 1 && os > 0)
518 {
519 murrine_draw_slider_path (cr, os-1, os, width-(os*2)+2, height-(os*2)+1, widget->roundness+1);
520 if (widget->reliefstyle == 5)
521 murrine_draw_shadow_from_path (cr, &widget->parentbg,
522 os-1, os, width-(os*2)+2, height-(os*2)+1,
523 widget->reliefstyle,
524 mrn_gradient_new, 0.5);
525 else
526 murrine_draw_shadow_from_path (cr, &border,
527 os-1, os, width-(os*2)+2, height-(os*2)+1,
528 widget->reliefstyle,
529 mrn_gradient_new, 0.08);
530 }
531
532 murrine_mix_color (&border, &widget->parentbg, 0.2, &border);
533 murrine_mix_color (&border, &fill, 0.25, &border);
534
535 cairo_save (cr);
536
537 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
538
539 murrine_draw_slider_path (cr, os, os+1, width-(os*2), height-(os*2)-1, widget->roundness);
540 cairo_clip_preserve (cr);
541
542 murrine_draw_glaze (cr, &fill,
543 glow_shade_new, highlight_shade_new, !widget->active ? lightborder_shade_new : 1.0,
544 mrn_gradient_new, widget,
545 os, os+1, width-(os*2), height-(os*2)-1,
546 widget->roundness, widget->corners, TRUE);
547
548 cairo_restore (cr);
549
550 murrine_draw_slider_path (cr, os, os+1, width-(os*2), height-(os*2)-1, widget->roundness);
551
552 murrine_draw_border_from_path (cr, &border,
553 os, os+1, width-(os*2), height-(os*2)-1,
554 mrn_gradient_new, 1.0);
555
556 cairo_restore (cr);
557
558 if (!slider->horizontal)
559 murrine_exchange_axis (cr, &x, &y, &width, &height);
560 }
561
562 static void
murrine_rgba_draw_spinbutton(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const SpinbuttonParameters * spinbutton,int x,int y,int width,int height,boolean horizontal)563 murrine_rgba_draw_spinbutton (cairo_t *cr,
564 const MurrineColors *colors,
565 const WidgetParameters *widget,
566 const SpinbuttonParameters *spinbutton,
567 int x, int y, int width, int height,
568 boolean horizontal)
569 {
570 ButtonParameters button;
571 button.has_default_button_color = FALSE;
572
573 cairo_save (cr);
574
575 widget->style_functions->draw_button (cr, colors, widget, &button, x, y, width, height, horizontal);
576
577 cairo_restore (cr);
578
579 switch (spinbutton->style)
580 {
581 default:
582 case 0:
583 break;
584 case 1:
585 {
586 MurrineRGB line = colors->shade[!widget->disabled ? 8 : 6];
587 MurrineRGB highlight = colors->bg[widget->state_type];
588 double lightborder_shade_new = widget->lightborder_shade;
589 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
590
591 if (widget->disabled)
592 {
593 lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
594 mrn_gradient_new.border_shades[0] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[0], 2.0);
595 mrn_gradient_new.border_shades[1] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[1], 2.0);
596 }
597 else
598 murrine_shade (&colors->shade[8], 0.95, &line);
599
600 /* adjust line accordingly to buttons */
601 if (widget->mrn_gradient.has_border_colors)
602 murrine_mix_color (&mrn_gradient_new.border_colors[0], &mrn_gradient_new.border_colors[1], 0.5, &line);
603 else
604 {
605 murrine_mix_color (&line, &widget->parentbg, 0.2, &line);
606 if (widget->mrn_gradient.has_gradient_colors)
607 murrine_mix_color (&line, &mrn_gradient_new.gradient_colors[2], 0.4, &line);
608 else
609 murrine_mix_color (&line, &colors->bg[widget->state_type], 0.25, &line);
610 }
611 murrine_shade (&line, (mrn_gradient_new.border_shades[0]+mrn_gradient_new.border_shades[1])/2.0, &line);
612
613 /* adjust highlight accordingly to buttons */
614 if (widget->mrn_gradient.has_gradient_colors)
615 murrine_shade (&mrn_gradient_new.gradient_colors[2], mrn_gradient_new.gradient_shades[2], &highlight);
616 murrine_shade (&highlight, lightborder_shade_new*mrn_gradient_new.gradient_shades[2], &highlight);
617
618 /* this will align the path to the cairo grid */
619 if (height % 2 != 0)
620 height++;
621
622 cairo_move_to (cr, x+2, y+height/2.0-0.5);
623 cairo_line_to (cr, width-3, y+height/2.0-0.5);
624 murrine_set_color_rgb (cr, &line);
625 cairo_stroke (cr);
626
627 cairo_move_to (cr, x+3, y+height/2.0+0.5);
628 cairo_line_to (cr, width-4, y+height/2.0+0.5);
629 murrine_set_color_rgba (cr, &highlight, 0.5);
630 cairo_stroke (cr);
631 break;
632 }
633 }
634 }
635
636 static void
murrine_rgba_draw_progressbar_trough(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ProgressBarParameters * progressbar,int x,int y,int width,int height)637 murrine_rgba_draw_progressbar_trough (cairo_t *cr,
638 const MurrineColors *colors,
639 const WidgetParameters *widget,
640 const ProgressBarParameters *progressbar,
641 int x, int y, int width, int height)
642 {
643 MurrineRGB border, fill;
644 int roundness = MIN (widget->roundness, MIN ((height-2.0)/2.0, (width-2.0)/2.0));
645 boolean horizontal = progressbar->orientation < 2;
646
647 murrine_shade (&colors->bg[GTK_STATE_ACTIVE], 1.0, &fill);
648 murrine_shade (&colors->bg[GTK_STATE_ACTIVE], murrine_get_contrast(0.82, widget->contrast), &border);
649
650 /* Create trough box */
651 murrine_draw_trough (cr, &fill, x+1, y+1, width-2, height-2, roundness-1, widget->corners, widget->mrn_gradient, 0.8, horizontal);
652
653 /* Draw border */
654 murrine_draw_trough_border (cr, &border, x+0.5, y+0.5, width-1, height-1, roundness, widget->corners, widget->mrn_gradient, 0.8, horizontal);
655
656 if (widget->mrn_gradient.gradients &&
657 widget->mrn_gradient.trough_shades[0] == 1.0 &&
658 widget->mrn_gradient.trough_shades[1] == 1.0)
659 {
660 cairo_pattern_t *pat;
661 MurrineRGB shadow;
662
663 murrine_shade (&border, 0.94, &shadow);
664
665 /* clip the corners of the shadows */
666 murrine_rounded_rectangle_closed (cr, x+1, y+1, width-2, height-2, roundness, widget->corners);
667 cairo_clip (cr);
668
669 /* Top shadow */
670 cairo_rectangle (cr, x+1, y+1, width-2, 4);
671 pat = cairo_pattern_create_linear (x, y, x, y+4);
672 murrine_pattern_add_color_stop_rgba (pat, 0.0, &shadow, 0.26);
673 murrine_pattern_add_color_stop_rgba (pat, 1.0, &shadow, 0.0);
674 cairo_set_source (cr, pat);
675 cairo_fill (cr);
676 cairo_pattern_destroy (pat);
677
678 /* Left shadow */
679 cairo_rectangle (cr, x+1, y+1, 4, height-2);
680 pat = cairo_pattern_create_linear (x, y, x+4, y);
681 murrine_pattern_add_color_stop_rgba (pat, 0.0, &shadow, 0.26);
682 murrine_pattern_add_color_stop_rgba (pat, 1.0, &shadow, 0.0);
683 cairo_set_source (cr, pat);
684 cairo_fill (cr);
685 cairo_pattern_destroy (pat);
686 }
687 }
688
689 static void
murrine_rgba_draw_progressbar_fill(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ProgressBarParameters * progressbar,int x,int y,int width,int height,gint offset)690 murrine_rgba_draw_progressbar_fill (cairo_t *cr,
691 const MurrineColors *colors,
692 const WidgetParameters *widget,
693 const ProgressBarParameters *progressbar,
694 int x, int y, int width, int height,
695 gint offset)
696 {
697 double tile_pos = 0;
698 double stroke_width;
699 int x_step;
700 int roundness;
701 MurrineRGB border = colors->spot[2];
702 MurrineRGB effect;
703 MurrineRGB fill = colors->spot[1];
704
705 murrine_get_fill_color (&fill, &widget->mrn_gradient);
706 murrine_shade (&fill, murrine_get_contrast(0.65, widget->contrast), &effect);
707
708 /* progressbar->orientation < 2 == boolean is_horizontal */
709 if (progressbar->orientation < 2)
710 {
711 if (progressbar->orientation == MRN_ORIENTATION_LEFT_TO_RIGHT)
712 rotate_mirror_translate (cr, 0, x, y, FALSE, FALSE);
713 else
714 rotate_mirror_translate (cr, 0, x+width, y, TRUE, FALSE);
715 }
716 else
717 {
718 int tmp = height; height = width; width = tmp;
719
720 x = x+1; y = y-1; width = width+2; height = height-2;
721
722 if (progressbar->orientation == MRN_ORIENTATION_TOP_TO_BOTTOM)
723 rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
724 else
725 rotate_mirror_translate (cr, M_PI/2, x, y+width, TRUE, FALSE);
726 }
727
728 roundness = MIN (widget->roundness-widget->xthickness, height/2.0);
729 int yos = 0;
730 if ((2*roundness > width) && roundness > 0)
731 {
732 int h = height*sin((M_PI*(width))/(4*roundness));
733 roundness = round(width/2.0);
734 yos = 0.5+(height-h)/2.0;
735 height = h;
736 }
737 stroke_width = height*2;
738 x_step = (((float)stroke_width/10)*offset);
739
740 cairo_save (cr);
741
742 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
743
744 murrine_rounded_rectangle_closed (cr, 2, 1+yos, width-4, height-2, roundness-1, widget->corners);
745 cairo_clip (cr);
746
747 cairo_rectangle (cr, 2, 1+yos, width-4, height-2);
748
749 murrine_draw_glaze (cr, &fill,
750 widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
751 widget->mrn_gradient, widget, 2, 1+yos, width-4, height-2,
752 roundness, widget->corners, TRUE);
753
754 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
755
756 switch (progressbar->style)
757 {
758 case 0:
759 break;
760 default:
761 case 1:
762 {
763 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
764
765 /* Draw strokes */
766 while (stroke_width > 0 && tile_pos <= width+x_step)
767 {
768 cairo_move_to (cr, stroke_width/2-x_step, 0);
769 cairo_line_to (cr, stroke_width-x_step, 0);
770 cairo_line_to (cr, stroke_width/2-x_step, height);
771 cairo_line_to (cr, -x_step, height);
772
773 cairo_translate (cr, stroke_width, 0);
774 tile_pos += stroke_width;
775 }
776
777 murrine_set_color_rgba (cr, &effect, 0.15);
778 cairo_fill (cr);
779 break;
780 }
781 case 2:
782 {
783 MurrineRGB highlight;
784 int step = 18;
785 int i;
786
787 murrine_shade (&fill, widget->lightborder_shade*widget->highlight_shade, &highlight);
788
789 for (i=step; i<width-3; i+=step)
790 {
791 cairo_move_to (cr, i-0.5, 1);
792 cairo_line_to (cr, i-0.5, height-1);
793 murrine_set_color_rgba (cr, &highlight, 0.5*widget->mrn_gradient.rgba_opacity);
794 cairo_stroke (cr);
795
796 cairo_move_to (cr, i+0.5, 1);
797 cairo_line_to (cr, i+0.5, height-1);
798 murrine_set_color_rgba (cr, &effect, 0.25);
799 cairo_stroke (cr);
800 }
801 break;
802 }
803 }
804
805 cairo_restore (cr);
806
807 cairo_save (cr);
808
809 murrine_rounded_rectangle_closed (cr, 0.5, -0.5+yos, width-1, height+1, roundness-1, widget->corners);
810 cairo_clip (cr);
811
812 /* Draw border */
813 murrine_mix_color (&border, &fill, 0.28, &border);
814 murrine_draw_border (cr, &border,
815 1.5, 0.5+yos, width-3, height-1,
816 roundness, widget->corners,
817 widget->mrn_gradient, 1.0);
818 cairo_restore (cr);
819 }
820
821 static void
murrine_rgba_draw_menubar(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,int x,int y,int width,int height,int menubarstyle)822 murrine_rgba_draw_menubar (cairo_t *cr,
823 const MurrineColors *colors,
824 const WidgetParameters *widget,
825 int x, int y, int width, int height,
826 int menubarstyle)
827 {
828 const MurrineRGB *fill = &colors->bg[0];
829 MurrineRGB dark = colors->shade[4];
830
831 if(widget->mrn_gradient.has_border_colors)
832 dark = widget->mrn_gradient.border_colors[1];
833
834 cairo_translate (cr, x, y);
835 cairo_rectangle (cr, 0, 0, width, height);
836
837 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
838
839 /* Glass menubar */
840 switch (menubarstyle)
841 {
842 default:
843 case 0:
844 {
845 cairo_pattern_t *pat;
846
847 pat = cairo_pattern_create_linear (0, 0, width, 0);
848 murrine_pattern_add_color_stop_rgba (pat, 0.0, fill, MENUBAR_OPACITY);
849 murrine_pattern_add_color_stop_rgba (pat, 0.5, fill, (MENUBAR_OPACITY-0.04));
850 murrine_pattern_add_color_stop_rgba (pat, 1.0, fill, MENUBAR_OPACITY);
851 cairo_set_source (cr, pat);
852 cairo_rectangle (cr, 0, 0, width, height);
853 cairo_fill (cr);
854 cairo_pattern_destroy (pat);
855
856 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
857 break;
858 }
859 case 1:
860 {
861 /* XXX: should use another gradient rgba_opacity */
862 int os = (widget->glazestyle == 2) ? 1 : 0;
863 murrine_draw_glaze (cr, fill,
864 widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
865 widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
866 widget->roundness, widget->corners, TRUE);
867 break;
868 }
869 case 2:
870 {
871 cairo_pattern_t *pat;
872 MurrineRGB lower;
873 murrine_shade (fill, 0.95, &lower);
874
875 pat = cairo_pattern_create_linear (0, 0, 0, height);
876 murrine_pattern_add_color_stop_rgba (pat, 0.0, fill, MENUBAR_OPACITY);
877 murrine_pattern_add_color_stop_rgba (pat, 1.0, &lower, MENUBAR_OPACITY);
878 cairo_set_source (cr, pat);
879 cairo_fill (cr);
880 cairo_pattern_destroy (pat);
881
882 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
883 break;
884 }
885 case 3:
886 {
887 cairo_pattern_t *pat;
888 MurrineRGB low, top;
889 murrine_shade (fill, 0.9, &top);
890 murrine_shade (fill, 1.1, &low);
891 pat = cairo_pattern_create_linear (0, 0, 0, height);
892 murrine_pattern_add_color_stop_rgba (pat, 0.0, &top, MENUBAR_STRIPED_OPACITY);
893 murrine_pattern_add_color_stop_rgba (pat, 1.0, &low, MENUBAR_STRIPED_OPACITY);
894 cairo_set_source (cr, pat);
895 cairo_fill (cr);
896
897 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
898
899 cairo_pattern_destroy (pat);
900 int counter = -height;
901 murrine_shade (&low, 0.9, &low);
902 murrine_set_color_rgba (cr, &low, MENUBAR_STRIPED_OPACITY);
903 while (counter < width)
904 {
905 cairo_move_to (cr, counter, height);
906 cairo_line_to (cr, counter+height, 0);
907 cairo_stroke (cr);
908 counter += 5;
909 }
910 break;
911 }
912 }
913
914 /* Draw bottom line */
915 if (menubarstyle == 1 && widget->glazestyle == 2)
916 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
917 else
918 {
919 cairo_move_to (cr, 0, height-0.5);
920 cairo_line_to (cr, width, height-0.5);
921 }
922
923 murrine_set_color_rgb (cr, &dark);
924 cairo_stroke (cr);
925 }
926
927 static void
murrine_rgba_draw_toolbar(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ToolbarParameters * toolbar,int x,int y,int width,int height)928 murrine_rgba_draw_toolbar (cairo_t *cr,
929 const MurrineColors *colors,
930 const WidgetParameters *widget,
931 const ToolbarParameters *toolbar,
932 int x, int y, int width, int height)
933 {
934 const MurrineRGB *fill = &colors->bg[0];
935 const MurrineRGB *top = &colors->shade[0];
936 MurrineRGB dark = colors->shade[4];
937
938 if(widget->mrn_gradient.has_border_colors)
939 dark = widget->mrn_gradient.border_colors[1];
940
941 cairo_translate (cr, x, y);
942 cairo_rectangle (cr, 0, 0, width, height);
943
944 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
945
946 /* Glass toolbar */
947 switch (toolbar->style)
948 {
949 default:
950 case 0:
951 murrine_set_color_rgba (cr, fill, TOOLBAR_OPACITY);
952 cairo_fill (cr);
953
954 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
955
956 /* Draw highlight */
957 if (!toolbar->topmost)
958 {
959 murrine_set_color_rgba (cr, top, 0.5);
960 cairo_move_to (cr, 0, 0.5);
961 cairo_line_to (cr, width, 0.5);
962 cairo_stroke (cr);
963 }
964 break;
965 case 1:
966 {
967 int os = (widget->glazestyle == 2) ? 1 : 0;
968 murrine_draw_glaze (cr, fill,
969 widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
970 widget->mrn_gradient, widget, os, os, width-os*2, height-os*2,
971 widget->roundness, widget->corners, TRUE);
972
973 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
974 break;
975 }
976 case 2:
977 {
978 cairo_pattern_t *pat;
979 MurrineRGB lower;
980 murrine_shade (fill, 0.95, &lower);
981 pat = cairo_pattern_create_linear (0, 0, 0, height);
982 murrine_pattern_add_color_stop_rgba (pat, 0.0, fill, TOOLBAR_OPACITY);
983 murrine_pattern_add_color_stop_rgba (pat, 1.0, &lower, TOOLBAR_OPACITY);
984 cairo_set_source (cr, pat);
985 cairo_pattern_destroy (pat);
986 cairo_fill (cr);
987
988 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
989
990 /* Draw highlight */
991 if (!toolbar->topmost)
992 {
993 cairo_move_to (cr, 0, 0.5);
994 cairo_line_to (cr, width, 0.5);
995 murrine_set_color_rgb (cr, top);
996 cairo_stroke (cr);
997 }
998 break;
999 }
1000 }
1001
1002 /* Draw shadow */
1003 murrine_set_color_rgb (cr, &dark);
1004 /* Draw bottom line */
1005 if (toolbar->style == 1 && widget->glazestyle == 2)
1006 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
1007 else
1008 {
1009 cairo_move_to (cr, 0, height-0.5);
1010 cairo_line_to (cr, width, height-0.5);
1011 }
1012 cairo_stroke (cr);
1013 }
1014
1015 static void
murrine_get_frame_gap_clip(int x,int y,int width,int height,const FrameParameters * frame,MurrineRectangle * bevel,MurrineRectangle * border)1016 murrine_get_frame_gap_clip (int x, int y, int width, int height,
1017 const FrameParameters *frame,
1018 MurrineRectangle *bevel,
1019 MurrineRectangle *border)
1020 {
1021 switch (frame->gap_side)
1022 {
1023 case MRN_GAP_TOP:
1024 MURRINE_RECTANGLE_SET ((*bevel), 1.5+frame->gap_x, -0.5,
1025 frame->gap_width-3, 2.0);
1026 MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, -0.5,
1027 frame->gap_width-2, 2.0);
1028 break;
1029 case MRN_GAP_BOTTOM:
1030 MURRINE_RECTANGLE_SET ((*bevel), 1.5+frame->gap_x, height-2.5,
1031 frame->gap_width-3, 2.0);
1032 MURRINE_RECTANGLE_SET ((*border), 0.5+frame->gap_x, height-1.5,
1033 frame->gap_width-2, 2.0);
1034 break;
1035 case MRN_GAP_LEFT:
1036 MURRINE_RECTANGLE_SET ((*bevel), -0.5, 1.5+frame->gap_x,
1037 2.0, frame->gap_width-3);
1038 MURRINE_RECTANGLE_SET ((*border), -0.5, 0.5+frame->gap_x,
1039 1.0, frame->gap_width-2);
1040 break;
1041 case MRN_GAP_RIGHT:
1042 MURRINE_RECTANGLE_SET ((*bevel), width-2.5, 1.5+frame->gap_x,
1043 2.0, frame->gap_width-3);
1044 MURRINE_RECTANGLE_SET ((*border), width-1.5, 0.5+frame->gap_x,
1045 1.0, frame->gap_width-2);
1046 break;
1047 }
1048 }
1049
1050 static void
murrine_rgba_draw_frame(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const FrameParameters * frame,int x,int y,int width,int height)1051 murrine_rgba_draw_frame (cairo_t *cr,
1052 const MurrineColors *colors,
1053 const WidgetParameters *widget,
1054 const FrameParameters *frame,
1055 int x, int y, int width, int height)
1056 {
1057 MurrineRGB *border = frame->border;
1058 MurrineRectangle bevel_clip;
1059 MurrineRectangle frame_clip;
1060 const MurrineRGB *dark = &colors->shade[5];
1061 MurrineRGB highlight, shadow_color;
1062
1063 murrine_shade (&colors->bg[0], 1.15, &highlight);
1064 murrine_shade (&colors->bg[0], 0.4, &shadow_color);
1065
1066 if (frame->shadow == MRN_SHADOW_NONE)
1067 return;
1068
1069 if (frame->gap_x != -1)
1070 murrine_get_frame_gap_clip (x, y, width, height,
1071 frame, &bevel_clip, &frame_clip);
1072
1073 cairo_translate (cr, x+0.5, y+0.5);
1074
1075 /* save everything */
1076 cairo_save (cr);
1077
1078 /* Set clip for the bevel */
1079 if (frame->gap_x != -1)
1080 {
1081 /* Set clip for gap */
1082 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1083 cairo_rectangle (cr, -0.5, -0.5, width, height);
1084 cairo_rectangle (cr, bevel_clip.x, bevel_clip.y, bevel_clip.width, bevel_clip.height);
1085 cairo_clip (cr);
1086 }
1087
1088 /* Draw the bevel */
1089 if (frame->shadow == MRN_SHADOW_ETCHED_IN || frame->shadow == MRN_SHADOW_ETCHED_OUT)
1090 {
1091 if (frame->shadow == MRN_SHADOW_ETCHED_IN)
1092 murrine_rounded_rectangle (cr, 1, 1, width-2, height-2, widget->roundness, widget->corners);
1093 else
1094 murrine_rounded_rectangle (cr, 0, 0, width-2, height-2, widget->roundness, widget->corners);
1095 murrine_set_color_rgba (cr, &highlight, 0.5);
1096 cairo_stroke (cr);
1097 }
1098 else if (frame->shadow != MRN_SHADOW_FLAT)
1099 {
1100 ShadowParameters shadow;
1101 shadow.corners = widget->corners;
1102 shadow.shadow = frame->shadow;
1103 murrine_draw_highlight_and_shade (cr, colors, &shadow, width, height, widget->roundness-1);
1104 }
1105
1106 /* restore the previous clip region */
1107 cairo_restore (cr);
1108 cairo_save (cr);
1109 if (frame->gap_x != -1)
1110 {
1111 /* Set clip for gap */
1112 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1113 cairo_rectangle (cr, -0.5, -0.5, width, height);
1114 cairo_rectangle (cr, frame_clip.x, frame_clip.y, frame_clip.width, frame_clip.height);
1115 cairo_clip (cr);
1116 }
1117
1118 /* Draw frame */
1119 if (frame->shadow == MRN_SHADOW_ETCHED_IN || frame->shadow == MRN_SHADOW_ETCHED_OUT)
1120 {
1121 murrine_set_color_rgb (cr, dark);
1122 if (frame->shadow == MRN_SHADOW_ETCHED_IN)
1123 murrine_rounded_rectangle (cr, 0, 0, width-2, height-2, widget->roundness, widget->corners);
1124 else
1125 murrine_rounded_rectangle (cr, 1, 1, width-2, height-2, widget->roundness, widget->corners);
1126 }
1127 else
1128 {
1129 murrine_set_color_rgb (cr, border);
1130 murrine_rounded_rectangle (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
1131 }
1132 cairo_stroke (cr);
1133 cairo_restore (cr);
1134 }
1135
1136 static void
murrine_rgba_draw_tab(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const TabParameters * tab,int x,int y,int width,int height)1137 murrine_rgba_draw_tab (cairo_t *cr,
1138 const MurrineColors *colors,
1139 const WidgetParameters *widget,
1140 const TabParameters *tab,
1141 int x, int y, int width, int height)
1142 {
1143 const MurrineRGB *stripe_fill = &colors->spot[1];
1144 const MurrineRGB *stripe_border = &colors->spot[2];
1145 const MurrineRGB *fill = &colors->bg[widget->state_type];
1146 const MurrineRGB *border = &colors->shade[!widget->active ? 5 : 4];
1147 cairo_pattern_t *pat;
1148
1149 /* Set clip */
1150 cairo_rectangle (cr, x, y, width, height);
1151 cairo_clip (cr);
1152 cairo_new_path (cr);
1153
1154 cairo_translate (cr, x+0.5, y+0.5);
1155
1156 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1157
1158 /* Make the tabs slightly bigger than they should be, to create a gap */
1159 /* And calculate the strip size too, while you're at it */
1160 if (tab->gap_side == MRN_GAP_TOP || tab->gap_side == MRN_GAP_BOTTOM)
1161 {
1162 height += 3.0;
1163
1164 if (tab->gap_side == MRN_GAP_TOP)
1165 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
1166 }
1167 else
1168 {
1169 width += 3.0;
1170
1171 if (tab->gap_side == MRN_GAP_LEFT)
1172 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
1173 }
1174
1175 /* Set tab shape */
1176 murrine_rounded_rectangle_closed (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
1177
1178 /* Draw fill */
1179 if (!widget->active)
1180 {
1181 murrine_set_color_rgba (cr, fill, NOTEBOOK_OPACITY);
1182 cairo_fill (cr);
1183 }
1184
1185 if (widget->active)
1186 {
1187 MurrineRGB shade1, shade2, shade3, shade4, highlight;
1188 MurrineGradients mrn_gradient_new = mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
1189 double highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
1190 double lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
1191
1192 murrine_shade (fill, mrn_gradient_new.gradient_shades[0]*highlight_shade_new, &shade1);
1193 murrine_shade (fill, mrn_gradient_new.gradient_shades[1]*highlight_shade_new, &shade2);
1194 murrine_shade (fill, mrn_gradient_new.gradient_shades[2], &shade3);
1195 murrine_shade (fill, mrn_gradient_new.gradient_shades[3], &shade4);
1196
1197 switch (tab->gap_side)
1198 {
1199 case MRN_GAP_TOP:
1200 pat = cairo_pattern_create_linear (0, height-2, 0, 0);
1201 break;
1202 case MRN_GAP_BOTTOM:
1203 pat = cairo_pattern_create_linear (0, 1, 0, height);
1204 break;
1205 case MRN_GAP_LEFT:
1206 pat = cairo_pattern_create_linear (width-2, 0, 1, 0);
1207 break;
1208 case MRN_GAP_RIGHT:
1209 pat = cairo_pattern_create_linear (1, 0, width-2, 0);
1210 break;
1211 }
1212
1213 murrine_rounded_rectangle_closed (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
1214
1215 murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, NOTEBOOK_OPACITY);
1216 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade2, NOTEBOOK_OPACITY);
1217 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade3, NOTEBOOK_OPACITY);
1218 murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade4, NOTEBOOK_OPACITY);
1219 cairo_set_source (cr, pat);
1220 cairo_fill (cr);
1221 cairo_pattern_destroy (pat);
1222
1223 /* Draw lightborder */
1224 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1225
1226 murrine_shade (fill, lightborder_shade_new*highlight_shade_new, &highlight);
1227 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[0]*highlight_shade_new, &shade1);
1228 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[1]*highlight_shade_new, &shade2);
1229 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[2], &shade3);
1230 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[3], &shade4);
1231
1232 switch (tab->gap_side)
1233 {
1234 case MRN_GAP_TOP:
1235 pat = cairo_pattern_create_linear (0, height-2, 0, 0);
1236 break;
1237 case MRN_GAP_BOTTOM:
1238 pat = cairo_pattern_create_linear (0, 1, 0, height);
1239 break;
1240 case MRN_GAP_LEFT:
1241 pat = cairo_pattern_create_linear (width-2, 0, 1, 0);
1242 break;
1243 case MRN_GAP_RIGHT:
1244 pat = cairo_pattern_create_linear (1, 0, width-2, 0);
1245 break;
1246 }
1247
1248 murrine_rounded_rectangle_closed (cr, 1, 1, width-3, height-3, widget->roundness, widget->corners);
1249
1250 murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, 0.5*NOTEBOOK_OPACITY);
1251 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade2, 0.5*NOTEBOOK_OPACITY);
1252 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade3, 0.5*NOTEBOOK_OPACITY);
1253 murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade4, 0.5*NOTEBOOK_OPACITY);
1254 cairo_set_source (cr, pat);
1255 cairo_stroke (cr);
1256 cairo_pattern_destroy (pat);
1257 }
1258 else
1259 {
1260 MurrineRGB shade1, shade2, shade3, shade4, highlight;
1261 MurrineGradients mrn_gradient_new = mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
1262 double highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
1263
1264 murrine_shade (fill, mrn_gradient_new.gradient_shades[0]*highlight_shade_new, &shade1);
1265 murrine_shade (fill, mrn_gradient_new.gradient_shades[1]*highlight_shade_new, &shade2);
1266 murrine_shade (fill, mrn_gradient_new.gradient_shades[2], &shade3);
1267 murrine_shade (fill, 1.0, &shade4); /* this value should change as draw_frame */
1268
1269 /* Draw shade */
1270 switch (tab->gap_side)
1271 {
1272 case MRN_GAP_TOP:
1273 pat = cairo_pattern_create_linear (0, height-2, 0, 0);
1274 break;
1275 case MRN_GAP_BOTTOM:
1276 pat = cairo_pattern_create_linear (0, 0, 0, height);
1277 break;
1278 case MRN_GAP_LEFT:
1279 pat = cairo_pattern_create_linear (width-2, 0, 0, 0);
1280 break;
1281 case MRN_GAP_RIGHT:
1282 pat = cairo_pattern_create_linear (0, 0, width, 0);
1283 break;
1284 }
1285
1286 murrine_rounded_rectangle_closed (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
1287
1288 murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, NOTEBOOK_OPACITY);
1289 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade2, NOTEBOOK_OPACITY);
1290 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade3, NOTEBOOK_OPACITY);
1291 murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade4, NOTEBOOK_OPACITY);
1292 cairo_set_source (cr, pat);
1293 cairo_fill (cr);
1294 cairo_pattern_destroy (pat);
1295
1296 /* Draw lightborder */
1297 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1298
1299 murrine_shade (fill, widget->lightborder_shade*highlight_shade_new, &highlight);
1300 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[0]*highlight_shade_new, &shade1);
1301 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[1]*highlight_shade_new, &shade2);
1302 murrine_shade (&highlight, mrn_gradient_new.gradient_shades[2], &shade3);
1303 murrine_shade (fill, 1.15, &shade4); /* this value should change as draw_frame */
1304
1305 switch (tab->gap_side)
1306 {
1307 case MRN_GAP_TOP:
1308 pat = cairo_pattern_create_linear (0, height-2, 0, 0);
1309 break;
1310 case MRN_GAP_BOTTOM:
1311 pat = cairo_pattern_create_linear (0, 0, 0, height);
1312 break;
1313 case MRN_GAP_LEFT:
1314 pat = cairo_pattern_create_linear (width-2, 0, 0, 0);
1315 break;
1316 case MRN_GAP_RIGHT:
1317 pat = cairo_pattern_create_linear (0, 0, width, 0);
1318 break;
1319 }
1320
1321 murrine_rounded_rectangle_closed (cr, 1, 1, width-3, height-3, widget->roundness, widget->corners);
1322
1323 murrine_pattern_add_color_stop_rgba (pat, 0.00, &shade1, 0.5*NOTEBOOK_OPACITY);
1324 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade2, 0.5*NOTEBOOK_OPACITY);
1325 murrine_pattern_add_color_stop_rgba (pat, 0.45, &shade3, 0.5*NOTEBOOK_OPACITY);
1326 murrine_pattern_add_color_stop_rgba (pat, 1.00, &shade4, 0.5*NOTEBOOK_OPACITY);
1327 cairo_set_source (cr, pat);
1328 cairo_stroke (cr);
1329 cairo_pattern_destroy (pat);
1330 }
1331
1332 murrine_rounded_rectangle (cr, 0, 0, width-1, height-1, widget->roundness, widget->corners);
1333 murrine_set_color_rgb (cr, border);
1334 cairo_stroke (cr);
1335 }
1336
1337 static void
murrine_rgba_draw_scrollbar_trough(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ScrollBarParameters * scrollbar,int x,int y,int width,int height)1338 murrine_rgba_draw_scrollbar_trough (cairo_t *cr,
1339 const MurrineColors *colors,
1340 const WidgetParameters *widget,
1341 const ScrollBarParameters *scrollbar,
1342 int x, int y, int width, int height)
1343 {
1344 MurrineRGB border;
1345 MurrineRGB fill;
1346
1347 murrine_shade (&widget->parentbg,
1348 murrine_get_contrast (scrollbar->stepperstyle != 1 ? 0.82 : 0.75, widget->contrast),
1349 &border);
1350 murrine_shade (&widget->parentbg, scrollbar->stepperstyle != 1 ? 0.95 : 1.065, &fill);
1351
1352 if (!scrollbar->horizontal)
1353 {
1354 cairo_translate (cr, x, y);
1355 }
1356 else
1357 {
1358 int tmp = height;
1359 rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
1360 height = width;
1361 width = tmp;
1362 }
1363
1364 /* Draw fill */
1365 murrine_draw_trough (cr, &fill, 0, 0, width, height, widget->roundness, widget->corners, widget->mrn_gradient, 0.4, FALSE);
1366
1367 if (scrollbar->stepperstyle == 3)
1368 {
1369 uint8 corners;
1370 MurrineRGB fill_stepper;
1371 MurrineRGB border_stepper;
1372
1373 murrine_shade (&widget->parentbg, 1.02, &fill_stepper);
1374 murrine_shade (&border, (widget->mrn_gradient.trough_shades[0]+widget->mrn_gradient.trough_shades[1])/2.0, &border_stepper);
1375
1376 cairo_save (cr);
1377
1378 murrine_rounded_rectangle_closed (cr, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners);
1379 cairo_clip (cr);
1380
1381 corners = MRN_CORNER_BOTTOMLEFT | MRN_CORNER_BOTTOMRIGHT;
1382 murrine_rounded_rectangle_inverted (cr, 0.5, 0.5, width-1, scrollbar->steppersize, widget->roundness, corners);
1383 murrine_set_color_rgb (cr, &fill_stepper);
1384 cairo_fill_preserve (cr);
1385 murrine_draw_trough_border_from_path (cr, &border,0.5, 0.5, width-1, scrollbar->steppersize, widget->mrn_gradient, 1.0, FALSE);
1386
1387 corners = MRN_CORNER_TOPLEFT | MRN_CORNER_TOPRIGHT;
1388 murrine_rounded_rectangle_inverted (cr, 0.5, height-scrollbar->steppersize-0.5, width-1, scrollbar->steppersize, widget->roundness, corners);
1389 murrine_set_color_rgb (cr, &fill_stepper);
1390 cairo_fill_preserve (cr);
1391 murrine_draw_trough_border_from_path (cr, &border, 0.5, height-scrollbar->steppersize-0.5, width-1, scrollbar->steppersize, widget->mrn_gradient, 1.0, FALSE);
1392
1393 cairo_restore (cr);
1394 }
1395
1396 /* Draw border */
1397 if (!scrollbar->within_bevel)
1398 murrine_draw_trough_border (cr, &border, 0.5, 0.5, width-1, height-1, widget->roundness, widget->corners, widget->mrn_gradient, 0.82, FALSE);
1399 else
1400 {
1401 murrine_shade (&border, widget->mrn_gradient.trough_shades[0], &border);
1402 murrine_set_color_rgba (cr, &border, 0.82);
1403 cairo_move_to (cr, 0.5, 0);
1404 cairo_line_to (cr, 0.5, height);
1405 cairo_stroke (cr);
1406 }
1407 }
1408
1409 void
murrine_rgba_draw_scrollbar_stepper(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ScrollBarParameters * scrollbar,int x,int y,int width,int height)1410 murrine_rgba_draw_scrollbar_stepper (cairo_t *cr,
1411 const MurrineColors *colors,
1412 const WidgetParameters *widget,
1413 const ScrollBarParameters *scrollbar,
1414 int x, int y, int width, int height)
1415 {
1416 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
1417 double border_stop_mid = ((mrn_gradient_new.border_shades[0])+
1418 (mrn_gradient_new.border_shades[1]))/2.0;
1419 MurrineRGB border;
1420 MurrineRGB fill = colors->bg[widget->state_type];
1421
1422 murrine_get_fill_color (&fill, &mrn_gradient_new);
1423 murrine_shade (&colors->shade[7], 0.95, &border);
1424
1425 mrn_gradient_new.border_shades[0] = border_stop_mid;
1426 mrn_gradient_new.border_shades[1] = border_stop_mid;
1427
1428 if (!scrollbar->horizontal)
1429 murrine_exchange_axis (cr, &x, &y, &width, &height);
1430
1431 /* Border color */
1432 murrine_mix_color (&border, &fill, 0.45, &border);
1433
1434 cairo_translate (cr, x, y);
1435
1436 cairo_save (cr);
1437
1438 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1439
1440 murrine_rounded_rectangle_closed (cr, 1, 1, width-2, height-2, widget->roundness-1, widget->corners);
1441 cairo_clip_preserve(cr);
1442
1443 murrine_draw_glaze (cr, &fill,
1444 widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
1445 widget->mrn_gradient, widget, 1, 1, width-2, height-2,
1446 widget->roundness, widget->corners, TRUE);
1447
1448 cairo_restore (cr);
1449
1450 murrine_draw_border (cr, &border,
1451 0.5, 0.5, width-1, height-1,
1452 widget->roundness, widget->corners,
1453 mrn_gradient_new, 1.0);
1454 }
1455
1456 void
murrine_rgba_draw_scrollbar_slider(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const ScrollBarParameters * scrollbar,int x,int y,int width,int height)1457 murrine_rgba_draw_scrollbar_slider (cairo_t *cr,
1458 const MurrineColors *colors,
1459 const WidgetParameters *widget,
1460 const ScrollBarParameters *scrollbar,
1461 int x, int y, int width, int height)
1462 {
1463 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
1464 double border_stop_mid = ((mrn_gradient_new.border_shades[0])+
1465 (mrn_gradient_new.border_shades[1]))/2.0;
1466 MurrineRGB fill = scrollbar->has_color ? scrollbar->color : colors->bg[widget->state_type];
1467 MurrineRGB border;
1468 uint8 corners = widget->corners;
1469
1470 murrine_get_fill_color (&fill, &mrn_gradient_new);
1471
1472 if (scrollbar->stepperstyle != 1 && scrollbar->stepperstyle != 3)
1473 {
1474 if (scrollbar->junction & MRN_JUNCTION_BEGIN)
1475 {
1476 if (scrollbar->horizontal)
1477 {
1478 x -= 1;
1479 width += 1;
1480 }
1481 else
1482 {
1483 y -= 1;
1484 height += 1;
1485 }
1486 }
1487 if (scrollbar->junction & MRN_JUNCTION_END)
1488 {
1489 if (scrollbar->horizontal)
1490 width += 1;
1491 else
1492 height += 1;
1493 }
1494 }
1495
1496 if (scrollbar->stepperstyle == 2)
1497 {
1498 if (scrollbar->junction & MRN_JUNCTION_BEGIN)
1499 {
1500 if (scrollbar->horizontal)
1501 corners ^= MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT;
1502 else
1503 corners ^= MRN_CORNER_TOPLEFT | MRN_CORNER_BOTTOMLEFT;
1504 }
1505 if (scrollbar->junction & MRN_JUNCTION_END)
1506 {
1507 if (scrollbar->horizontal)
1508 corners ^= MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT;
1509 else
1510 corners ^= MRN_CORNER_TOPRIGHT | MRN_CORNER_BOTTOMRIGHT;
1511 }
1512 }
1513
1514 murrine_shade (&colors->shade[7], 0.95, &border);
1515
1516 mrn_gradient_new.border_shades[0] = border_stop_mid;
1517 mrn_gradient_new.border_shades[1] = border_stop_mid;
1518
1519 if (widget->prelight && scrollbar->has_color)
1520 murrine_shade (&fill, scrollbar->prelight_shade, &fill);
1521
1522 murrine_mix_color (&border, &fill, 0.5, &border);
1523
1524 if (scrollbar->horizontal)
1525 cairo_translate (cr, x, y);
1526 else
1527 {
1528 int tmp = height;
1529 rotate_mirror_translate (cr, M_PI/2, x, y, FALSE, FALSE);
1530 height = width;
1531 width = tmp;
1532 }
1533
1534 cairo_save (cr);
1535
1536 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1537
1538 murrine_rounded_rectangle_closed (cr, 1, 1, width-2, height-2, widget->roundness-1, corners);
1539 cairo_clip_preserve (cr);
1540
1541 murrine_draw_glaze (cr, &fill,
1542 widget->glow_shade, widget->highlight_shade, widget->lightborder_shade,
1543 widget->mrn_gradient, widget, 1, 1, width-2, height-2,
1544 widget->roundness, corners, TRUE);
1545
1546 /* Draw the options */
1547 MurrineRGB style;
1548 if (scrollbar->style > 0)
1549 murrine_shade (&fill, 0.55, &style);
1550
1551 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1552
1553 switch (scrollbar->style)
1554 {
1555 case 1:
1556 {
1557 int circ_radius = 2;
1558 int circ_space = 5;
1559 int i;
1560 int x1 = circ_space+circ_radius;
1561 int y1 = height/2;
1562 for (i = circ_space; i < width-circ_space; i += 2*circ_radius+circ_space)
1563 {
1564 cairo_move_to (cr, i, 1);
1565 cairo_arc (cr, x1, y1, circ_radius, 0, M_PI*2);
1566
1567 x1 += 2*circ_radius+circ_space;
1568
1569 cairo_close_path (cr);
1570 murrine_set_color_rgba (cr, &style, 0.15);
1571 cairo_fill (cr);
1572 }
1573 break;
1574 }
1575 case 3:
1576 case 4:
1577 {
1578 int counter = -width;
1579 cairo_save (cr);
1580 cairo_rectangle (cr, 1, 1, width-2, height-2);
1581 cairo_clip (cr);
1582 cairo_new_path (cr);
1583 cairo_set_line_width (cr, 5.0); /* stroke width */
1584 murrine_set_color_rgba (cr, &style, 0.08);
1585 while (counter < height)
1586 {
1587 cairo_move_to (cr, width, counter);
1588 cairo_line_to (cr, 0, counter+width);
1589 cairo_stroke (cr);
1590 counter += 12;
1591 }
1592 cairo_restore (cr);
1593 break;
1594 }
1595 case 5:
1596 case 6:
1597 {
1598 int stroke_width = 7;
1599 int stroke_space = 5;
1600 int i;
1601 murrine_set_color_rgba (cr, &style, 0.08);
1602 for (i = stroke_space; i < width-stroke_space; i += stroke_width+stroke_space)
1603 {
1604 cairo_move_to (cr, i, 1);
1605 cairo_rel_line_to (cr, 0, height-2);
1606 cairo_rel_line_to (cr, stroke_width, 0);
1607 cairo_rel_line_to (cr, 0, -(height-2));
1608 cairo_fill (cr);
1609 }
1610 break;
1611 }
1612 }
1613 /* Draw the handle */
1614 if (scrollbar->style > 0 && scrollbar->style % 2 == 0)
1615 {
1616 double bar_x = width/2-3.5;
1617 int i;
1618
1619 switch (scrollbar->handlestyle)
1620 {
1621 default:
1622 case 0:
1623 {
1624 for (i=0; i<3; i++)
1625 {
1626 cairo_move_to (cr, bar_x, 5);
1627 cairo_line_to (cr, bar_x, height-5);
1628 murrine_set_color_rgb (cr, &border);
1629 cairo_stroke (cr);
1630
1631 bar_x += 3;
1632 }
1633 break;
1634 }
1635 case 1:
1636 {
1637 MurrineRGB inset;
1638 murrine_shade (&fill, 1.08, &inset);
1639
1640 for (i=0; i<3; i++)
1641 {
1642 cairo_move_to (cr, bar_x, 5);
1643 cairo_line_to (cr, bar_x, height-5);
1644 murrine_set_color_rgb (cr, &border);
1645 cairo_stroke (cr);
1646
1647 cairo_move_to (cr, bar_x+1, 5);
1648 cairo_line_to (cr, bar_x+1, height-5);
1649 murrine_set_color_rgb (cr, &inset);
1650 cairo_stroke (cr);
1651
1652 bar_x += 3;
1653 }
1654 break;
1655 }
1656 case 2:
1657 {
1658 MurrineRGB inset;
1659 murrine_shade (&fill, 1.04, &inset);
1660
1661 bar_x++;
1662
1663 for (i=0; i<3; i++)
1664 {
1665 cairo_move_to (cr, bar_x, 5);
1666 cairo_line_to (cr, bar_x, height-5);
1667 murrine_set_color_rgb (cr, &border);
1668 cairo_stroke (cr);
1669
1670 cairo_move_to (cr, bar_x+1, 5);
1671 cairo_line_to (cr, bar_x+1, height-5);
1672 murrine_set_color_rgb (cr, &inset);
1673 cairo_stroke (cr);
1674
1675 bar_x += 2;
1676 }
1677 break;
1678 }
1679 }
1680 }
1681
1682 cairo_restore (cr);
1683
1684 murrine_draw_border (cr, &border,
1685 0.5, 0.5, width-1, height-1,
1686 widget->roundness, corners,
1687 mrn_gradient_new, 1.0);
1688 }
1689
1690 static void
murrine_rgba_draw_tooltip(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,int x,int y,int width,int height)1691 murrine_rgba_draw_tooltip (cairo_t *cr,
1692 const MurrineColors *colors,
1693 const WidgetParameters *widget,
1694 int x, int y, int width, int height)
1695 {
1696 MurrineRGB border;
1697 MurrineRGB fill = colors->bg[widget->state_type];
1698 MurrineGradients mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 2.0);
1699 double glow_shade_new = murrine_get_decreased_shade (widget->glow_shade, 2.0);
1700 double highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
1701
1702 murrine_shade (&fill, murrine_get_contrast(0.6, widget->contrast), &border);
1703 murrine_get_fill_color (&fill, &mrn_gradient_new);
1704
1705 cairo_save (cr);
1706
1707 cairo_translate (cr, x, y);
1708
1709 cairo_rectangle (cr, 0, 0, width, height);
1710 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1711 cairo_fill (cr);
1712
1713 cairo_save (cr);
1714
1715 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1716
1717 murrine_rounded_rectangle_closed (cr, 1, 1, width-2, height-2, widget->roundness-1, widget->corners);
1718 cairo_clip_preserve (cr);
1719
1720 murrine_draw_glaze (cr, &colors->bg[widget->state_type],
1721 glow_shade_new, highlight_shade_new, widget->lightborder_shade,
1722 mrn_gradient_new, widget, 1, 1, width-2, height-2,
1723 widget->roundness-1, widget->corners, TRUE);
1724
1725 cairo_restore (cr);
1726
1727 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1728
1729 murrine_draw_border (cr, &border,
1730 0.5, 0.5, width-1, height-1,
1731 widget->roundness, widget->corners,
1732 mrn_gradient_new, 1.0);
1733
1734 cairo_restore (cr);
1735 }
1736
1737 static void
murrine_rgba_draw_handle(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const HandleParameters * handle,int x,int y,int width,int height)1738 murrine_rgba_draw_handle (cairo_t *cr,
1739 const MurrineColors *colors,
1740 const WidgetParameters *widget,
1741 const HandleParameters *handle,
1742 int x, int y, int width, int height)
1743 {
1744 int bar_height;
1745 int bar_width = 4;
1746 int i, bar_y = 1;
1747 int num_bars, bar_spacing;
1748 num_bars = 3;
1749 bar_spacing = 3;
1750 bar_height = num_bars*bar_spacing;
1751
1752 if (handle->horizontal)
1753 {
1754 int tmp = height;
1755 rotate_mirror_translate (cr, M_PI/2, x+0.5+width/2-bar_height/2, y+height/2-bar_width/2, FALSE, FALSE);
1756 height = width;
1757 width = tmp;
1758 }
1759 else
1760 {
1761 cairo_translate (cr, x+width/2-bar_width/2, y+height/2-bar_height/2+0.5);
1762 }
1763
1764 switch (handle->style)
1765 {
1766 default:
1767 case 0:
1768 {
1769 for (i=0; i<num_bars; i++)
1770 {
1771 cairo_move_to (cr, 0, bar_y);
1772 cairo_line_to (cr, bar_width, bar_y);
1773 murrine_set_color_rgb (cr, &colors->shade[5]);
1774 cairo_stroke (cr);
1775
1776 bar_y += bar_spacing;
1777 }
1778 break;
1779 }
1780 case 1:
1781 {
1782 for (i=0; i<num_bars; i++)
1783 {
1784 cairo_move_to (cr, 0, bar_y);
1785 cairo_line_to (cr, bar_width, bar_y);
1786 murrine_set_color_rgb (cr, &colors->shade[5]);
1787 cairo_stroke (cr);
1788
1789 cairo_move_to (cr, 0, bar_y+1);
1790 cairo_line_to (cr, bar_width, bar_y+1);
1791 murrine_set_color_rgb (cr, &colors->shade[0]);
1792 cairo_stroke (cr);
1793
1794 bar_y += bar_spacing;
1795 }
1796 break;
1797 }
1798 case 2:
1799 {
1800 bar_y++;
1801
1802 for (i=0; i<num_bars; i++)
1803 {
1804 cairo_move_to (cr, 0, bar_y);
1805 cairo_line_to (cr, bar_width, bar_y);
1806 murrine_set_color_rgb (cr, &colors->shade[5]);
1807 cairo_stroke (cr);
1808
1809 cairo_move_to (cr, 0, bar_y+1);
1810 cairo_line_to (cr, bar_width, bar_y+1);
1811 murrine_set_color_rgb (cr, &colors->shade[0]);
1812 cairo_stroke (cr);
1813
1814 bar_y += 2;
1815 }
1816 break;
1817 }
1818 }
1819 }
1820
1821
1822 static void
murrine_rgba_draw_radiobutton(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const CheckboxParameters * checkbox,int x,int y,int width,int height,double trans)1823 murrine_rgba_draw_radiobutton (cairo_t *cr,
1824 const MurrineColors *colors,
1825 const WidgetParameters *widget,
1826 const CheckboxParameters *checkbox,
1827 int x, int y, int width, int height,
1828 double trans)
1829 {
1830 MurrineRGB border;
1831 const MurrineRGB *dot;
1832 const MurrineRGB *bg = &colors->base[0];
1833 gboolean inconsistent = FALSE;
1834 gboolean draw_box = !checkbox->in_menu;
1835 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1836 int roundness = width+height;
1837 double highlight_shade_new = widget->highlight_shade;
1838 double lightborder_shade_new = widget->lightborder_shade;
1839 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
1840
1841 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1842 draw_bullet |= inconsistent;
1843
1844 if (widget->state_type == GTK_STATE_INSENSITIVE)
1845 {
1846 border = colors->shade[4];
1847 dot = &colors->shade[4];
1848 bg = &colors->bg[0];
1849
1850 mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
1851 mrn_gradient_new.border_shades[0] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[0], 3.0);
1852 mrn_gradient_new.border_shades[1] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[1], 3.0);
1853 highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
1854 lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
1855 }
1856 else
1857 {
1858 border = colors->shade[6];
1859 if (draw_bullet)
1860 {
1861 border = colors->spot[2];
1862 bg = &colors->spot[1];
1863 }
1864 dot = &colors->text[widget->state_type];
1865 }
1866 murrine_mix_color (&border, widget->state_type != GTK_STATE_INSENSITIVE ?
1867 draw_bullet ? &colors->spot[1] : &colors->bg[0] : &colors->bg[0], 0.2, &border);
1868
1869 cairo_translate (cr, x, y);
1870
1871 if (draw_box)
1872 {
1873 if (widget->xthickness > 2 && widget->ythickness > 2)
1874 {
1875 if (widget->reliefstyle > 1 && draw_bullet && widget->state_type != GTK_STATE_INSENSITIVE)
1876 {
1877 if (widget->reliefstyle == 5)
1878 murrine_draw_shadow (cr, &widget->parentbg,
1879 0.5, 0.5, width-1, height-1,
1880 roundness+1, widget->corners,
1881 widget->reliefstyle,
1882 mrn_gradient_new, 0.5);
1883 else
1884 {
1885 MurrineRGB shadow;
1886 murrine_shade (&border, 0.9, &shadow);
1887
1888 murrine_draw_shadow (cr, &shadow,
1889 0.5, 0.5, width-1, height-1,
1890 roundness+1, widget->corners,
1891 widget->reliefstyle,
1892 mrn_gradient_new, 0.08);
1893 }
1894 }
1895 else if (widget->reliefstyle != 0)
1896 murrine_draw_inset (cr, &widget->parentbg, 0.5, 0.5, width-1, height-1, roundness+1, widget->corners);
1897 }
1898
1899 cairo_save (cr);
1900
1901 murrine_rounded_rectangle_closed (cr, 1.5, 1.5, width-3, height-3, roundness, widget->corners);
1902 cairo_clip_preserve (cr);
1903
1904 if (draw_bullet)
1905 {
1906 murrine_draw_glaze (cr, bg,
1907 widget->glow_shade, highlight_shade_new, lightborder_shade_new,
1908 mrn_gradient_new, widget, 2, 2, width-4, height-4,
1909 roundness, widget->corners, TRUE);
1910 }
1911 else
1912 {
1913 murrine_set_color_rgb (cr, bg);
1914 cairo_fill (cr);
1915 }
1916
1917 cairo_restore (cr);
1918
1919 if (checkbox->in_cell)
1920 {
1921 mrn_gradient_new.border_shades[0] = 1.0;
1922 mrn_gradient_new.border_shades[1] = 1.0;
1923 if (!draw_bullet)
1924 mrn_gradient_new.has_border_colors = FALSE;
1925 }
1926 else if (!draw_bullet)
1927 {
1928 mrn_gradient_new = murrine_get_inverted_border_shades (mrn_gradient_new);
1929 mrn_gradient_new.has_border_colors = FALSE;
1930 }
1931
1932 murrine_draw_border (cr, &border,
1933 1.5, 1.5, width-3, height-3,
1934 roundness, widget->corners,
1935 mrn_gradient_new, 1.0);
1936 }
1937
1938 if (draw_bullet)
1939 {
1940 if (inconsistent)
1941 {
1942 cairo_save (cr);
1943 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1944 cairo_set_line_width (cr, 2.0);
1945
1946 cairo_move_to(cr, 5, (double)height/2);
1947 cairo_line_to(cr, width-5, (double)height/2);
1948
1949 murrine_set_color_rgba (cr, dot, trans);
1950 cairo_stroke (cr);
1951 cairo_restore (cr);
1952 }
1953 else
1954 {
1955 if (!draw_box)
1956 {
1957 cairo_arc (cr, (double)width/2, (double)height/2, (double)(width+height)/4-4, 0, G_PI*2);
1958 }
1959 else
1960 {
1961 MurrineRGB outline;
1962 murrine_invert_text (dot, &outline);
1963
1964 cairo_arc (cr, (double)width/2, (double)height/2, (double)(width+height)/4-4, 0, G_PI*2);
1965 murrine_set_color_rgba (cr, &outline, 0.3*trans*(widget->state_type == GTK_STATE_INSENSITIVE ? 0.2 : 1.0));
1966 cairo_fill (cr);
1967
1968 cairo_arc (cr, (double)width/2, (double)height/2, (double)(width+height)/4-5, 0, G_PI*2);
1969 }
1970
1971 murrine_set_color_rgba (cr, dot, trans);
1972 cairo_fill (cr);
1973 }
1974 }
1975 }
1976
1977 static void
murrine_rgba_draw_checkbox(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,const CheckboxParameters * checkbox,int x,int y,int width,int height,double trans)1978 murrine_rgba_draw_checkbox (cairo_t *cr,
1979 const MurrineColors *colors,
1980 const WidgetParameters *widget,
1981 const CheckboxParameters *checkbox,
1982 int x, int y, int width, int height,
1983 double trans)
1984 {
1985 MurrineRGB border;
1986 const MurrineRGB *dot;
1987 const MurrineRGB *bg = &colors->base[0];
1988 gboolean inconsistent = FALSE;
1989 gboolean draw_box = !checkbox->in_menu;
1990 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1991 int roundness = CLAMP (widget->roundness, 0, 2);
1992 double highlight_shade_new = widget->highlight_shade;
1993 double lightborder_shade_new = widget->lightborder_shade;
1994 MurrineGradients mrn_gradient_new = widget->mrn_gradient;
1995
1996 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1997 draw_bullet |= inconsistent;
1998
1999 if (widget->state_type == GTK_STATE_INSENSITIVE)
2000 {
2001 border = colors->shade[4];
2002 dot = &colors->shade[4];
2003 bg = &colors->bg[0];
2004
2005 mrn_gradient_new = murrine_get_decreased_gradient_shades (widget->mrn_gradient, 3.0);
2006 mrn_gradient_new.border_shades[0] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[0], 3.0);
2007 mrn_gradient_new.border_shades[1] = murrine_get_decreased_shade (widget->mrn_gradient.border_shades[1], 3.0);
2008 highlight_shade_new = murrine_get_decreased_shade (widget->highlight_shade, 2.0);
2009 lightborder_shade_new = murrine_get_decreased_shade (widget->lightborder_shade, 2.0);
2010 }
2011 else
2012 {
2013 border = colors->shade[6];
2014 if (draw_bullet)
2015 {
2016 border = colors->spot[2];
2017 bg = &colors->spot[1];
2018 }
2019 dot = &colors->text[widget->state_type];
2020 }
2021 murrine_mix_color (&border, widget->state_type != GTK_STATE_INSENSITIVE ?
2022 draw_bullet ? &colors->spot[1] : &colors->bg[0] : &colors->bg[0], 0.2, &border);
2023
2024 cairo_translate (cr, x, y);
2025
2026 if (draw_box)
2027 {
2028 if (widget->xthickness > 2 && widget->ythickness > 2)
2029 {
2030 if (widget->reliefstyle > 1 && draw_bullet && widget->state_type != GTK_STATE_INSENSITIVE)
2031 {
2032 if (widget->reliefstyle == 5)
2033 murrine_draw_shadow (cr, &widget->parentbg,
2034 0.5, 0.5, width-1, height-1,
2035 roundness+1, widget->corners,
2036 widget->reliefstyle,
2037 mrn_gradient_new, 0.5);
2038 else
2039 {
2040 MurrineRGB shadow;
2041 murrine_shade (&border, 0.9, &shadow);
2042
2043 murrine_draw_shadow (cr, &shadow,
2044 0.5, 0.5, width-1, height-1,
2045 roundness+1, widget->corners,
2046 widget->reliefstyle,
2047 mrn_gradient_new, 0.08);
2048 }
2049 }
2050 else if (widget->reliefstyle != 0)
2051 murrine_draw_inset (cr, &widget->parentbg, 0.5, 0.5, width-1, height-1, roundness+1, widget->corners);
2052 }
2053
2054 cairo_save (cr);
2055
2056 murrine_rounded_rectangle_closed (cr, 1.5, 1.5, width-3, height-3, roundness, widget->corners);
2057 cairo_clip_preserve (cr);
2058
2059 if (draw_bullet)
2060 {
2061 murrine_draw_glaze (cr, bg,
2062 widget->glow_shade, highlight_shade_new, lightborder_shade_new,
2063 mrn_gradient_new, widget, 2, 2, width-4, height-4,
2064 roundness, widget->corners, TRUE);
2065 }
2066 else
2067 {
2068 murrine_set_color_rgb (cr, bg);
2069 cairo_fill (cr);
2070 }
2071
2072 cairo_restore (cr);
2073
2074 if (checkbox->in_cell)
2075 {
2076 mrn_gradient_new.border_shades[0] = 1.0;
2077 mrn_gradient_new.border_shades[1] = 1.0;
2078 if (!draw_bullet)
2079 mrn_gradient_new.has_border_colors = FALSE;
2080 }
2081 else if (!draw_bullet)
2082 {
2083 mrn_gradient_new = murrine_get_inverted_border_shades (mrn_gradient_new);
2084 mrn_gradient_new.has_border_colors = FALSE;
2085 }
2086
2087 murrine_draw_border (cr, &border,
2088 1.5, 1.5, width-3, height-3,
2089 roundness, widget->corners,
2090 mrn_gradient_new, 1.0);
2091 }
2092
2093 if (draw_bullet)
2094 {
2095 if (inconsistent)
2096 {
2097 cairo_save (cr);
2098 cairo_set_line_width (cr, 2.0);
2099 cairo_move_to (cr, 3, (double)height/2);
2100 cairo_line_to (cr, width-3, (double)height/2);
2101 cairo_restore (cr);
2102 }
2103 else
2104 {
2105 if (!draw_box)
2106 {
2107 cairo_scale (cr, (double)width/18.0, (double)height/18.0);
2108 cairo_translate (cr, 2.0, 3.0);
2109 }
2110 else
2111 {
2112 MurrineRGB outline;
2113 murrine_invert_text (dot, &outline);
2114
2115 cairo_scale (cr, (double)width/18.0, (double)height/18.0);
2116
2117 cairo_move_to (cr, 5.0, 5.65);
2118 cairo_line_to (cr, 8.95, 9.57);
2119 cairo_line_to (cr, 16.0, 2.54);
2120 cairo_line_to (cr, 16.0, 8.36);
2121 cairo_line_to (cr, 10.6, 15.1);
2122 cairo_line_to (cr, 7.6, 15.1);
2123 cairo_line_to (cr, 2.95, 10.48);
2124 cairo_line_to (cr, 2.95, 7.65);
2125 cairo_close_path (cr);
2126
2127 murrine_set_color_rgba (cr, &outline, 0.5*trans*(widget->state_type == GTK_STATE_INSENSITIVE ? 0.2 : 1.0));
2128 cairo_fill (cr);
2129
2130 cairo_translate (cr, 4.0, 2.0);
2131 }
2132 cairo_move_to (cr, 0.0, 6.0);
2133 cairo_line_to (cr, 0.0, 8.0);
2134 cairo_line_to (cr, 4.0, 12.0);
2135 cairo_line_to (cr, 6.0, 12.0);
2136 cairo_line_to (cr, 15.0, 1.0);
2137 cairo_line_to (cr, 15.0, 0.0);
2138 cairo_line_to (cr, 14.0, 0.0);
2139 cairo_line_to (cr, 5.0, 9.0);
2140 cairo_line_to (cr, 1.0, 5.0);
2141 cairo_close_path (cr);
2142 }
2143 murrine_set_color_rgba (cr, dot, trans);
2144 cairo_fill (cr);
2145 }
2146 }
2147
2148 static void
murrine_rgba_draw_menu_frame(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,int x,int y,int width,int height,int menustyle)2149 murrine_rgba_draw_menu_frame (cairo_t *cr,
2150 const MurrineColors *colors,
2151 const WidgetParameters *widget,
2152 int x, int y, int width, int height,
2153 int menustyle)
2154 {
2155 uint8 corners = (menustyle == 1 ? MRN_CORNER_BOTTOMRIGHT :
2156 MRN_CORNER_BOTTOMLEFT | MRN_CORNER_BOTTOMRIGHT);
2157
2158 cairo_translate (cr, x, y);
2159
2160 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
2161 cairo_paint (cr);
2162 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2163
2164 murrine_set_color_rgba (cr, &colors->bg[0], MENU_OPACITY);
2165 clearlooks_rounded_rectangle (cr, 0, 0, width, height, widget->roundness > 1 ? widget->roundness+1 : 0, corners);
2166 cairo_fill (cr);
2167
2168 switch (menustyle)
2169 {
2170 case 1:
2171 {
2172 MurrineRGB *fill = (MurrineRGB*)&colors->spot[1];
2173 MurrineRGB border2;
2174 murrine_shade (fill, 0.5, &border2);
2175
2176 murrine_set_color_rgb (cr, &border2);
2177 cairo_rectangle (cr, 0.5, 0.5, 3, height-1);
2178 cairo_stroke_preserve (cr);
2179
2180 murrine_set_color_rgb (cr, fill);
2181 cairo_fill (cr);
2182 }
2183 default:
2184 case 0:
2185 {
2186 const MurrineRGB *border = &colors->shade[5];
2187
2188 murrine_set_color_rgb (cr, border);
2189 murrine_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, widget->roundness, corners);
2190 cairo_stroke (cr);
2191 break;
2192 }
2193 case 2:
2194 {
2195 const MurrineRGB *border = &colors->shade[2];
2196 MurrineRGB fill;
2197 raico_blur_t* blur = NULL;
2198 cairo_t *cr_surface;
2199 cairo_surface_t *surface;
2200 cairo_pattern_t *pat;
2201 int bradius = 30;
2202 int bheight = MIN (height, 300);
2203
2204 murrine_shade (&colors->bg[0], 1.14, &fill);
2205
2206 murrine_set_color_rgb (cr, border);
2207 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
2208 cairo_stroke (cr);
2209
2210 /* draw glow */
2211 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, bheight);
2212 cr_surface = cairo_create (surface);
2213 blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
2214 raico_blur_set_radius (blur, bradius);
2215 cairo_set_line_width (cr_surface, 1.0);
2216 cairo_rectangle (cr_surface, bradius, bradius-15, width-bradius*2, bheight-bradius*2+15);
2217 murrine_set_color_rgb (cr_surface, &fill);
2218 cairo_fill (cr_surface);
2219 raico_blur_apply (blur, surface);
2220 cairo_rectangle (cr_surface, 0, -15, width, bheight+15);
2221 pat = cairo_pattern_create_linear (0, -15, 0.0, bheight+15);
2222 murrine_pattern_add_color_stop_rgba (pat, 0.25, &colors->bg[0], 0.0);
2223 murrine_pattern_add_color_stop_rgba (pat, 1.0, &colors->bg[0], 1.0);
2224 cairo_set_source (cr_surface, pat);
2225 cairo_pattern_destroy (pat);
2226 cairo_fill (cr_surface);
2227 cairo_set_source_surface (cr, surface, 0, 0);
2228 cairo_paint (cr);
2229 cairo_surface_destroy (surface);
2230 cairo_destroy (cr_surface);
2231 break;
2232 }
2233 case 3:
2234 {
2235 MurrineRGB border;
2236 MurrineRGB fill;
2237 raico_blur_t* blur = NULL;
2238 cairo_t *cr_surface;
2239 cairo_surface_t *surface;
2240 cairo_pattern_t *pat;
2241 int bradius = 30;
2242 int bheight = MIN (height, 300);
2243
2244 murrine_shade (&colors->bg[0], murrine_get_contrast(1.1, widget->contrast), &border);
2245 murrine_shade (&colors->bg[0], 0.96, &fill);
2246
2247 murrine_set_color_rgb (cr, &border);
2248 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
2249 cairo_stroke (cr);
2250
2251 /* draw glow */
2252 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, bheight);
2253 cr_surface = cairo_create (surface);
2254 blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
2255 raico_blur_set_radius (blur, bradius);
2256 cairo_set_line_width (cr_surface, 1.0);
2257 cairo_rectangle (cr_surface, bradius, bradius-15, width-bradius*2, bheight-bradius*2+15);
2258 murrine_set_color_rgb (cr_surface, &fill);
2259 cairo_fill (cr_surface);
2260 raico_blur_apply (blur, surface);
2261 cairo_rectangle (cr_surface, 0, -15, width, bheight+15);
2262 pat = cairo_pattern_create_linear (0, -15, 0.0, bheight+15);
2263 murrine_pattern_add_color_stop_rgba (pat, 0.25, &colors->bg[0], 0.0);
2264 murrine_pattern_add_color_stop_rgba (pat, 1.0, &colors->bg[0], 1.0);
2265 cairo_set_source (cr_surface, pat);
2266 cairo_pattern_destroy (pat);
2267 cairo_fill (cr_surface);
2268 cairo_set_source_surface (cr, surface, 0, 0);
2269 cairo_paint (cr);
2270 cairo_surface_destroy (surface);
2271 cairo_destroy (cr_surface);
2272 break;
2273 }
2274 }
2275 }
2276
2277 static void
murrine_rgba_draw_statusbar(cairo_t * cr,const MurrineColors * colors,const WidgetParameters * widget,int x,int y,int width,int height)2278 murrine_rgba_draw_statusbar (cairo_t *cr,
2279 const MurrineColors *colors,
2280 const WidgetParameters *widget,
2281 int x, int y, int width, int height)
2282 {
2283 const MurrineRGB *dark = &colors->shade[4];
2284 const MurrineRGB *highlight = &colors->shade[0];
2285
2286 cairo_translate (cr, x, y+0.5);
2287
2288 murrine_set_color_rgb (cr, dark);
2289 cairo_move_to (cr, 0, 0);
2290 cairo_line_to (cr, width, 0);
2291 cairo_stroke (cr);
2292
2293 murrine_set_color_rgba (cr, highlight, 0.5);
2294 cairo_move_to (cr, 0, 1);
2295 cairo_line_to (cr, width, 1);
2296 cairo_stroke (cr);
2297 }
2298
2299 void
murrine_register_style_rgba(MurrineStyleFunctions * functions)2300 murrine_register_style_rgba (MurrineStyleFunctions *functions)
2301 {
2302 functions->draw_button = murrine_rgba_draw_button;
2303 functions->draw_entry = murrine_rgba_draw_entry;
2304 functions->draw_scale_trough = murrine_rgba_draw_scale_trough;
2305 functions->draw_slider = murrine_rgba_draw_slider;
2306 functions->draw_spinbutton = murrine_rgba_draw_spinbutton;
2307 functions->draw_progressbar_trough = murrine_rgba_draw_progressbar_trough;
2308 functions->draw_progressbar_fill = murrine_rgba_draw_progressbar_fill;
2309 functions->draw_menubar = murrine_rgba_draw_menubar;
2310 functions->draw_toolbar = murrine_rgba_draw_toolbar;
2311 functions->draw_frame = murrine_rgba_draw_frame;
2312 functions->draw_tab = murrine_rgba_draw_tab;
2313 functions->draw_scrollbar_trough = murrine_rgba_draw_scrollbar_trough;
2314 functions->draw_scrollbar_stepper = murrine_rgba_draw_scrollbar_stepper;
2315 functions->draw_scrollbar_slider = murrine_rgba_draw_scrollbar_slider;
2316 functions->draw_handle = murrine_rgba_draw_handle;
2317 functions->draw_tooltip = murrine_rgba_draw_tooltip;
2318 functions->draw_radiobutton = murrine_rgba_draw_radiobutton;
2319 functions->draw_checkbox = murrine_rgba_draw_checkbox;
2320 functions->draw_menu_frame = murrine_rgba_draw_menu_frame;
2321 functions->draw_statusbar = murrine_rgba_draw_statusbar;
2322 }
2323