Merge pull request #174

This commit is contained in:
Eizen 2016-11-19 23:58:17 -03:00
commit b6dafbd444

31
src/x.c
View File

@ -537,8 +537,12 @@ static void r_free_layouts(GSList *layouts)
static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layout *cl_next, dimension_t dim, bool first, bool last)
{
int h;
int h_text;
pango_layout_get_pixel_size(cl->l, NULL, &h);
if (cl->icon) h = MAX(cairo_image_surface_get_height(cl->icon), h);
if (cl->icon) {
h_text = h;
h = MAX(cairo_image_surface_get_height(cl->icon), h);
}
int bg_x = 0;
int bg_y = dim.y;
@ -564,8 +568,7 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou
if (!last) bg_height -= settings.separator_height;
}
bg_width -= 2 * settings.frame_width;
if (last)
bg_height -= settings.frame_width;
bg_height += settings.frame_width;
cairo_set_source_rgb(c, cl->bg.r, cl->bg.g, cl->bg.b);
cairo_rectangle(c, bg_x, bg_y, bg_width, bg_height);
@ -576,9 +579,15 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou
dim.y += settings.padding;
else
dim.y += (int) (ceil(bg_half_height) - pango_offset);
if (cl->icon && settings.icon_position == icons_left)
cairo_move_to(c, cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding, dim.y);
else cairo_move_to(c, settings.h_padding, dim.y);
if (cl->icon && settings.icon_position == icons_left) {
cairo_move_to(c, settings.frame_width + cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding, bg_y + settings.padding + h/2 - h_text/2);
}
else if (cl->icon && settings.icon_position == icons_right) {
cairo_move_to(c, settings.frame_width + settings.h_padding, bg_y + settings.padding + h/2 - h_text/2);
}
else {
cairo_move_to(c, settings.frame_width + settings.h_padding, bg_y + settings.padding);
}
cairo_set_source_rgb(c, cl->fg.r, cl->fg.g, cl->fg.b);
pango_cairo_update_layout(c, cl->l);
pango_cairo_show_layout(c, cl->l);
@ -596,9 +605,9 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou
// the wrong color in the corners.
cairo_rectangle(c, 0, dim.y, dim.w, settings.separator_height);
else
cairo_rectangle(c, settings.frame_width, dim.y,
dim.w - 2 * settings.frame_width,
settings.separator_height);
cairo_rectangle(c, settings.frame_width, dim.y + settings.frame_width,
dim.w - 2 * settings.frame_width
, settings.separator_height);
cairo_fill(c);
dim.y += settings.separator_height;
@ -611,8 +620,8 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou
image_x,
image_y = bg_y + settings.padding;
if (settings.icon_position == icons_left) image_x = settings.h_padding;
else image_x = bg_width - settings.h_padding - image_width;
if (settings.icon_position == icons_left) image_x = settings.frame_width + settings.h_padding;
else image_x = bg_width - settings.h_padding - image_width + settings.frame_width;
cairo_set_source_surface (c, cl->icon, image_x, image_y);
cairo_rectangle (c, image_x, image_y, image_width, image_height);