aboutsummaryrefslogtreecommitdiff
path: root/src/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout.c')
-rw-r--r--src/layout.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/layout.c b/src/layout.c
index db707c5..3c4f13b 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -93,30 +93,41 @@ void layout_init(layout_t *layout, block_t *block, layout_info_t info)
void layout_render(layout_t *layout, cairo_t *cr)
{
- double degree = M_PI / 180.0;
+ const double degree = M_PI / 180.0;
int radius = layout->height / 2 - layout->y_padding;
int line_radius = radius - layout->block->line_width / 2;
- // Render background
- color_t color = layout->block->color;
- cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
+ // Update gradients
+ cairo_matrix_t matrix;
+ cairo_matrix_init_scale(&matrix, 1.0 / layout->width, 1.0);
+ cairo_matrix_translate(&matrix, -layout->x, 0.0);
- cairo_new_sub_path(cr);
- cairo_arc(cr, layout->x + layout->x_padding + radius, layout->y + layout->y_padding + radius, radius, 90 * degree, 270 * degree);
- cairo_arc(cr, layout->x + layout->width - layout->x_padding - radius, layout->y + layout->y_padding + radius, radius, 270 * degree, 450 * degree);
- cairo_close_path(cr);
- cairo_fill(cr);
+ // Render background
+ cairo_pattern_t *pattern = layout->block->bg_color.cached;
+ if (pattern != NULL) {
+ cairo_new_sub_path(cr);
+ cairo_arc(cr, layout->x + layout->x_padding + radius, layout->y + layout->y_padding + radius, radius, 90 * degree, 270 * degree);
+ cairo_arc(cr, layout->x + layout->width - layout->x_padding - radius, layout->y + layout->y_padding + radius, radius, 270 * degree, 450 * degree);
+ cairo_close_path(cr);
+
+ cairo_pattern_set_matrix(pattern, &matrix);
+ cairo_set_source(cr, pattern);
+ cairo_fill(cr);
+ }
// Render border
- color = layout->block->line_color;
- cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
- cairo_set_line_width(cr, layout->block->line_width);
-
- cairo_new_sub_path(cr);
- cairo_arc(cr, layout->x + layout->x_padding + radius, layout->y + layout->y_padding + radius, line_radius, 90 * degree, 270 * degree);
- cairo_arc(cr, layout->x + layout->width - layout->x_padding - radius, layout->y + layout->y_padding + radius, line_radius, 270 * degree, 450 * degree);
- cairo_close_path(cr);
- cairo_stroke(cr);
+ pattern = layout->block->line_color.cached;
+ if (pattern != NULL) {
+ cairo_new_sub_path(cr);
+ cairo_arc(cr, layout->x + layout->x_padding + radius, layout->y + layout->y_padding + radius, line_radius, 90 * degree, 270 * degree);
+ cairo_arc(cr, layout->x + layout->width - layout->x_padding - radius, layout->y + layout->y_padding + radius, line_radius, 270 * degree, 450 * degree);
+ cairo_close_path(cr);
+
+ cairo_pattern_set_matrix(pattern, &matrix);
+ cairo_set_source(cr, pattern);
+ cairo_set_line_width(cr, layout->block->line_width);
+ cairo_stroke(cr);
+ }
switch (layout->block->type) {
case BLOCK_TEXT: {
@@ -126,7 +137,7 @@ void layout_render(layout_t *layout, cairo_t *cr)
int text_x = layout->x + (layout->width - layout->text_width) / 2;
int text_y = layout->y + (layout->height - layout->text_height) / 2;
- color = text->text_color;
+ color_t color = text->text_color;
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
cairo_move_to(cr, text_x, text_y);