static void clearlooks_glossy_draw_tab (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, const TabParameters *tab, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[5]; const CairoColor *stripe_fill = &colors->spot[1]; const CairoColor *stripe_border = &colors->spot[2]; const CairoColor *fill; CairoColor hilight; cairo_pattern_t *pattern; double radius; double strip_size; double length; radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0)); /* Set clip */ cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); cairo_new_path (cr); /* Translate and set line width */ cairo_set_line_width (cr, 1.0); cairo_translate (cr, x+0.5, y+0.5); /* Make the tabs slightly bigger than they should be, to create a gap */ /* And calculate the strip size too, while you're at it */ if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM) { height += 3.0; length = height; strip_size = 2.0/height; /* 2 pixel high strip */ if (tab->gap_side == CL_GAP_TOP) cairo_translate (cr, 0.0, -3.0); /* gap at the other side */ } else { width += 3.0; length = width; strip_size = 2.0/width; if (tab->gap_side == CL_GAP_LEFT) cairo_translate (cr, -3.0, 0.0); /* gap at the other side */ } /* Set the fill color */ fill = &colors->bg[params->state_type]; /* Set tab shape */ ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); /* Draw fill */ ge_cairo_set_color (cr, fill); cairo_fill (cr); ge_shade_color (fill, 1.3, &hilight); /* Draw highlight */ if (!params->active) { ShadowParameters shadow; shadow.shadow = CL_SHADOW_OUT; shadow.corners = params->corners; /* This is the only usage of clearlooks_glossy_draw_highlight_and_shade, * the function assumes currently that the input is translated by 0.5 px. */ clearlooks_glossy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow, width, height, radius); } if (params->active) { CairoColor shadow, hilight, f1, f2; switch (tab->gap_side) { case CL_GAP_TOP: pattern = cairo_pattern_create_linear (0, height-2, 0, 0); break; case CL_GAP_BOTTOM: pattern = cairo_pattern_create_linear (0, 1, 0, height); break; case CL_GAP_LEFT: pattern = cairo_pattern_create_linear (width-2, 0, 1, 0); break; case CL_GAP_RIGHT: pattern = cairo_pattern_create_linear (1, 0, width-2, 0); break; default: pattern = NULL; } ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); ge_shade_color (fill, 1.06, &shadow); ge_shade_color (fill, 1.18, &hilight); ge_shade_color (fill, 1.12, &f1); ge_shade_color (fill, 1.06, &f2); cairo_pattern_add_color_stop_rgb (pattern, 0.0, hilight.r, hilight.g, hilight.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, hilight.r, hilight.g, hilight.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, f1.r, f1.g, f1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.45, f2.r, f2.g, f2.b); cairo_pattern_add_color_stop_rgb (pattern, 0.45, fill->r, fill->g, fill->b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r, shadow.g, shadow.b); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); } else { /* Draw shade */ switch (tab->gap_side) { case CL_GAP_TOP: pattern = cairo_pattern_create_linear (0, height-2, 0, 0); break; case CL_GAP_BOTTOM: pattern = cairo_pattern_create_linear (0, 0, 0, height); break; case CL_GAP_LEFT: pattern = cairo_pattern_create_linear (width-2, 0, 0, 0); break; case CL_GAP_RIGHT: pattern = cairo_pattern_create_linear (0, 0, width, 0); break; default: pattern = NULL; } ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); cairo_pattern_add_color_stop_rgba (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.5); cairo_pattern_add_color_stop_rgba (pattern, 0.8, fill->r, fill->g, fill->b, 0.0); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); } ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); if (params->active) { ge_cairo_set_color (cr, border); cairo_stroke (cr); } else { switch (tab->gap_side) { case CL_GAP_TOP: pattern = cairo_pattern_create_linear (2, height-2, 2, 2); break; case CL_GAP_BOTTOM: pattern = cairo_pattern_create_linear (2, 2, 2, height); break; case CL_GAP_LEFT: pattern = cairo_pattern_create_linear (width-2, 2, 2, 2); break; case CL_GAP_RIGHT: pattern = cairo_pattern_create_linear (2, 2, width, 2); break; default: pattern = NULL; } cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b); cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r, border->g, border->b); cairo_set_source (cr, pattern); cairo_stroke (cr); cairo_pattern_destroy (pattern); } }
static void clearlooks_glossy_draw_tab (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, const TabParameters *tab, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[5]; const CairoColor *stripe_fill = &colors->spot[1]; const CairoColor *stripe_border = &colors->spot[2]; const CairoColor *fill; CairoColor hilight; cairo_pattern_t *pattern; double radius; radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0)); /* Set clip */ cairo_rectangle (cr, x, y, width, height); cairo_clip (cr); cairo_new_path (cr); /* Translate and set line width */ cairo_set_line_width (cr, 1.0); cairo_translate (cr, x+0.5, y+0.5); /* Make the tabs slightly bigger than they should be, to create a gap */ /* And calculate the strip size too, while you're at it */ if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM) { height += 3.0; if (tab->gap_side == CL_GAP_TOP) cairo_translate (cr, 0.0, -3.0); /* gap at the other side */ } else { width += 3.0; if (tab->gap_side == CL_GAP_LEFT) cairo_translate (cr, -3.0, 0.0); /* gap at the other side */ } /* Set the fill color */ fill = &colors->bg[params->state_type]; /* Set tab shape */ ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); /* Draw fill */ ge_cairo_set_color (cr, fill); cairo_fill (cr); ge_shade_color (fill, 1.3, &hilight); /* Draw highlight */ if (!params->active) { ShadowParameters shadow; shadow.shadow = CL_SHADOW_OUT; shadow.corners = params->corners; clearlooks_glossy_draw_highlight_and_shade (cr, &colors->bg[0], &shadow, width, height, radius); } if (params->active) { CairoColor shadow, f1, f2; pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-1 : 0, tab->gap_side == CL_GAP_TOP ? height-2 : 1, tab->gap_side == CL_GAP_RIGHT ? width : 0, tab->gap_side == CL_GAP_BOTTOM ? height : 0); ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); ge_shade_color (fill, 1.06, &shadow); ge_shade_color (fill, 1.18, &hilight); ge_shade_color (fill, 1.12, &f1); ge_shade_color (fill, 1.06, &f2); cairo_pattern_add_color_stop_rgb (pattern, 0.0, hilight.r, hilight.g, hilight.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, hilight.r, hilight.g, hilight.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0/height, f1.r, f1.g, f1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.45, f2.r, f2.g, f2.b); cairo_pattern_add_color_stop_rgb (pattern, 0.45, fill->r, fill->g, fill->b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r, shadow.g, shadow.b); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); } else { /* Draw shade */ pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-2 : 0, tab->gap_side == CL_GAP_TOP ? height-2 : 0, tab->gap_side == CL_GAP_RIGHT ? width : 0, tab->gap_side == CL_GAP_BOTTOM ? height : 0); ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); cairo_pattern_add_color_stop_rgba (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b, 0.5); cairo_pattern_add_color_stop_rgba (pattern, 0.8, fill->r, fill->g, fill->b, 0.0); cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); } ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners); if (params->active) { ge_cairo_set_color (cr, border); cairo_stroke (cr); } else { pattern = cairo_pattern_create_linear (tab->gap_side == CL_GAP_LEFT ? width-2 : 2, tab->gap_side == CL_GAP_TOP ? height-2 : 2, tab->gap_side == CL_GAP_RIGHT ? width : 2, tab->gap_side == CL_GAP_BOTTOM ? height : 2); cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b); cairo_pattern_add_color_stop_rgb (pattern, 0.8, border->r, border->g, border->b); cairo_set_source (cr, pattern); cairo_stroke (cr); cairo_pattern_destroy (pattern); } }