static void clearlooks_glossy_draw_progressbar_trough (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[6]; CairoColor shadow; cairo_pattern_t *pattern; double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0)); cairo_save (cr); cairo_set_line_width (cr, 1.0); /* Fill with bg color */ ge_cairo_set_color (cr, &colors->bg[params->state_type]); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); /* Create trough box */ ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners); ge_cairo_set_color (cr, &colors->shade[2]); cairo_fill (cr); /* Draw border */ ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners); clearlooks_set_mixed_color (cr, border, &colors->shade[2], 0.3); cairo_stroke (cr); /* clip the corners of the shadows */ ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners); cairo_clip (cr); ge_shade_color (border, 0.92, &shadow); /* Top shadow */ cairo_rectangle (cr, x+1, y+1, width-2, 4); pattern = cairo_pattern_create_linear (x, y, x, y+4); cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3); cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); /* Left shadow */ cairo_rectangle (cr, x+1, y+1, 4, height-2); pattern = cairo_pattern_create_linear (x, y, x+4, y); cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.3); cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_restore (cr); }
static void clearlooks_glossy_draw_slider (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[7]; CairoColor fill; CairoColor hilight; CairoColor a, b, c, d; cairo_pattern_t *pattern; cairo_set_line_width (cr, 1.0); cairo_translate (cr, x, y); cairo_translate (cr, -0.5, -0.5); ge_shade_color (&colors->bg[params->state_type], 1.0, &fill); if (params->prelight) ge_shade_color (&fill, 1.1, &fill); ge_shade_color (&fill, 1.25, &hilight); ge_shade_color (&fill, 1.16, &a); ge_shade_color (&fill, 1.08, &b); ge_shade_color (&fill, 1.0, &c); ge_shade_color (&fill, 1.08, &d); pattern = cairo_pattern_create_linear (1, 1, 1, height-2); cairo_pattern_add_color_stop_rgb (pattern, 0, a.r, a.g, a.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, b.r, b.g, b.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, c.r, c.g, c.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, d.r, d.g, d.b); cairo_rectangle (cr, 1, 1, width-2, height-2); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); clearlooks_set_mixed_color (cr, border, &fill, 0.2); if (params->prelight) ge_cairo_set_color (cr, &colors->spot[2]); ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, 2.5, params->corners); cairo_stroke (cr); cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5); ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, 2.0, params->corners); cairo_stroke (cr); }
static void clearlooks_glossy_scale_draw_gradient (cairo_t *cr, const CairoColor *c1, const CairoColor *c2, const CairoColor *c3, int x, int y, int width, int height, boolean horizontal) { cairo_pattern_t *pattern; pattern = cairo_pattern_create_linear (0, 0, horizontal ? 0 : width, horizontal ? height : 0); cairo_pattern_add_color_stop_rgb (pattern, 0.0, c1->r, c1->g, c1->b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, c2->r, c2->g, c2->b); cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); clearlooks_set_mixed_color (cr, c3, c1, 0.3); ge_cairo_stroke_rectangle (cr, x, y, width, height); }
static void clearlooks_glossy_draw_scrollbar_slider (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const ScrollBarParameters *scrollbar, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[7]; CairoColor fill = scrollbar->color; CairoColor hilight; CairoColor shade1, shade2, shade3; cairo_pattern_t *pattern; if (scrollbar->junction & CL_JUNCTION_BEGIN) { if (scrollbar->horizontal) { x -= 1; width += 1; } else { y -= 1; height += 1; } } if (scrollbar->junction & CL_JUNCTION_END) { if (scrollbar->horizontal) width += 1; else height += 1; } if (!scrollbar->horizontal) ge_cairo_exchange_axis (cr, &x, &y, &width, &height); cairo_translate (cr, x, y); if (widget->prelight) ge_shade_color (&fill, 1.1, &fill); cairo_set_line_width (cr, 1); ge_shade_color (&fill, 1.25, &hilight); ge_shade_color (&fill, 1.16, &shade1); ge_shade_color (&fill, 1.08, &shade2); ge_shade_color (&fill, 1.08, &shade3); pattern = cairo_pattern_create_linear (1, 1, 1, height-2); cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill.r, fill.g, fill.b); cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b); cairo_rectangle (cr, 1, 1, width-2, height-2); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); if (scrollbar->has_color) { cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5); ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3); } clearlooks_set_mixed_color (cr, border, &fill, scrollbar->has_color? 0.4 : 0.2); ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1); }
static void clearlooks_glossy_draw_scrollbar_stepper (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const ScrollBarParameters *scrollbar, const ScrollBarStepperParameters *stepper, int x, int y, int width, int height) { CairoCorners corners = CR_CORNER_NONE; const CairoColor *border = &colors->shade[7]; CairoColor fill, s1, s2, s4; cairo_pattern_t *pattern; ShadowParameters shadow; double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0)); if (scrollbar->horizontal) { if (stepper->stepper == CL_STEPPER_START) corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT; else if (stepper->stepper == CL_STEPPER_END) corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT; if (stepper->stepper == CL_STEPPER_START_INNER) { x -= 1; width += 1; } else if (stepper->stepper == CL_STEPPER_END_INNER) { width += 1; } } else { if (stepper->stepper == CL_STEPPER_START) corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT; else if (stepper->stepper == CL_STEPPER_END) corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT; if (stepper->stepper == CL_STEPPER_START_INNER) { y -= 1; height += 1; } else if (stepper->stepper == CL_STEPPER_END_INNER) { height += 1; } } cairo_translate (cr, x, y); cairo_set_line_width (cr, 1); ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners); if (scrollbar->horizontal) pattern = cairo_pattern_create_linear (0, 0, 0, height); else pattern = cairo_pattern_create_linear (0, 0, width, 0); fill = colors->bg[widget->state_type]; ge_shade_color(&fill, 1.16, &s1); ge_shade_color(&fill, 1.08, &s2); ge_shade_color(&fill, 1.08, &s4); cairo_pattern_add_color_stop_rgb(pattern, 0, s1.r, s1.g, s1.b); cairo_pattern_add_color_stop_rgb(pattern, 0.5, s2.r, s2.g, s2.b); cairo_pattern_add_color_stop_rgb(pattern, 0.5, fill.r, fill.g, fill.b); cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners); clearlooks_set_mixed_color (cr, border, &fill, 0.2); if (widget->prelight) ge_cairo_set_color (cr, &colors->spot[2]); cairo_stroke (cr); shadow.shadow = CL_SHADOW_OUT; shadow.corners = corners; }
static void clearlooks_glossy_draw_button (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { double xoffset = 0, yoffset = 0; CairoColor fill = colors->bg[params->state_type]; CairoColor border_normal = colors->shade[6]; CairoColor border_disabled = colors->shade[4]; double radius; cairo_pattern_t *pattern; cairo_save (cr); cairo_translate (cr, x, y); cairo_set_line_width (cr, 1.0); /* Shadows and shadow */ if (params->xthickness == 3 || params->ythickness == 3) { if (params->xthickness == 3) xoffset = 1; if (params->ythickness == 3) yoffset = 1; } radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0, (height - 2.0 - 2*yoffset) / 2.0)); if (params->xthickness == 3 || params->ythickness == 3) { /* if (params->enable_shadow && !params->active && !params->disabled) */ if (!params->active && (params->prelight || params->enable_shadow)) { /* shadow becomes a shadow to have 3d prelight buttons :) */ CairoColor shadow; radius = MIN (params->radius, MIN ((width - 2.0 - 2*xoffset) / 2.0 - 1.0, (height - 2.0 - 2*yoffset) / 2.0 - 1.0)); ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius+1, params->corners); ge_shade_color (¶ms->parentbg, 0.96, &shadow); ge_cairo_set_color (cr, &shadow); cairo_stroke (cr); ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-2, height-2, radius+1, params->corners); ge_shade_color (¶ms->parentbg, 0.92, &shadow); ge_cairo_set_color (cr, &shadow); cairo_stroke (cr); } else { if (!(params->disabled)) params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, params->radius+1, params->corners); else /*Draw a lighter inset */ clearlooks_glossy_draw_light_inset (cr, ¶ms->parentbg, 0, 0, width, height, params->radius+1, params->corners); } } clearlooks_draw_glossy_gradient (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, height-(yoffset*2)-2, &fill, params->disabled, radius, params->corners); /* Pressed button shadow */ if (params->active) { CairoColor shadow; ge_shade_color (&fill, 0.92, &shadow); cairo_save (cr); 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)); cairo_clip (cr); cairo_rectangle (cr, xoffset+1, yoffset+1, width-(xoffset*2)-2, 3); pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+1, yoffset+4); cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58); cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_rectangle (cr, xoffset+1, yoffset+1, 3, height-(yoffset*2)-2); pattern = cairo_pattern_create_linear (xoffset+1, yoffset+1, xoffset+4, yoffset+1); cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.58); cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_restore (cr); } /* Default button highlight */ if (params->is_default && !params->active && !params->disabled) { const CairoColor *shadow = &colors->spot[0]; double hh = (height-5)/2.0 + 1; cairo_rectangle (cr, 3.5, 3.5, width-7, height-7); ge_cairo_set_color (cr, shadow); cairo_stroke (cr); shadow = &colors->spot[0]; cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, -hh); cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, hh); ge_cairo_set_color (cr, shadow); cairo_stroke (cr); hh--; shadow = &colors->spot[1]; cairo_move_to (cr, 2.5, 2.5+hh); cairo_rel_line_to (cr, 0, hh); cairo_rel_line_to (cr, width-5, 0); cairo_rel_line_to (cr, 0, -hh); ge_cairo_set_color (cr, shadow); cairo_stroke (cr); } /* Border */ if (params->is_default || (params->prelight && params->enable_shadow)) border_normal = colors->spot[2]; /* ge_mix_color (&border_normal, &colors->spot[2], 0.5, &border_normal); */ if (params->disabled) ge_cairo_set_color (cr, &border_disabled); else clearlooks_set_mixed_color (cr, &border_normal, &fill, 0.2); ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5, width-(xoffset*2)-1, height-(yoffset*2)-1, radius, params->corners); cairo_stroke (cr); cairo_restore (cr); }
static void clearlooks_glossy_draw_checkbox (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const CheckboxParameters *checkbox, int x, int y, int width, int height) { const CairoColor *border; const CairoColor *dot; gboolean inconsistent = FALSE; gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; if (widget->disabled) { border = &colors->shade[5]; dot = &colors->shade[6]; } else { if (widget->prelight) border = &colors->spot[2]; else border = &colors->shade[6]; dot = &colors->text[GTK_STATE_NORMAL]; } cairo_translate (cr, x, y); cairo_set_line_width (cr, 1); if (widget->xthickness > 2 && widget->ythickness > 2) { widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0, width, height, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL); /* Draw the rectangle for the checkbox itself */ ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL); } else { /* Draw the rectangle for the checkbox itself */ ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL); } if (!widget->disabled) { if (widget->prelight) clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5); else ge_cairo_set_color (cr, &colors->base[0]); cairo_fill_preserve (cr); } ge_cairo_set_color (cr, border); cairo_stroke (cr); if (draw_bullet) { if (inconsistent) /* Inconsistent */ { cairo_set_line_width (cr, 2.0); cairo_move_to (cr, 3, height*0.5); cairo_line_to (cr, width-3, height*0.5); } else { cairo_set_line_width (cr, 1.7); cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5)); cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7)); cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7), 0.5 + (width*0.5), (height*0.4), 0.5 + (width*0.70), (height*0.25)); } ge_cairo_set_color (cr, dot); cairo_stroke (cr); } }
static void clearlooks_glossy_draw_radiobutton (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const CheckboxParameters *checkbox, int x, int y, int width, int height) { const CairoColor *border; const CairoColor *dot; CairoColor shadow; CairoColor highlight; cairo_pattern_t *pt; gboolean inconsistent; gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); gdouble w, h, cx, cy, radius; w = (gdouble) width; h = (gdouble) height; cx = width / 2.0; cy = height / 2.0; radius = MIN (width, height) / 2.0; inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; if (widget->disabled) { border = &colors->shade[5]; dot = &colors->shade[6]; } else { if (widget->prelight) border = &colors->spot[2]; else border = &colors->shade[6]; dot = &colors->text[0]; } ge_shade_color (&widget->parentbg, 0.9, &shadow); ge_shade_color (&widget->parentbg, 1.1, &highlight); pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0); cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g); cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5); cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5); cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b); cairo_translate (cr, x, y); cairo_set_line_width (cr, MAX (1.0, floor (radius/3))); cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2); cairo_set_source (cr, pt); cairo_stroke (cr); cairo_pattern_destroy (pt); cairo_set_line_width (cr, MAX (1.0, floor (radius/6))); cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2); if (!widget->disabled) { if (widget->prelight) clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5); else ge_cairo_set_color (cr, &colors->base[0]); cairo_fill_preserve (cr); } ge_cairo_set_color (cr, border); cairo_stroke (cr); if (draw_bullet) { if (inconsistent) { cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_width (cr, ceil (radius * 2 / 3)); cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy)); cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy)); ge_cairo_set_color (cr, dot); cairo_stroke (cr); } else { cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2); ge_cairo_set_color (cr, dot); cairo_fill (cr); cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2); cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5); cairo_fill (cr); } } }
static void clearlooks_glossy_draw_radiobutton (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const CheckboxParameters *checkbox, int x, int y, int width, int height) { const CairoColor *border; const CairoColor *dot; CairoColor shadow; CairoColor highlight; cairo_pattern_t *pt; gboolean inconsistent; gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN); (void) width; (void) height; inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN); draw_bullet |= inconsistent; if (widget->disabled) { border = &colors->shade[5]; dot = &colors->shade[6]; } else { if (widget->prelight) border = &colors->spot[2]; else border = &colors->shade[6]; dot = &colors->text[0]; } ge_shade_color (&widget->parentbg, 0.9, &shadow); ge_shade_color (&widget->parentbg, 1.1, &highlight); pt = cairo_pattern_create_linear (0, 0, 13, 13); cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g); cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5); cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5); cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b); cairo_translate (cr, x, y); cairo_set_line_width (cr, 2); cairo_arc (cr, 7, 7, 6, 0, G_PI*2); cairo_set_source (cr, pt); cairo_stroke (cr); cairo_pattern_destroy (pt); cairo_set_line_width (cr, 1); cairo_arc (cr, 7, 7, 5.5, 0, G_PI*2); if (!widget->disabled) { if (widget->prelight) clearlooks_set_mixed_color (cr, &colors->base[0], &colors->spot[1], 0.5); else ge_cairo_set_color (cr, &colors->base[0]); cairo_fill_preserve (cr); } ge_cairo_set_color (cr, border); cairo_stroke (cr); if (draw_bullet) { if (inconsistent) { cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_width (cr, 4); cairo_move_to(cr, 5, 7); cairo_line_to(cr, 9, 7); ge_cairo_set_color (cr, dot); cairo_stroke (cr); } else { cairo_arc (cr, 7, 7, 3, 0, G_PI*2); ge_cairo_set_color (cr, dot); cairo_fill (cr); cairo_arc (cr, 6, 6, 1, 0, G_PI*2); cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5); cairo_fill (cr); } } }