From 6bb814bae6e1d85b080e13c26b15b224bc0fe3a2 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 9 Aug 2016 16:01:01 -0300 Subject: [PATCH] eeshow/gui-over.h: use struct for color, instead of array That way, we can use assignments on them. --- eeshow/gui-over.c | 12 ++++++------ eeshow/gui-over.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/eeshow/gui-over.c b/eeshow/gui-over.c index 409b42d..cfdd9ef 100644 --- a/eeshow/gui-over.c +++ b/eeshow/gui-over.c @@ -68,9 +68,9 @@ static void rrect(cairo_t *cr, int x, int y, int w, int h, int r) struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y) { const struct overlay_style *style = &over->style; - const double *fg = style->fg; - const double *bg = style->bg; - const double *frame = style->frame; + const struct color *fg = &style->fg; + const struct color *bg = &style->bg; + const struct color *frame = &style->frame; unsigned ink_w, ink_h; /* effectively used text area size */ unsigned w, h; /* box size */ int tx, ty; /* text start position */ @@ -120,9 +120,9 @@ fprintf(stderr, "%d + %d %d + %d\n", rrect(cr, sx, sy, w, h, style->radius); - cairo_set_source_rgba(cr, bg[0], bg[1], bg[2], bg[3]); + cairo_set_source_rgba(cr, bg->r, bg->g, bg->b, bg->alpha); cairo_fill_preserve(cr); - cairo_set_source_rgba(cr, frame[0], frame[1], frame[2], frame[3]); + cairo_set_source_rgba(cr, frame->r, frame->g, frame->b, frame->alpha); cairo_set_line_width(cr, style->width); cairo_stroke(cr); @@ -147,7 +147,7 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over-> cairo_clip(cr); } - cairo_set_source_rgba(cr, fg[0], fg[1], fg[2], fg[3]); + cairo_set_source_rgba(cr, fg->r, fg->g, fg->b, fg->alpha); cairo_move_to(cr, tx, ty); pango_cairo_update_layout(cr, layout); diff --git a/eeshow/gui-over.h b/eeshow/gui-over.h index d734588..d11bcef 100644 --- a/eeshow/gui-over.h +++ b/eeshow/gui-over.h @@ -21,15 +21,20 @@ #include "gui-aoi.h" +struct color { + double r, g, b, alpha; +}; + + struct overlay_style { const char *font; unsigned wmin, wmax; unsigned radius; unsigned pad; /* in x and y direction; adjust for radius ! */ unsigned skip; /* should be list-specific */ - double fg[4]; - double bg[4]; - double frame[4]; + struct color fg; + struct color bg; + struct color frame; double width; };